wok view linux64-zram/stuff/compcache @ rev 22153
updated xbindkeys (1.8.3 -> 1.8.6)
author | Hans-G?nter Theisgen |
---|---|
date | Thu Nov 07 07:22:09 2019 +0100 (2019-11-07) |
parents | 2ba7edb00cce |
children | 5cfd86a4f9d1 |
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="$(grep -s zram0 /proc/swaps)"
13 case "$1" in
14 start)
15 if [ "$EXIST" ] ; then
16 _ '%s is already running.' $NAME
17 exit 1
18 fi
19 action 'Loading module...'
20 devices=$(awk '/cpu cores/{c=$4} /processor/{p++}
21 END { if (c>0) p=c; if (p==0) p++; print p }' /proc/cpuinfo)
22 modprobe zram zram_num_devices=$devices &&
23 [ -n "$SIZE_KB" ] && for i in $(seq 0 $(($devices-1))); do
24 echo $(($SIZE_KB * 1024 / $devices)) > /sys/block/zram$i/disksize
25 done
26 status
28 action 'Starting %s: %s...' "$DESC" $NAME
29 for i in $(seq 0 $(($devices-1))); do
30 mkswap /dev/zram$i && swapon /dev/zram$i -p 100
31 done
32 status
33 ;;
34 stop)
35 if [ -z "$EXIST" ] ; then
36 _ '%s is not running.' $NAME
37 exit 1
38 fi
39 action 'Stopping %s: %s...' "$DESC" $NAME
40 for i in $(cd /sys/block/; ls -d zram*); do
41 swapoff /dev/$i && echo 1 > /sys/block/$i/reset
42 done
43 status
44 action 'Unloading module...'
45 rmmod zram
46 status
47 ;;
48 *)
49 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop]"
50 newline
51 exit 1
52 ;;
53 esac
55 exit 0