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