Update to 8.0.0
[openstack-build/neutron-build.git] / centos7 / rpm / SOURCES / neutron-ovs-cleanup.init
1 #!/bin/bash
2 #
3 # neutron-ovs-cleanup  OpenStack Open vSwitch cleanup utility
4 #
5 # chkconfig:   - 97 02
6 # description: Purge Open vSwitch of the Neutron devices
7 #
8 # This is a one-shot init.d script with the next properties:
9 #
10 # * It accepts 3 verbs: start, stop, status
11 # * It cleans unused resources during start (system or agents startup)
12 # * It cleans everything on stop (agents migration to other hosts)
13 # * Once started, it will respond with status = OK
14 # * Once stopped, it will respond with status = DEAD
15 #
16 ### END INIT INFO
17
18 . /etc/rc.d/init.d/functions
19
20 proj=neutron
21 prog=$proj-ovs-cleanup
22 exec="/usr/bin/$prog"
23 pidfile="/var/run/$proj/$prog.pid"
24 configs=(
25     "/etc/$proj/$proj.conf" \
26     "/etc/$proj/plugins/ml2/openvswitch_agent.ini" \
27 )
28 configs_str=${configs[@]/#/--config-file }
29
30 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
31
32 lockfile=/var/lock/subsys/$prog
33
34 clean() {
35     [ -x $exec ] || exit 5
36     for config in ${configs[@]}; do
37         [ -f $config ] || exit 6
38     done
39     runuser -s /bin/bash neutron -c "$exec --log-file /var/log/$proj/ovs-cleanup.log $configs_str &>/dev/null"
40     return $?
41 }
42
43 retval=0
44
45 case "$1" in
46     start)
47         clean
48         retval=$?
49         [ $retval -eq 0 ] && touch $lockfile
50         ;;
51     stop)
52         clean
53         retval=$?
54         [ $retval -eq 0 ] && rm -f $lockfile
55         ;;
56     status)
57         [ ! -f $lockfile ] && retval=3
58         ;;
59     restart|reload|force-reload|condrestart|try-restart)
60         # Do nothing
61         ;;
62     *)
63         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
64         exit 2
65 esac
66 exit $retval