123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/bin/bash
- PARMS=$1
- PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/zramraid";
- DESC="Zram Raid"
- NAME="zramraid"
- SCRIPTNAME="zramraid-maker";
- ZPATH="/etc/zramraid"
- MODE="/etc/default/zramraid";
- if [[ "$PARMS" = '' ]];
- then
- echo "/etc/init.d/zramraid-manager {start|stop|restart|status}"
- exit 0
- fi
- function zRun() {
- if [ ! $(echo $USER|grep root|wc -m) = 0 ]
- then
- if [ $(cat $MODE |grep mode|grep -v '#'|sed 's/\mode=//g'|sed 's/\"//g;s/\;//g'|grep auto|wc -m) == 0 ]
- then
- echo "$(date) $NAME: no autostart from boot! mode=manual - /etc/defaults/zramraid">>/var/log/zramraid.log
- exit 0;
- else
- $ZPATH/$SCRIPTNAME --on
- fi
- exit 0;
- fi
- if [ ! $(echo $USER|grep '[priv]'|wc -m) = 0 ]
- then
- if [ $(cat $MODE |grep mode|grep -v '#'|sed 's/\mode=//g'|sed 's/\"//g;s/\;//g'|grep auto|wc -m) == 0 ]
- then
- echo "$(date) $NAME: no autostart from boot! mode=manual - /etc/defaults/zramraid">>/var/log/zramraid.log
- exit 0;
- else
- $ZPATH/$SCRIPTNAME --on
- fi
- exit 0;
- fi
- echo "$NAME:Sorry.. The only root privileges!"
- exit 0;
- }
- case "$PARMS" in
- "start" | "start" )
- zRun;
- exit 0
- ;;
- "stop" | "stop" )
- $ZPATH/$SCRIPTNAME --off
- exit 0
- ;;
- "restart" | "restart" )
- $ZPATH/$SCRIPTNAME --off
- sleep 3
- zRun;
- exit 0
- ;;
- "status" | "status" )
- $ZPATH/$SCRIPTNAME --status
- exit 0
- ;;
- "boot" | "boot" )
- zBoot;
- exit 0
- ;;
- * )
- echo
- echo "no input parameters."
- exit 1
- ;;
- esac
|