upstream/openstack/python-neutron/centos/files/neutron-ovs-cleanup.init

68 lines
1.6 KiB
Bash

#!/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/ml2/openvswitch_agent.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