From d2c63d926aad9c9e25fd2b3348a1b2f33529b707 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Tue, 28 Sep 2021 18:42:34 -0400 Subject: [PATCH] asdf --- .gitignore | 3 ++- backup.sh | 19 +++++++++------ botcp.sh | 69 ------------------------------------------------------ 3 files changed, 14 insertions(+), 77 deletions(-) mode change 100644 => 100755 backup.sh delete mode 100644 botcp.sh diff --git a/.gitignore b/.gitignore index 23d9952..b323212 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -backups \ No newline at end of file +backups +.dir \ No newline at end of file diff --git a/backup.sh b/backup.sh old mode 100644 new mode 100755 index 2caad89..30ba516 --- a/backup.sh +++ b/backup.sh @@ -35,7 +35,12 @@ # Note: this isn't ideal, this is going to name the # backup according to the time the script is launched # not according to the time the actual backup was initiated -backupdir="$(pwd)/backups" +if [[ -f "./.dir" ]]; then + backupdir=$(cat ./.dir) +else + backupdir="$(pwd)/backups" +fi + timestamp=$(date "+%Y%m%d_%H%M") filename="backup_$timestamp.tar.gz" @@ -46,15 +51,13 @@ echo -e " \e[1m\e[32m[ Skylar's Backup Script ]\e[0m \e[32mThis script is being run from: \e[0m'$(pwd)' - \e[32mBackup Filename: \e[0m'$filename' \e[32mCurrent Backup Location: \e[0m'$backupdir' - \e[32mDirectories to Backup: \e[0m'/var/www', '$HOME' + \e[32mDirectories to Backup: \e[0m '$HOME' \e[34mPlease enter an option from below:\e[0m \e[34m[1] \e[0mCreate a new backup. \e[34m[2] \e[0mList saved backups. - \e[34m[3] \e[0mCheck /tmp for any rogue backups. \e[34m[4] \e[0mChange backup directory. \e[34m[5] \e[0mGenerate a reusable backup script using these settings. @@ -83,8 +86,10 @@ case "$opt" in 1) # Create new backup clear - tar -czf "/tmp/$filename" /var/www $HOME - mv "$filename" "$backupdir" + tar -czvf "/tmp/$filename" $HOME + mv "/tmp/$filename" "$backupdir" + clear + echo "Your backup is complete and can be found at $backupdir/$filename" ;; 2) # List saved backups @@ -99,7 +104,7 @@ case "$opt" in 4) # Change backup directory read -p " New directory: " newdir - backupdir=$newdir + echo $newdir > ./.dir ;; 0) # Exit the script diff --git a/botcp.sh b/botcp.sh deleted file mode 100644 index a7efd57..0000000 --- a/botcp.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/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 \ No newline at end of file