Fixed restarting durp

This commit is contained in:
neersighted 2012-04-02 12:32:42 -07:00
parent 52aaabd877
commit cb474ddc03
2 changed files with 13 additions and 16 deletions

View File

@ -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
;;
*)

View File

@ -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)