From ec55682f70ad8f3a36a5ef13976cec06ced50fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= Date: Sat, 30 Nov 2024 15:36:09 +0100 Subject: [PATCH] [install-federated] Create and activate a swap file in low-RAM configs --- bin/install-federated | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/install-federated b/bin/install-federated index ec8281a..3852909 100755 --- a/bin/install-federated +++ b/bin/install-federated @@ -99,6 +99,23 @@ fi #IFS=$'\n' read -r -d '' -a EXTRA_APPS_LIST < <(awk -F',' '{ for( i=1; i<=NF; i++ ) print $i }' <<<"$EXTRA_APPS") #SERVICES=("${CORE_APPS_LIST[@]}" "${EXTRA_APPS_LIST[@]}") +# Create a swap file if we're in a low RAM configuration +MEM=$(LC_ALL=C free |grep ^Mem: |awk '{ print $2; }') +if [ "$MEM" -le 2097152 ]; then + SWAPSIZE=4096 +elif [ "$MEM" -le 4194304 ]; then + SWAPSIZE=2048 +else + SWAPSIZE=0 +fi +if [ "$SWAPSIZE" -gt 0 ]; then + dd if=/dev/zero of=/swap-0001 bs=1M count=$SWAPSIZE + chmod 0600 /swap-0001 + mkswap -v1 /swap-0001 + echo '/swap-0001 none swap defaults,prio=90 0 2' >>/etc/fstab + swapon -a +fi + # Configure and start each federated core app for i in "${CORE_APPS[@]}"; do . /federated/lib/$i.sh