1
0
mirror of https://github.com/moparisthebest/pi-hole synced 2024-11-25 18:42:16 -05:00

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.
This commit is contained in:
jacobsalmela 2015-08-25 18:01:54 -05:00
parent d68c262b96
commit fa77b7b69d

View File

@ -44,6 +44,31 @@ else
sudo mkdir $piholeDir sudo mkdir $piholeDir
fi 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 # Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and blank lines
for ((i = 0; i < "${#sources[@]}"; i++)) for ((i = 0; i < "${#sources[@]}"; i++))
do do