From afb6f13517d6d532a94d51e91ca9727cc58387a5 Mon Sep 17 00:00:00 2001 From: Stephan Raue Date: Wed, 7 Sep 2011 23:11:57 +0200 Subject: [PATCH] util-linux: start init scripts on RUNLEVEL=boot Signed-off-by: Stephan Raue --- .../sysutils/util-linux/init.d/32_swapfile | 53 +++++++++++-------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/packages/sysutils/util-linux/init.d/32_swapfile b/packages/sysutils/util-linux/init.d/32_swapfile index 80cb8be661..4f30fb20b4 100644 --- a/packages/sysutils/util-linux/init.d/32_swapfile +++ b/packages/sysutils/util-linux/init.d/32_swapfile @@ -23,29 +23,36 @@ # # runlevels: openelec, textmode -( - INSTALLED_MEMORY=`cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}'` - SWAP=`blkid -t TYPE="swap" -o device` - SWAPFILE="$HOME/.cache/swapfile" +case $RUNLEVEL in + boot) + ( + INSTALLED_MEMORY=`cat /proc/meminfo | grep 'MemTotal:' | awk '{print $2}'` + SWAP=`blkid -t TYPE="swap" -o device` + SWAPFILE="$HOME/.cache/swapfile" - if [ "$INSTALLED_MEMORY" -le "500000" ]; then - if [ -z "$SWAP" -a ! -f "$SWAPFILE" ]; then - progress "creating swapfile" - mkdir -p $HOME/.cache - dd if=/dev/zero of=$SWAPFILE bs=1024 count=262144 2>&1 > /dev/null - mkswap $SWAPFILE 2>&1 > /dev/null - fi + if [ "$INSTALLED_MEMORY" -le "500000" ]; then + if [ -z "$SWAP" -a ! -f "$SWAPFILE" ]; then + progress "creating swapfile" + mkdir -p $HOME/.cache + dd if=/dev/zero of=$SWAPFILE bs=1024 count=262144 2>&1 > /dev/null + mkswap $SWAPFILE 2>&1 > /dev/null + fi - progress "enable swap" - [ -z "$SWAP" -a -f "$SWAPFILE" ] && SWAP=$SWAPFILE - for i in $SWAP; do - swapon -p 10000 $SWAP 2>&1 > /dev/null - done + progress "enable swap" + [ -z "$SWAP" -a -f "$SWAPFILE" ] && SWAP=$SWAPFILE + for i in $SWAP; do + swapon -p 10000 $SWAP 2>&1 > /dev/null + done - if [ "$INSTALLED_MEMORY" -le "260000" ]; then - sysctl -w vm.swappiness=100 2>&1 > /dev/null - else - sysctl -w vm.swappiness=60 2>&1 > /dev/null - fi - fi -)& \ No newline at end of file + if [ "$INSTALLED_MEMORY" -le "260000" ]; then + sysctl -w vm.swappiness=100 2>&1 > /dev/null + else + sysctl -w vm.swappiness=60 2>&1 > /dev/null + fi + fi + )& + ;; + + poweroff|reboot) + ;; +esac