Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/nextcloudpi-config.d/nc-swapfile.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/etc/nextcloudpi-config.d/nc-swapfile.sh b/etc/nextcloudpi-config.d/nc-swapfile.sh
index 8ff79540..82e781df 100644
--- a/etc/nextcloudpi-config.d/nc-swapfile.sh
+++ b/etc/nextcloudpi-config.d/nc-swapfile.sh
@@ -23,6 +23,7 @@ configure()
{
local ORIG=$( grep -oP "CONF_SWAPFILE=.*" /etc/dphys-swapfile | cut -f2 -d= )
[[ "$ORIG" == "$SWAPFILE_" ]] && return
+ test -d "$SWAPFILE_" && { echo "$SWAPFILE_ is a directory. Abort"; return 1; }
[[ $( stat -fc%d / ) == $( stat -fc%d $( dirname $SWAPFILE_ ) ) ]] && \
echo -e "INFO: moving swapfile to another place in the same SD card\nIf you want to use an external mount, make sure it is properly set up"
@@ -30,6 +31,10 @@ configure()
sed -i "s|#\?CONF_SWAPFILE=.*|CONF_SWAPFILE=$SWAPFILE_|" /etc/dphys-swapfile
sed -i "s|#\?CONF_SWAPSIZE=.*|CONF_SWAPSIZE=$SWAPSIZE_|" /etc/dphys-swapfile
grep -q vm.swappiness /etc/sysctl.conf || echo "vm.swappiness = 10" >> /etc/sysctl.conf && sysctl --load
+
+ # workaround for automount, systemd doesn't get the order right
+ grep -q sleep /etc/init.d/dphys-swapfile || sed -i "/\<start)/asleep 15" /etc/init.d/dphys-swapfile
+
service dphys-swapfile restart && swapoff "$ORIG" && rm -f "$ORIG"
}