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