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