wok-6.x view linux64-zram/stuff/compcache @ rev 23512

updated python-netifaces (0.8 -> 0.10.9)
author Hans-G?nter Theisgen
date Mon Apr 06 10:53:56 2020 +0100 (2020-04-06)
parents a1821e12e28a
children a35e53505947
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 if [ -z "$SIZE" -o "$SIZE" = "0%" ]; then
20 _ '%s disabled in %s.' $NAME '/etc/compcache.conf'
21 exit 1
22 fi
23 action 'Loading module...'
24 devices=$(awk '/cpu cores/{c=$4} /processor/{p++}
25 END { if (c>0) p=c; if (p==0) p++; print p }' /proc/cpuinfo)
26 modprobe zram num_devices=$devices &&
27 for i in $(seq 0 $(($devices-1))); do
28 awk "/MemTotal/ { print \$2 * 1024 * ${SIZE%\%} / 100 / $devices }" \
29 < /proc/meminfo > /sys/block/zram$i/disksize
30 done
31 status
33 action 'Starting %s: %s...' "$DESC" $NAME
34 for i in $(seq 0 $(($devices-1))); do
35 mkswap /dev/zram$i && swapon /dev/zram$i -p 100
36 done
37 status
38 ;;
39 stop)
40 if [ -z "$EXIST" ] ; then
41 _ '%s is not running.' $NAME
42 exit 1
43 fi
44 action 'Stopping %s: %s...' "$DESC" $NAME
45 for i in $(cd /sys/block/; ls -d zram*); do
46 swapoff /dev/$i && echo 1 > /sys/block/$i/reset
47 done
48 status
49 action 'Unloading module...'
50 rmmod zram
51 status
52 ;;
53 *)
54 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop]"
55 newline
56 exit 1
57 ;;
58 esac
60 exit 0