Added patches init-scripts for kill services
[openstack-build/neutron-build.git] / rpm / SOURCES / neutron-server.init
1 #!/bin/bash
2 #
3 # neutron  OpenStack Software Defined Networking Service
4 #
5 # chkconfig:   - 98 02
6 # description: neutron provides an API to  \
7 #               * request and configure virtual networks
8 ### END INIT INFO
9
10 . /etc/rc.d/init.d/functions
11
12 prog=neutron
13 exec="/usr/bin/$prog-server"
14 configs=(
15     "/usr/share/$prog/$prog-dist.conf" \
16     "/etc/$prog/$prog.conf" \
17     "/etc/$prog/plugin.ini" \
18 )
19 pidfile="/var/run/$prog/$prog.pid"
20 logfile="/var/log/$prog/server.log"
21
22 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
23
24 lockfile=/var/lock/subsys/$prog-server
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 ${configs[@]/#/--config-file } --log-file $logfile &>/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-server &>/dev/null ; then
43         sleep 2
44         pgrep $prog-server &>/dev/null && \
45         killall $prog-server
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 $?