Added patches init-scripts for kill services
[openstack-build/neutron-build.git] / rpm / SOURCES / neutron-mlnx-agent.init
index 8db937b31ade4038013c4e0bb09b7e42f42eb67e..b5e514f37388cfb229df1714f5e95043b23454ac 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # neutron-mlnx-agent  OpenStack Neutron Mellanox Agent
 #
@@ -12,7 +12,11 @@ proj=neutron
 plugin=mlnx-agent
 prog=$proj-$plugin
 exec="/usr/bin/$prog"
-config="/etc/$proj/plugins/mlnx/mlnx_conf.ini"
+configs=(
+    "/usr/share/$proj/$proj-dist.conf" \
+    "/etc/$proj/$proj.conf" \
+    "/etc/$proj/plugins/mlnx/mlnx_conf.ini" \
+)
 pidfile="/var/run/$proj/$prog.pid"
 
 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
@@ -21,9 +25,11 @@ lockfile=/var/lock/subsys/$prog
 
 start() {
     [ -x $exec ] || exit 5
-    [ -f $config ] || exit 6
+    for config in ${configs[@]}; do
+        [ -f $config ] || exit 6
+    done
     echo -n $"Starting $prog: "
-    daemon --user neutron --pidfile $pidfile "$exec --log-file /var/log/$proj/$plugin.log --config-file /etc/$proj/$proj.conf --config-file $config &>/dev/null & echo \$! > $pidfile"
+    daemon --user neutron --pidfile $pidfile "$exec --log-file /var/log/$proj/$plugin.log ${configs[@]/#/--config-file } &>/dev/null & echo \$! > $pidfile"
     retval=$?
     echo
     [ $retval -eq 0 ] && touch $lockfile
@@ -33,6 +39,11 @@ start() {
 stop() {
     echo -n $"Stopping $prog: "
     killproc -p $pidfile $prog
+    if pgrep $prog &>/dev/null ; then
+        sleep 2
+        pgrep $prog &>/dev/null && \
+        killall $prog
+    fi
     retval=$?
     echo
     [ $retval -eq 0 ] && rm -f $lockfile