wok-undigest annotate linux/stuff/compcache @ rev 1257

recook binutils
author Hans-Günter Theisgen
date Sat Aug 13 10:55:58 2022 +0100 (2022-08-13)
parents
children
rev   line source
Hans-Günter@1217 1 #!/bin/sh
Hans-Günter@1217 2 # /etc/init.d/compcache: Start, stop and restart COMPCACHE daemon on SliTaz,
Hans-Günter@1217 3 # at boot time or with the command line. Daemons options are configured
Hans-Günter@1217 4 # with /etc/daemons.conf
Hans-Günter@1217 5 #
Hans-Günter@1217 6 . /etc/init.d/rc.functions
Hans-Günter@1217 7 source /etc/compcache.conf
Hans-Günter@1217 8
Hans-Günter@1217 9 NAME="compcache"
Hans-Günter@1217 10 DESC="$(_ '%s daemon' compcache)"
Hans-Günter@1217 11 EXIST=$(cat /proc/swaps | grep zram0)
Hans-Günter@1217 12
Hans-Günter@1217 13 case "$1" in
Hans-Günter@1217 14 start)
Hans-Günter@1217 15 if [ -n "$EXIST" ] ; then
Hans-Günter@1217 16 _ '%s is already running.' $NAME
Hans-Günter@1217 17 exit 1
Hans-Günter@1217 18 fi
Hans-Günter@1217 19 action 'Loading module...'
Hans-Günter@1217 20 modprobe zram zram_num_devices=1 &&
Hans-Günter@1217 21 [ -n "$SIZE_KB" ] && echo $(($SIZE_KB * 1024)) > /sys/block/zram0/disksize
Hans-Günter@1217 22 status
Hans-Günter@1217 23
Hans-Günter@1217 24 action 'Starting %s: %s...' "$DESC" $NAME
Hans-Günter@1217 25 mkswap /dev/zram0 && swapon /dev/zram0 -p 100
Hans-Günter@1217 26 status
Hans-Günter@1217 27 ;;
Hans-Günter@1217 28 stop)
Hans-Günter@1217 29 if [ -z "$EXIST" ] ; then
Hans-Günter@1217 30 _ '%s is not running.' $NAME
Hans-Günter@1217 31 exit 1
Hans-Günter@1217 32 fi
Hans-Günter@1217 33 action 'Stopping %s: %s...' "$DESC" $NAME
Hans-Günter@1217 34 swapoff /dev/zram0 && echo 1 > /sys/block/zram0/reset
Hans-Günter@1217 35 status
Hans-Günter@1217 36 action 'Unloading module...'
Hans-Günter@1217 37 rmmod zram
Hans-Günter@1217 38 status
Hans-Günter@1217 39 ;;
Hans-Günter@1217 40 *)
Hans-Günter@1217 41 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop]"
Hans-Günter@1217 42 newline
Hans-Günter@1217 43 exit 1
Hans-Günter@1217 44 ;;
Hans-Günter@1217 45 esac
Hans-Günter@1217 46
Hans-Günter@1217 47 exit 0