Merge "Rebuild neutron in 8.0 branch" into openstack-ci/fuel-8.0/liberty
[openstack-build/neutron-build.git] / centos7 / rpm / SOURCES / neutron-ovs-cleanup.init
diff --git a/centos7/rpm/SOURCES/neutron-ovs-cleanup.init b/centos7/rpm/SOURCES/neutron-ovs-cleanup.init
new file mode 100644 (file)
index 0000000..9b6906f
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# neutron-ovs-cleanup  OpenStack Open vSwitch cleanup utility
+#
+# chkconfig:   - 97 02
+# description: Purge Open vSwitch of the Neutron devices
+#
+# This is a one-shot init.d script with the next properties:
+#
+# * It accepts 3 verbs: start, stop, status
+# * It cleans unused resources during start (system or agents startup)
+# * It cleans everything on stop (agents migration to other hosts)
+# * Once started, it will respond with status = OK
+# * Once stopped, it will respond with status = DEAD
+#
+### END INIT INFO
+
+. /etc/rc.d/init.d/functions
+
+proj=neutron
+prog=$proj-ovs-cleanup
+exec="/usr/bin/$prog"
+pidfile="/var/run/$proj/$prog.pid"
+configs=(
+    "/usr/share/$proj/$proj-dist.conf" \
+    "/etc/$proj/$proj.conf" \
+    "/etc/$proj/plugins/openvswitch/ovs_neutron_plugin.ini" \
+)
+configs_str=${configs[@]/#/--config-file }
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/$prog
+
+clean() {
+    [ -x $exec ] || exit 5
+    for config in ${configs[@]}; do
+        [ -f $config ] || exit 6
+    done
+    runuser -s /bin/bash neutron -c "$exec --log-file /var/log/$proj/ovs-cleanup.log $configs_str &>/dev/null"
+    return $?
+}
+
+retval=0
+
+case "$1" in
+    start)
+        clean
+        retval=$?
+        [ $retval -eq 0 ] && touch $lockfile
+        ;;
+    stop)
+        clean
+        retval=$?
+        [ $retval -eq 0 ] && rm -f $lockfile
+        ;;
+    status)
+        [ ! -f $lockfile ] && retval=3
+        ;;
+    restart|reload|force-reload|condrestart|try-restart)
+        # Do nothing
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+        exit 2
+esac
+exit $retval