From fa77b7b69da4aaea1f349a015ceeba92514cefac Mon Sep 17 00:00:00 2001 From: jacobsalmela Date: Tue, 25 Aug 2015 18:01:54 -0500 Subject: [PATCH] increase swap to fix #37 memory error This will increase the swap file to 500MB before downloading the lists. Most of the issue comes from the mahakala list, which is so large. If no swap file is found, one is created. --- gravity.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/gravity.sh b/gravity.sh index f1e70a6..71b194d 100755 --- a/gravity.sh +++ b/gravity.sh @@ -44,6 +44,31 @@ else sudo mkdir $piholeDir fi +# Add additional swap to prevent the "Error fork: unable to allocate memory" message: https://github.com/jacobsalmela/pi-hole/issues/37 +function createSwapFile() +######################### + { + echo "** Creating more swap space to accomodate large solar masses..." + sudo dphys-swapfile swapoff + sudo curl -s -o /etc/dphys-swapfile https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dphys-swapfile + sudo dphys-swapfile setup + sudo dphys-swapfile swapon + } + +if [[ -f /etc/dphys-swapfile ]];then + swapSize=$(cat /etc/dphys-swapfile | grep -m1 CONF_SWAPSIZE | cut -d'=' -f2) + if [[ $swapSize != 500 ]];then + mv /etc/dphys-swapfile /etc/dphys-swapfile.orig + echo "** Current swap size is $swapSize" + createSwapFile + else + : + fi +else + echo "** No swap file found. Creating one..." + createSwapFile +fi + # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines for ((i = 0; i < "${#sources[@]}"; i++)) do