Fixed restarting durp
This commit is contained in:
parent
52aaabd877
commit
cb474ddc03
2 changed files with 13 additions and 16 deletions
24
cloudbot
24
cloudbot
|
@ -15,7 +15,7 @@ locatefiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
running() {
|
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
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
@ -23,10 +23,10 @@ running() {
|
||||||
}
|
}
|
||||||
|
|
||||||
checkbackend() {
|
checkbackend() {
|
||||||
if dpkg -l| grep ^ii|grep screen|grep 'terminal multi' > /dev/null; then
|
if dpkg -l| grep ^ii|grep daemon|grep 'turns other' > /dev/null; then
|
||||||
backend="screen"
|
|
||||||
elif dpkg -l| grep ^ii|grep daemon|grep 'turns other' > /dev/null; then
|
|
||||||
backend="daemon"
|
backend="daemon"
|
||||||
|
elif dpkg -l| grep ^ii|grep screen|grep 'terminal multi' > /dev/null; then
|
||||||
|
backend="screen"
|
||||||
else
|
else
|
||||||
backend="manual"
|
backend="manual"
|
||||||
fi
|
fi
|
||||||
|
@ -56,8 +56,7 @@ setcommands() {
|
||||||
screen -d -m -S cloudbot -t cloudbot python $botfile > $logfile 2>&1
|
screen -d -m -S cloudbot -t cloudbot python $botfile > $logfile 2>&1
|
||||||
}
|
}
|
||||||
stop() {
|
stop() {
|
||||||
proc=`ps ax|grep -v grep|grep screen|grep $botfile`
|
pid=`ps ax|grep -v grep|grep python|grep -v SCREEN|grep $botfile|awk '{print $1}'`
|
||||||
pid=`top -n 1 -p ${proc:0:5} | grep ${proc:0:5}`
|
|
||||||
kill $pid
|
kill $pid
|
||||||
}
|
}
|
||||||
elif [ "$backend" == "manual" ]; then
|
elif [ "$backend" == "manual" ]; then
|
||||||
|
@ -65,8 +64,7 @@ setcommands() {
|
||||||
$botfile
|
$botfile
|
||||||
}
|
}
|
||||||
stop() {
|
stop() {
|
||||||
proc=`ps ax|grep -v grep|grep python|grep $botfile`
|
pid=`ps ax|grep -v grep|grep python|grep $botfile|awk '{print $1}'`
|
||||||
pid=`top -n 1 -p ${proc:0:5} | grep ${proc:0:5}`
|
|
||||||
kill $pid
|
kill $pid
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
@ -74,7 +72,7 @@ setcommands() {
|
||||||
|
|
||||||
processargs() {
|
processargs() {
|
||||||
case $1 in
|
case $1 in
|
||||||
start)
|
start|-start|--start)
|
||||||
if running; then
|
if running; then
|
||||||
echo "Cannot start! Bot is already running!"
|
echo "Cannot start! Bot is already running!"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -83,7 +81,7 @@ processargs() {
|
||||||
start
|
start
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
stop)
|
stop|-stop|--stop)
|
||||||
if running; then
|
if running; then
|
||||||
echo "Stopping CloudBot... ($backend)"
|
echo "Stopping CloudBot... ($backend)"
|
||||||
stop
|
stop
|
||||||
|
@ -92,7 +90,7 @@ processargs() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
restart)
|
restart|-restart|--restart)
|
||||||
if running; then
|
if running; then
|
||||||
echo "Restarting CloudBot... ($backend)"
|
echo "Restarting CloudBot... ($backend)"
|
||||||
stop
|
stop
|
||||||
|
@ -103,11 +101,11 @@ processargs() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
clear)
|
clear|-clear|--clear)
|
||||||
echo "Clearing logs..."
|
echo "Clearing logs..."
|
||||||
clear
|
clear
|
||||||
;;
|
;;
|
||||||
status)
|
status|-status|--status)
|
||||||
status
|
status
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -64,8 +64,7 @@ def stop(inp, nick=None, conn=None):
|
||||||
else:
|
else:
|
||||||
conn.cmd("QUIT", ["Killed by %s." % nick])
|
conn.cmd("QUIT", ["Killed by %s." % nick])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
os.execl("./cloudbot", "stop")
|
os.execl("./cloudbot", "cloudbot", "stop")
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False, adminonly=True)
|
@hook.command(autohelp=False, adminonly=True)
|
||||||
def restart(inp, nick=None, conn=None):
|
def restart(inp, nick=None, conn=None):
|
||||||
|
@ -75,7 +74,7 @@ def restart(inp, nick=None, conn=None):
|
||||||
else:
|
else:
|
||||||
conn.cmd("QUIT", ["Restarted by %s." % nick])
|
conn.cmd("QUIT", ["Restarted by %s." % nick])
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
os.execl("./cloudbot", "restart")
|
os.execl("./cloudbot", "cloudbot", "restart")
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False, adminonly=True)
|
@hook.command(autohelp=False, adminonly=True)
|
||||||
|
|
Reference in a new issue