Permalink
Browse files

Fixed restarting durp

  • Loading branch information...
1 parent 52aaabd commit cb474ddc032d2a55639dd486f632f7b82b2c1d4b @neersighted neersighted committed Apr 2, 2012
Showing with 13 additions and 16 deletions.
  1. +11 −13 cloudbot
  2. +2 −3 plugins/admin.py
View
@@ -15,18 +15,18 @@ 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
fi
}
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,25 +56,23 @@ 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
start() {
$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
}
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
;;
*)
View
@@ -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)

0 comments on commit cb474dd

Please sign in to comment.