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