From cb474ddc032d2a55639dd486f632f7b82b2c1d4b Mon Sep 17 00:00:00 2001 From: neersighted Date: Mon, 2 Apr 2012 12:32:42 -0700 Subject: [PATCH] Fixed restarting durp --- cloudbot | 24 +++++++++++------------- plugins/admin.py | 5 ++--- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/cloudbot b/cloudbot index d6fbc09..877c4ea 100755 --- a/cloudbot +++ b/cloudbot @@ -15,7 +15,7 @@ locatefiles() { } running() { - if [[ $(ps aux|grep bot.py|grep -v grep|grep -v daemon|grep -v screen) != "" ]]; then + if [[ $(ps aux|grep bot.py|grep -v grep|grep -v daemon|grep -v SCREEN) != "" ]]; then true else false @@ -23,10 +23,10 @@ running() { } checkbackend() { - if dpkg -l| grep ^ii|grep screen|grep 'terminal multi' > /dev/null; then - backend="screen" - elif dpkg -l| grep ^ii|grep daemon|grep 'turns other' > /dev/null; then + if dpkg -l| grep ^ii|grep daemon|grep 'turns other' > /dev/null; then backend="daemon" + elif dpkg -l| grep ^ii|grep screen|grep 'terminal multi' > /dev/null; then + backend="screen" else backend="manual" fi @@ -56,8 +56,7 @@ setcommands() { screen -d -m -S cloudbot -t cloudbot python $botfile > $logfile 2>&1 } stop() { - proc=`ps ax|grep -v grep|grep screen|grep $botfile` - pid=`top -n 1 -p ${proc:0:5} | grep ${proc:0:5}` + pid=`ps ax|grep -v grep|grep python|grep -v SCREEN|grep $botfile|awk '{print $1}'` kill $pid } elif [ "$backend" == "manual" ]; then @@ -65,8 +64,7 @@ setcommands() { $botfile } stop() { - proc=`ps ax|grep -v grep|grep python|grep $botfile` - pid=`top -n 1 -p ${proc:0:5} | grep ${proc:0:5}` + pid=`ps ax|grep -v grep|grep python|grep $botfile|awk '{print $1}'` kill $pid } fi @@ -74,7 +72,7 @@ setcommands() { processargs() { case $1 in - start) + start|-start|--start) if running; then echo "Cannot start! Bot is already running!" exit 1 @@ -83,7 +81,7 @@ processargs() { start fi ;; - stop) + stop|-stop|--stop) if running; then echo "Stopping CloudBot... ($backend)" stop @@ -92,7 +90,7 @@ processargs() { exit 1 fi ;; - restart) + restart|-restart|--restart) if running; then echo "Restarting CloudBot... ($backend)" stop @@ -103,11 +101,11 @@ processargs() { exit 1 fi ;; - clear) + clear|-clear|--clear) echo "Clearing logs..." clear ;; - status) + status|-status|--status) status ;; *) diff --git a/plugins/admin.py b/plugins/admin.py index 8582602..73dd9cc 100755 --- a/plugins/admin.py +++ b/plugins/admin.py @@ -64,8 +64,7 @@ def stop(inp, nick=None, conn=None): else: conn.cmd("QUIT", ["Killed by %s." % nick]) time.sleep(5) - os.execl("./cloudbot", "stop") - + os.execl("./cloudbot", "cloudbot", "stop") @hook.command(autohelp=False, adminonly=True) def restart(inp, nick=None, conn=None): @@ -75,7 +74,7 @@ def restart(inp, nick=None, conn=None): else: conn.cmd("QUIT", ["Restarted by %s." % nick]) time.sleep(5) - os.execl("./cloudbot", "restart") + os.execl("./cloudbot", "cloudbot", "restart") @hook.command(autohelp=False, adminonly=True)