wok-current annotate linux64-zram/stuff/compcache @ rev 22820
created recipe for xprintidle-2.1
author | Hans-G?nter Theisgen |
---|---|
date | Wed Feb 05 15:08:31 2020 +0100 (2020-02-05) |
parents | 5cfd86a4f9d1 |
children | a1821e12e28a |
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)" |
pascal@22023 | 11 EXIST="$(grep -s zram0 /proc/swaps)" |
pascal@13390 | 12 |
pascal@13390 | 13 case "$1" in |
pascal@13390 | 14 start) |
pascal@22023 | 15 if [ "$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...' |
pascal@21917 | 20 devices=$(awk '/cpu cores/{c=$4} /processor/{p++} |
pascal@21917 | 21 END { if (c>0) p=c; if (p==0) p++; print p }' /proc/cpuinfo) |
Hans-G?nter@22377 | 22 modprobe zram num_devices=$devices && |
pascal@21917 | 23 [ -n "$SIZE_KB" ] && for i in $(seq 0 $(($devices-1))); do |
pascal@22385 | 24 awk "END { print $SIZE_KB * 1024 / $devices }" < /dev/null \ |
pascal@22385 | 25 > /sys/block/zram$i/disksize |
pascal@21917 | 26 done |
pascal@13390 | 27 status |
pascal@13390 | 28 |
al@19159 | 29 action 'Starting %s: %s...' "$DESC" $NAME |
pascal@21917 | 30 for i in $(seq 0 $(($devices-1))); do |
pascal@21917 | 31 mkswap /dev/zram$i && swapon /dev/zram$i -p 100 |
pascal@21917 | 32 done |
pascal@13390 | 33 status |
pascal@13390 | 34 ;; |
pascal@13390 | 35 stop) |
al@19159 | 36 if [ -z "$EXIST" ] ; then |
al@19159 | 37 _ '%s is not running.' $NAME |
pascal@13390 | 38 exit 1 |
pascal@13390 | 39 fi |
al@19159 | 40 action 'Stopping %s: %s...' "$DESC" $NAME |
pascal@21917 | 41 for i in $(cd /sys/block/; ls -d zram*); do |
pascal@21917 | 42 swapoff /dev/$i && echo 1 > /sys/block/$i/reset |
pascal@21917 | 43 done |
pascal@13390 | 44 status |
al@19159 | 45 action 'Unloading module...' |
pascal@13390 | 46 rmmod zram |
pascal@13390 | 47 status |
pascal@13390 | 48 ;; |
pascal@13390 | 49 *) |
al@19159 | 50 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop]" |
al@19159 | 51 newline |
pascal@13390 | 52 exit 1 |
pascal@13390 | 53 ;; |
pascal@13390 | 54 esac |
pascal@13390 | 55 |
pascal@13390 | 56 exit 0 |