From 1404edae2d1ad79e0aa8259f736bee73f9410a68 Mon Sep 17 00:00:00 2001 From: zribiahmed Date: Fri, 7 Jun 2013 16:59:06 +0000 Subject: [PATCH] PR3154: cwmp binary Only one instance should run --- src/init/cwmpd.init | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/init/cwmpd.init b/src/init/cwmpd.init index d4a663b..b746c25 100644 --- a/src/init/cwmpd.init +++ b/src/init/cwmpd.init @@ -86,15 +86,6 @@ run() { done } -kill_process() { -for pid in "$1" -do - if [ "_$pid" != "_" ];then - /bin/kill -9 $pid 2> /dev/null - fi -done -} - boot() { touch /etc/cwmpd/.cwmpd_boot } @@ -129,9 +120,26 @@ start() { stop() { echo $stop_msg;printf "\033[A" ;sleep 1 - kill_process "`ps aux|grep /usr/sbin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:`" - kill_process "`ps aux|grep /tmp/freecwmp_action.sh|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:`" - kill_process "`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:`" + ubus call tr069 command '{"command": "exit"}' -t 3 &> /dev/null + + pids="`ps aux|grep /usr/sbin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v \" Z \"|grep -v grep|cut -f1 -d:|tr '\n' ' '`" + while [ "_$pids" != "_" ];do + kill -9 $pids 2> /dev/null + pids="`ps aux|grep /usr/sbin/cwmpd|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v \" Z \"|grep -v grep|cut -f1 -d:|tr '\n' ' '`" + done + + pids="`ps aux|grep /tmp/freecwmp_action.sh|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`" + while [ "_$pids" != "_" ];do + kill -9 $pids 2> /dev/null + pids="`ps aux|grep /tmp/freecwmp_action.sh|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`" + done + + pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`" + while [ "_$pids" != "_" ];do + kill -9 $pids 2> /dev/null + pids="`ps aux|grep /usr/sbin/freecwmp|sed 's/^ \+//g'|sed 's/ \+/:/g'|grep -v grep|cut -f1 -d:|tr '\n' ' '`" + done + rm -f /tmp/freecwmp_action.sh }