Postbote

/etc/init.d/munin-fastcgi

Nov 20th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.60 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          munin-fastcgi
  4. # Required-Start:    $remote_fs $network
  5. # Required-Stop:     $remote_fs $network
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: starts munin-fastcgi
  9. # Description:       Spawn Munin FCGI sockets for Web access
  10. ### END INIT INFO
  11.  
  12. #
  13. # munin-fastcgi     Startup script for Munin CGI services
  14. #
  15. # chkconfig: - 84 15
  16. # description: Loading Munin CGI services using spawn-cgi
  17. #              HTML files and CGI.
  18. #
  19. # Author:  Ryan Norbauer <[email protected]>
  20. # Modified:     Geoffrey Grosenbach http://topfunky.com
  21. # Modified:     David Krmpotic http://davidhq.com
  22. # Modified:     Kun Xi http://kunxi.org
  23. # Modified:     http://drumcoder.co.uk/
  24. # Modified:     http://uname.pingveno.net/
  25.  
  26. DAEMON=/usr/bin/spawn-fcgi
  27. FCGI_GRAPH_SOCK=/var/run/munin/fastcgi-munin-graph.sock
  28. FCGI_HTML_SOCK=/var/run/munin/fastcgi-munin-html.sock
  29. WWW_USER=www-data
  30. FCGI_USER=munin
  31. FCGI_GROUP=munin
  32. FCGI_SPAWN_GRAPH=/usr/lib/munin/cgi/munin-cgi-graph
  33. FCGI_SPAWN_HTML=/usr/lib/munin/cgi/munin-cgi-graph
  34. PIDFILE_GRAPH=/var/run/munin/fastcgi-munin-graph.pid
  35. PIDFILE_HTML=/var/run/munin/fastcgi-munin-html.pid
  36. DESC="Munin FCGI for Graph an HTML"
  37.  
  38. # Gracefully exit if the package has been removed.
  39. test -x $DAEMON || exit 0
  40. test -x $FCGI_SPAWN_GRAPH || exit 0
  41. test -x $FCGI_SPAWN_HTML || exit 0
  42.  
  43. start() {
  44.   $DAEMON -s $FCGI_GRAPH_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_GRAPH $FCGI_SPAWN_GRAPH 2> /dev/null || echo "Graph Already running"
  45.   $DAEMON -s $FCGI_HTML_SOCK -U $WWW_USER -u $FCGI_USER -g $FCGI_GROUP -P $PIDFILE_HTML $FCGI_SPAWN_HTML 2> /dev/null || echo "HTML Already running"
  46. }
  47.  
  48. stop() {
  49.   kill -QUIT `cat $PIDFILE_GRAPH` || echo "Graph not running"
  50.   kill -QUIT `cat $PIDFILE_HTML` || echo "HTML Not running"
  51. }
  52.  
  53. restart() {
  54.   kill -HUP `cat $PIDFILE_GRAPH` || echo "Can't reload Graph"
  55.   kill -HUP `cat $PIDFILE_HTML` || echo "Can't reload HTML"
  56. }
  57.  
  58. case "$1" in
  59.   start)
  60.     echo "Starting $DESC: "
  61.     start
  62.   ;;
  63.   stop)
  64.     echo "Stopping $DESC: "
  65.     stop
  66.   ;;
  67.   restart|reload)
  68.     echo "Restarting $DESC: "
  69.     stop
  70.     # One second might not be time enough for a daemon to stop,
  71.     # if this happens, d_start will fail (and dpkg will break if
  72.     # the package is being upgraded). Change the timeout if needed
  73.     # be, or change d_stop to have start-stop-daemon use --retry.
  74.     # Notice that using --retry slows down the shutdown process somewhat.
  75.     sleep 1
  76.     start
  77.   ;;
  78.   *)
  79.     echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
  80.     exit 3
  81.   ;;
  82. esac
  83.  
  84. exit $?
Advertisement
Add Comment
Please, Sign In to add comment