Rebuild neutron in 8.0 branch
[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     "/usr/share/$proj/$proj-dist.conf" \
26     "/etc/$proj/$proj.conf" \
27     "/etc/$proj/plugins/openvswitch/ovs_neutron_plugin.ini" \
28 )
29 configs_str=${configs[@]/#/--config-file }
30
31 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
32
33 lockfile=/var/lock/subsys/$prog
34
35 clean() {
36     [ -x $exec ] || exit 5
37     for config in ${configs[@]}; do
38         [ -f $config ] || exit 6
39     done
40     runuser -s /bin/bash neutron -c "$exec --log-file /var/log/$proj/ovs-cleanup.log $configs_str &>/dev/null"
41     return $?
42 }
43
44 retval=0
45
46 case "$1" in
47     start)
48         clean
49         retval=$?
50         [ $retval -eq 0 ] && touch $lockfile
51         ;;
52     stop)
53         clean
54         retval=$?
55         [ $retval -eq 0 ] && rm -f $lockfile
56         ;;
57     status)
58         [ ! -f $lockfile ] && retval=3
59         ;;
60     restart|reload|force-reload|condrestart|try-restart)
61         # Do nothing
62         ;;
63     *)
64         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
65         exit 2
66 esac
67 exit $retval