feb4af521f19656034a418885a96afd0736005b5
[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     retval=$?
45     echo
46     [ $retval -eq 0 ] && rm -f $lockfile
47     return $retval
48 }
49
50 restart() {
51     stop
52     start
53 }
54
55 reload() {
56     restart
57 }
58
59 force_reload() {
60     restart
61 }
62
63 rh_status() {
64     status -p $pidfile $prog
65 }
66
67 rh_status_q() {
68     rh_status >/dev/null 2>&1
69 }
70
71
72 case "$1" in
73     start)
74         rh_status_q && exit 0
75         $1
76         ;;
77     stop)
78         rh_status_q || exit 0
79         $1
80         ;;
81     restart)
82         $1
83         ;;
84     reload)
85         rh_status_q || exit 7
86         $1
87         ;;
88     force-reload)
89         force_reload
90         ;;
91     status)
92         rh_status
93         ;;
94     condrestart|try-restart)
95         rh_status_q || exit 0
96         restart
97         ;;
98     *)
99         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
100         exit 2
101 esac
102 exit $?