Added patches init-scripts for kill services
[openstack-build/neutron-build.git] / rpm / SOURCES / neutron-nec-agent.init
1 #!/bin/bash
2 #
3 # neutron-nec-agent  OpenStack Neutron NEC OpenFlow Agent
4 #
5 # chkconfig:   - 98 02
6 # description: OpenStack Neutron NEC OpenFlow Agent
7 ### END INIT INFO
8
9 . /etc/rc.d/init.d/functions
10
11 proj=neutron
12 plugin=nec-agent
13 prog=$proj-$plugin
14 exec="/usr/bin/$prog"
15 configs=(
16     "/usr/share/$proj/$proj-dist.conf" \
17     "/etc/$proj/$proj.conf" \
18     "/etc/$proj/plugins/nec/nec.ini" \
19 )
20 pidfile="/var/run/$proj/$prog.pid"
21
22 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
23
24 lockfile=/var/lock/subsys/$prog
25
26 start() {
27     [ -x $exec ] || exit 5
28     for config in ${configs[@]}; do
29         [ -f $config ] || exit 6
30     done
31     echo -n $"Starting $prog: "
32     daemon --user neutron --pidfile $pidfile "$exec --log-file /var/log/$proj/$plugin.log ${configs[@]/#/--config-file } &>/dev/null & echo \$! > $pidfile"
33     retval=$?
34     echo
35     [ $retval -eq 0 ] && touch $lockfile
36     return $retval
37 }
38
39 stop() {
40     echo -n $"Stopping $prog: "
41     killproc -p $pidfile $prog
42     if pgrep $prog &>/dev/null ; then
43         sleep 2
44         pgrep $prog &>/dev/null && \
45         killall $prog
46     fi
47     retval=$?
48     echo
49     [ $retval -eq 0 ] && rm -f $lockfile
50     return $retval
51 }
52
53 restart() {
54     stop
55     start
56 }
57
58 reload() {
59     restart
60 }
61
62 force_reload() {
63     restart
64 }
65
66 rh_status() {
67     status -p $pidfile $prog
68 }
69
70 rh_status_q() {
71     rh_status >/dev/null 2>&1
72 }
73
74
75 case "$1" in
76     start)
77         rh_status_q && exit 0
78         $1
79         ;;
80     stop)
81         rh_status_q || exit 0
82         $1
83         ;;
84     restart)
85         $1
86         ;;
87     reload)
88         rh_status_q || exit 7
89         $1
90         ;;
91     force-reload)
92         force_reload
93         ;;
94     status)
95         rh_status
96         ;;
97     condrestart|try-restart)
98         rh_status_q || exit 0
99         restart
100         ;;
101     *)
102         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
103         exit 2
104 esac
105 exit $?