wok annotate linux-zram/stuff/compcache @ rev 21752

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