zramraid-manager 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: zramraid-manager
  4. # Required-Start: udev $local_fs $remote_fs $time
  5. # Required-Stop: $local_fs $remote_fs
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: start the zraid
  9. # Description: starts zraid using start-stop-daemon
  10. ### END INIT INFO
  11. ## version =25.06.18
  12. PARMS=$1
  13. export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
  14. DESC="Zram Raid"
  15. NAME="zramraid"
  16. SCRIPTNAME="zramraid-maker";
  17. ZPATH="/etc/zramraid"
  18. MODE="/etc/defaults/zramraid";
  19. ##
  20. if [[ "$PARMS" = '' ]];
  21. then
  22. echo "/etc/init.d/zramraid-manager {start|stop|restart|status}"
  23. exit 0
  24. fi
  25. function zramraidBoot() {
  26. if [ $(echo $(($(echo $USER|wc -m)-1))) == 0 ]
  27. then
  28. if [ $(cat $MODE |grep mode|grep -v '#'|sed 's/\mode=//g'|sed 's/\"//g;s/\;//g'|grep auto|wc -m) == 0 ]
  29. then
  30. exit 0;
  31. else
  32. $ZPATH/$SCRIPTNAME --on
  33. fi
  34. echo "$NAME:Sorry.. The only root privileges!"
  35. exit 0;
  36. fi
  37. }
  38. ### begin
  39. case "$PARMS" in
  40. "start" | "start" )
  41. zramraidBoot;
  42. exit 0
  43. ;;
  44. "stop" | "stop" )
  45. $ZPATH/$SCRIPTNAME --off
  46. exit 0
  47. ;;
  48. "restart" | "restart" )
  49. $ZPATH/$SCRIPTNAME --off
  50. sleep 3
  51. zramraidBoot;
  52. exit 0
  53. ;;
  54. "status" | "status" )
  55. $ZPATH/$SCRIPTNAME --status
  56. exit 0
  57. ;;
  58. * )
  59. echo
  60. echo "no input parameters."
  61. exit 1
  62. ;;
  63. esac