backup-script/botcp.sh

69 lines
1.4 KiB
Bash
Raw Normal View History

2021-09-22 01:26:37 +00:00
#!/bin/bash
# UI/Prompt
echo -e "
\e[0mDiscord Bot Control Panel\e[32m
Options:
\e[35m[1] \e[32mStart all bots.
\e[35m[2] \e[32mStop all bots.
\e[35m[3] \e[32mBot 1 Log
\e[35m[4] \e[32mBot 2 Log
\e[35m[5] \e[32mBot 3 Log
\e[35m[6] \e[32mBot 4 Log
\e[35m[0] \e[31mExit \e[32m
Bot 1 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot1/bot.js"`
Bot 2 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot2/bot.js"`
Bot 3 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot3/bot.js"`
Bot 4 PID: \e[0m`pgrep -f "[n]ode /home/ubuntu/bot4/bot.js"`"
# Bot PIDs
bbotPID=`pgrep -f "[n]ode /home/ubuntu/bot1/bot.js"`
vbotPID=`pgrep -f "[n]ode /home/ubuntu/bot2/bot.js"`
sbotPID=`pgrep -f "[n]ode /home/ubuntu/bot3/bot.js"`
abotPID=`pgrep -f "[n]ode /home/ubuntu/bot4/bot.js"`
# Wait for input
read -p " Option: " opt
# Execute commands based on input.
case "$opt" in
1)
echo " Starting all bots..."
node /home/ubuntu/bot1/bot.js &>> /home/ubuntu/logs/bot1.log &
node /home/ubuntu/bot2/bot.js &>> /home/ubuntu/logs/bot2.log &
node /home/ubuntu/bot3/bot.js &>> /home/ubuntu/logs/bot3.log &
node /home/ubuntu/bot4/bot.js &>> /home/ubuntu/logs/bot4.log &
sleep 0.4s
clear
;;
2)
echo " Stopping all bots..."
kill -9 $bbotPID
kill -9 $vbotPID
kill -9 $sbotPID
kill -9 $abotPID
sleep 0.4s
clear
;;
3)
;;
4)
;;
5)
;;
6)
;;
0)
echo " Quitting this script..."
sleep 0.4s
clear
exit
;;
*)
clear
;;
esac
exec ./botcp