Share Pastebin
Guest
Public paste!

Malcolm

By: a guest | Jul 8th, 2009 | Syntax: None | Size: 2.52 KB | Hits: 72 | Expires: Never
Copy text to clipboard
  1. #!/bin/sh
  2. #
  3. # Poweralert 12.0 Unix Shell Script to start and stop the engine
  4. # only. Modified by MJL 23 June, 2006
  5. #
  6. #---------------------------------------
  7. # Usage:
  8. #        pa start|stop|restart|status
  9. #
  10. #---------------------------------------
  11. #
  12. # Added status checks
  13. . /etc/rc.status
  14. rc_reset
  15.  
  16. ### BEGIN INIT INFO
  17. # Provides:          PowerAlert Engine
  18. # Required-Start:    $ALL
  19. # Should-Start:      $ALL
  20. # Required-Stop:     $ALL
  21. # Should-Stop:       $ALL
  22. # Default-Start:     2 3 5
  23. # Default-Stop:      0 2 3 5
  24. # Short-Description: PowerAlert engine daemon
  25. # Description:       PowerAlert engine daemon modifed by MJL to start/stop and status of engine only
  26. ### END INIT INFO
  27.  
  28. TRIPPLITE_PA_HOME=/opt/TrippLite/PowerAlert
  29.  
  30. SRV_PATH=$TRIPPLITE_PA_HOME/engine
  31. #CNS_PATH=$TRIPPLITE_PA_HOME/console
  32.  
  33. #UNINSTALL_PATH=$TRIPPLITE_PA_HOME/_uninst
  34.  
  35. cd $TRIPPLITE_PA_HOME
  36.  
  37. #paramNum=$#
  38. #param2="engine"
  39. #Copy the process table
  40. ps -efw > tempFile
  41.  
  42. case "$1" in
  43.     start)
  44.          if `cat tempFile | grep engine/pa > /dev/null`
  45.             then
  46.             echo -n "PowerAlert Engine is already running... "
  47.          else
  48.             echo -n "Starting PowerAlert Engine... "
  49.             $SRV_PATH/pa
  50.             sleep 3
  51.          fi
  52.          rc_status -v
  53.          ;;
  54.     stop)
  55.         if `cat tempFile | grep engine/pa > /dev/null`
  56.            then
  57.            echo -n "Stopping PowerAlert Engine... "
  58.            kill `pidof engine/pa`
  59.            sleep 3
  60.            rc_status -v
  61.         else
  62.            echo -n "PowerAlert Engine is already stopped... "
  63.            rc_status -v
  64.         fi
  65.         ;;
  66.     restart)
  67.         ## Stop the service and regardless of whether it was
  68.         ## running or not, start it again.
  69.         $0 stop
  70.         $0 start
  71.         # Remember status and be quiet
  72.         rc_status
  73.         ;;
  74.     status)
  75.         if `cat tempFile | grep engine/pa > /dev/null`
  76.            then
  77.            echo "PowerAlert Engine is running "
  78.         else
  79.            echo "PowerAlert Engine is stopped "
  80.         fi
  81.         ## Check status with checkproc(8), if process is running
  82.         ## checkproc will return with exit status 0.
  83.          
  84.         # Return value is slightly different for the status command:
  85.         # 0 - service up and running
  86.         # 1 - service dead, but /var/run/  pid  file exists
  87.         # 2 - service dead, but /var/lock/ lock file exists
  88.         # 3 - service not running (unused)
  89.         # 4 - service status unknown :-(
  90.         # 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
  91.         ;;
  92.     *)
  93.         echo "Usage: $0 {start|stop|restart|status}"
  94.         exit 1
  95.         ;;
  96. esac
  97. rc_exit