From 88081d1b68991d70fe0a948634bb4a4cc3d493ae Mon Sep 17 00:00:00 2001 From: eleksir Date: Sun, 4 Sep 2016 23:58:02 +0300 Subject: [PATCH] cleanup lunportman.sh --- lunportman.sh | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/lunportman.sh b/lunportman.sh index a7a4189..7d46ec8 100755 --- a/lunportman.sh +++ b/lunportman.sh @@ -1,52 +1,51 @@ #!/bin/sh -start() -{ - if [ -z "`/sbin/lsmod | /bin/grep fbdisk | /bin/awk {'print $1'}`" ];then +start() { + if [ -z "$(/sbin/lsmod | /bin/grep fbdisk | /bin/grep -v grep)" ];then /etc/init.d/fbdisk.sh start fi if [ -f /usr/bin/lunportman ]; then echo "Starting LUN Porter manitor: lunportman..." - [ -d /etc/config/lunporter ] || /usr/bin/install -d /etc/config/lunporter + [ -d /etc/config/lunporter ] || /bin/mkdir /etc/config/lunporter [ -h /etc/lunporter ] || /bin/ln -sf config/lunporter /etc/lunporter [ -f /etc/config/lunporter/lunporter.conf ] || /bin/cp -p /etc/default_config/lunporter/lunporter.conf /etc/config/lunporter/lunporter.conf /usr/bin/lunportman fi } -stop() -{ +stop() { echo "Shutting down LUN Porter manitor: lunportman..." /usr/bin/killall -q lunportman CNT=0 + while [ $CNT -lt 10 ]; do sleep 3 /bin/pidof lunporter 1>>/dev/null 2>>/dev/null [ $? = 0 ] || break - CNT=`expr $CNT + 1` + CNT=$(($CNT + 1)) done } case "$1" in -start) - start - ;; + "start") + start + ;; -stop) - stop - ;; + "stop") + stop + ;; -restart) - stop - sleep 1 - start - ;; + "restart") + stop + sleep 1 + start + ;; -*) - echo "Usage: /etc/init.d/lunportman.sh {start|stop|restart}" - exit 1 + *) + echo "Usage: /etc/init.d/lunportman.sh {start|stop|restart}" + exit 1 esac exit 0