From 1e746edf35f5e1dd62f189fdc6c045a5d1482fa8 Mon Sep 17 00:00:00 2001 From: Shubhendu Tripathi Date: Wed, 22 Jul 2015 16:55:06 +0530 Subject: extras: Exit with SUCCESS if no processes to stop This script might be executed even when there are no valid processes running to be stopped. In this scenario, the script should return with SUCCESS Change-Id: Ia293214a4b5052bc4bef9769f197f7b05c55ffe9 BUG: 1279776 Signed-off-by: Shubhendu Tripathi Reviewed-on: http://review.gluster.org/11739 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-on: http://review.gluster.org/12564 Tested-by: Ramesh N Reviewed-by: Aravinda VK --- extras/stop-all-gluster-processes.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'extras') diff --git a/extras/stop-all-gluster-processes.sh b/extras/stop-all-gluster-processes.sh index 087afa4cf22..25dc0ba6bf6 100755 --- a/extras/stop-all-gluster-processes.sh +++ b/extras/stop-all-gluster-processes.sh @@ -2,6 +2,8 @@ function main() { + errors=0; + for pidfile in $(find /var/lib/glusterd/ -iname '*pid'); do pid=$(cat ${pidfile}); @@ -13,7 +15,10 @@ function main() # processes are not having a pid file, so get it through 'ps' and # handle these processes gsyncpid=`ps aux | grep gluster | grep gsync | awk '{print $2}'`; - test -n "$gsyncpid" && kill -TERM $gsyncpid; + if [ -n "$gsyncpid" ] + then + kill -TERM $gsyncpid || errors=$(($errors + 1)); + fi sleep 5; @@ -27,7 +32,12 @@ function main() # handle 'KILL' of geo-replication gsyncpid=`ps aux | grep gluster | grep gsync | awk '{print $2}'`; - test -n "$gsyncpid" && kill -KILL $gsyncpid; + if [ -n "$gsyncpid" ] + then + kill -KILL $gsyncpid || errors=$(($errors + 1)); + fi + + exit $errors; } main "$@"; -- cgit