wok-current view linux64-zram/stuff/compcache @ rev 22559
updated bogofilter (1.2.4 -> 1.2.5)
author | Hans-G?nter Theisgen |
---|---|
date | Sat Jan 04 16:49:42 2020 +0100 (2020-01-04) |
parents | 5cfd86a4f9d1 |
children | a1821e12e28a |
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 num_devices=$devices &&
23 [ -n "$SIZE_KB" ] && for i in $(seq 0 $(($devices-1))); do
24 awk "END { print $SIZE_KB * 1024 / $devices }" < /dev/null \
25 > /sys/block/zram$i/disksize
26 done
27 status
29 action 'Starting %s: %s...' "$DESC" $NAME
30 for i in $(seq 0 $(($devices-1))); do
31 mkswap /dev/zram$i && swapon /dev/zram$i -p 100
32 done
33 status
34 ;;
35 stop)
36 if [ -z "$EXIST" ] ; then
37 _ '%s is not running.' $NAME
38 exit 1
39 fi
40 action 'Stopping %s: %s...' "$DESC" $NAME
41 for i in $(cd /sys/block/; ls -d zram*); do
42 swapoff /dev/$i && echo 1 > /sys/block/$i/reset
43 done
44 status
45 action 'Unloading module...'
46 rmmod zram
47 status
48 ;;
49 *)
50 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop]"
51 newline
52 exit 1
53 ;;
54 esac
56 exit 0