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