bugs :D
This commit is contained in:
parent
9b80da1323
commit
543eab562e
1 changed files with 12 additions and 13 deletions
25
cloudbot
25
cloudbot
|
@ -24,8 +24,7 @@ usage = "usage: ./cloudbot {start|stop|restart|status}"
|
||||||
quit = "Goodbye! Thanks for using CloudBot!"
|
quit = "Goodbye! Thanks for using CloudBot!"
|
||||||
|
|
||||||
pwd = os.getcwd()
|
pwd = os.getcwd()
|
||||||
clearlog1 = ": > ./bot.log && "
|
clearlog = ": > ./bot.log"
|
||||||
clearlog2 = ": > ./bot.log"
|
|
||||||
|
|
||||||
daemoncheck = subprocess.check_output("locate /usr/bin/daemon", shell=True)
|
daemoncheck = subprocess.check_output("locate /usr/bin/daemon", shell=True)
|
||||||
daemon = re.match(r'^/usr/bin/daemon$', daemoncheck)
|
daemon = re.match(r'^/usr/bin/daemon$', daemoncheck)
|
||||||
|
@ -59,16 +58,16 @@ pid = "echo 'Cannot get pid'"
|
||||||
|
|
||||||
if daemon:
|
if daemon:
|
||||||
if backend == "daemon":
|
if backend == "daemon":
|
||||||
start = "daemon -n cloudbot -O " + pwd + \
|
start = "daemon -r -n cloudbot -O " + pwd + \
|
||||||
"/bot.log python " + pwd + "/bot.py"
|
"/bot.log python " + pwd + "/bot.py"
|
||||||
stop = clearlog1 + "daemon -n cloudbot --stop"
|
stop = "daemon -n cloudbot --stop"
|
||||||
restart = clearlog1 + "daemon -n cloudbot --restart"
|
restart = "daemon -n cloudbot --restart"
|
||||||
pid = "pidof /usr/bin/daemon"
|
pid = "pidof /usr/bin/daemon"
|
||||||
elif backend == "screen":
|
elif backend == "screen":
|
||||||
start = "screen -S cloudbot -dm python" + pwd +\
|
start = "screen -S cloudbot -dm python" + pwd +\
|
||||||
"/bot.py >>" + pwd + "/bot.log 2>&1"
|
"/bot.py >>" + pwd + "/bot.log 2>&1"
|
||||||
stop = clearlog1 + "kill `pidof /usr/bin/screen`"
|
stop = "kill `pidof /usr/bin/screen`"
|
||||||
restart = clearlog1 + "daemon -n cloudbot --restart"
|
restart = stop + " && " + start
|
||||||
pid = "pidof /usr/bin/screen"
|
pid = "pidof /usr/bin/screen"
|
||||||
elif backend == False:
|
elif backend == False:
|
||||||
print "Welcome to your first run of: "
|
print "Welcome to your first run of: "
|
||||||
|
@ -76,10 +75,10 @@ if daemon:
|
||||||
print error5
|
print error5
|
||||||
elif screen:
|
elif screen:
|
||||||
if backend == "daemon":
|
if backend == "daemon":
|
||||||
start = "daemon -n cloudbot -O " + pwd + \
|
start = "daemon -r -n cloudbot -O " + pwd + \
|
||||||
"/bot.log -r python " + pwd + "/bot.py"
|
"/bot.log python " + pwd + "/bot.py"
|
||||||
stop = clearlog1 + "daemon -n cloudbot --stop"
|
stop = "daemon -n cloudbot --stop"
|
||||||
restart = stop + " && " + start
|
restart = "daemon -n cloudbot --restart"
|
||||||
pid = "pidof /usr/bin/daemon"
|
pid = "pidof /usr/bin/daemon"
|
||||||
elif backend == "screen":
|
elif backend == "screen":
|
||||||
start = "screen -S cloudbot -dm python" + pwd +\
|
start = "screen -S cloudbot -dm python" + pwd +\
|
||||||
|
@ -123,7 +122,7 @@ try:
|
||||||
command = pid
|
command = pid
|
||||||
print green + "Bot is running! " + nocol
|
print green + "Bot is running! " + nocol
|
||||||
elif (sys.argv[1] == 'clear'):
|
elif (sys.argv[1] == 'clear'):
|
||||||
command = clearlog2
|
command = clearlog
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command
|
||||||
print usage
|
print usage
|
||||||
|
@ -158,7 +157,7 @@ try:
|
||||||
elif (sys.argv[1] == 'status'):
|
elif (sys.argv[1] == 'status'):
|
||||||
print red + "Bot is not running!" + nocol
|
print red + "Bot is not running!" + nocol
|
||||||
elif (sys.argv[1] == 'clear'):
|
elif (sys.argv[1] == 'clear'):
|
||||||
command = clearlog2
|
command = clearlog
|
||||||
else:
|
else:
|
||||||
command = command
|
command = command
|
||||||
print usage
|
print usage
|
||||||
|
|
Reference in a new issue