Advertisement
josacar

spawn-fcgi-munin-graph init script

Apr 7th, 2012
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.69 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides:          spawn-fcgi-munin-graph
  5. # Required-Start:    $local_fs $remote_fs $network $syslog
  6. # Required-Stop:     $local_fs $remote_fs $network $syslog
  7. # Default-Start:     2 3 4 5
  8. # Default-Stop:      0 1 6
  9. # Short-Description: spawns the munin-graph fastcgi processes
  10. # Description:       spawns fastcgi using start-stop-daemon
  11. ### END INIT INFO
  12.  
  13. # spawn-fcgi -s /var/run/munin/munin-fastcgi-html.sock -U www-data -u munin -g munin /usr/lib/cgi-bin/munin-cgi-html
  14. #set -x -v
  15.  
  16. USER=munin
  17. USER_SOCKET=www-data
  18. GROUP=munin
  19. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  20. SCRIPTNAME=/etc/init.d/spawn-fcgi-munin-graph
  21. SSD="/sbin/start-stop-daemon"
  22. RETVAL=0
  23.  
  24. FCGI_DAEMON="/usr/bin/spawn-fcgi"
  25. FCGI_PROGRAM="/usr/lib/cgi-bin/munin-cgi-graph"
  26. FCGI_PORT="4050"
  27. FCGI_SOCKET="/var/run/munin/munin-fastcgi-graph.sock"
  28. FCGI_PIDFILE="/var/run/spawn-fcgi-munin-graph.pid"
  29.  
  30. set -e
  31.  
  32. export FCGI_WEB_SERVER_ADDRS
  33.  
  34. . /lib/lsb/init-functions
  35.  
  36. case "$1" in
  37.   start)
  38.         log_daemon_msg "Starting spawn-fcgi"
  39.         if ! $FCGI_DAEMON -s $FCGI_SOCKET -f $FCGI_PROGRAM -u $USER -U $USER_SOCKET -g $GROUP -P $FCGI_PIDFILE; then
  40.             log_end_msg 1
  41.         else
  42.             log_end_msg 0
  43.         fi
  44.         RETVAL=$?
  45.   ;;
  46.   stop)
  47.         log_daemon_msg "Killing all spawn-fcgi processes"
  48.         if killall --signal 2 php-cgi > /dev/null 2> /dev/null; then
  49.             log_end_msg 0
  50.         else
  51.             log_end_msg 1
  52.         fi
  53.         RETVAL=$?
  54.   ;;
  55.   restart|force-reload)
  56.         $0 stop
  57.         $0 start
  58.   ;;
  59.   *)
  60.         echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  61.         exit 1
  62.   ;;
  63. esac
  64.  
  65. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement