wok-6.x annotate linux-zram/stuff/compcache @ rev 22377
linux[64]-zram: modified modprobe command according to bug report 230
author | Hans-G?nter Theisgen |
---|---|
date | Thu Nov 28 07:37:48 2019 +0100 (2019-11-28) |
parents | ac1cbda6d814 |
children | 804a303f31dc |
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@21917 | 24 echo $(($SIZE_KB * 1024 / $devices)) > /sys/block/zram$i/disksize |
pascal@21917 | 25 done |
pascal@13390 | 26 status |
pascal@13390 | 27 |
al@19159 | 28 action 'Starting %s: %s...' "$DESC" $NAME |
pascal@21917 | 29 for i in $(seq 0 $(($devices-1))); do |
pascal@21917 | 30 mkswap /dev/zram$i && swapon /dev/zram$i -p 100 |
pascal@21917 | 31 done |
pascal@13390 | 32 status |
pascal@13390 | 33 ;; |
pascal@13390 | 34 stop) |
al@19159 | 35 if [ -z "$EXIST" ] ; then |
al@19159 | 36 _ '%s is not running.' $NAME |
pascal@13390 | 37 exit 1 |
pascal@13390 | 38 fi |
al@19159 | 39 action 'Stopping %s: %s...' "$DESC" $NAME |
pascal@21917 | 40 for i in $(cd /sys/block/; ls -d zram*); do |
pascal@21917 | 41 swapoff /dev/$i && echo 1 > /sys/block/$i/reset |
pascal@21917 | 42 done |
pascal@13390 | 43 status |
al@19159 | 44 action 'Unloading module...' |
pascal@13390 | 45 rmmod zram |
pascal@13390 | 46 status |
pascal@13390 | 47 ;; |
pascal@13390 | 48 *) |
al@19159 | 49 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop]" |
al@19159 | 50 newline |
pascal@13390 | 51 exit 1 |
pascal@13390 | 52 ;; |
pascal@13390 | 53 esac |
pascal@13390 | 54 |
pascal@13390 | 55 exit 0 |