Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # observer Starts and stops Observer daemon |
| 4 | # |
| 5 | |
| 6 | # Source function library. |
| 7 | . /etc/init.d/functions |
| 8 | |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 9 | [ -f /etc/sysconfig/xosobserver ] && . /etc/sysconfig/xosobserver |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 10 | |
| 11 | |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 12 | xosobserver=${NODEMANAGER-"python /opt/xos/xos-observer.py -d"} |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 13 | prog="OpenCloud Observer" |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 14 | pidfile=${PIDFILE-/var/run/xosobserver.pid} |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 15 | |
| 16 | RETVAL=0 |
| 17 | |
| 18 | function start() { |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 19 | action $"Starting $prog: " daemon --pidfile=$pidfile --check=xosobserver $xosobserver "$@" |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | function stop() { |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 23 | action $"Stopping $prog: " killproc -p $pidfile xosobserver |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | case "$1" in |
| 27 | start) |
| 28 | start $options |
| 29 | ;; |
| 30 | stop) |
| 31 | stop |
| 32 | ;; |
| 33 | status) |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 34 | status -p $pidfile xosobserver |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 35 | RETVAL=$? |
| 36 | ;; |
| 37 | restart|reload) |
| 38 | shift |
| 39 | stop |
| 40 | start $options "$@" |
| 41 | ;; |
| 42 | condrestart) |
| 43 | shift |
| 44 | [ -f ${pidfile} ] && { stop; start $options "$@"; } |
| 45 | ;; |
| 46 | restartverbose) |
| 47 | shift |
| 48 | stop |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 49 | $xosobserver $verboseoptions "$@" |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 50 | ;; |
| 51 | restartdebug) |
| 52 | shift |
| 53 | stop |
| 54 | echo "Restarting with $debugoptions $@ .." |
Scott Baker | b1a951d | 2015-02-19 13:24:52 -0800 | [diff] [blame^] | 55 | $xosobserver $debugoptions "$@" |
Sapan Bhatia | ca9b4e2 | 2014-08-04 23:42:21 -0400 | [diff] [blame] | 56 | ;; |
| 57 | *) |
| 58 | echo $"Usage: $0 {start|stop|status|restart|condrestart|restartdebug [-d]}" |
| 59 | exit 1 |
| 60 | ;; |
| 61 | esac |
| 62 | |
| 63 | exit $RETVAL |