2023-01-12 23:34:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#####################################################
|
|
|
|
# Interactive script for managing Hestia Web Portal #
|
|
|
|
#####################################################
|
|
|
|
# Formatting Tips:
|
|
|
|
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
|
|
|
#
|
|
|
|
# Formatting:
|
|
|
|
# \e[1m - Bold
|
|
|
|
# \e[2m - Dim
|
|
|
|
# \e[8m - Hidden (passwords)
|
|
|
|
#
|
|
|
|
# Reset:
|
|
|
|
# \e[0m - Reset All Attributes
|
|
|
|
# \e[21m - Reset Bold/Bright
|
|
|
|
# \e[22m - Reset Dim
|
|
|
|
# \e[28m - Reset Hidden
|
|
|
|
#
|
|
|
|
# Colors:
|
|
|
|
# \e[39m - Default Foreground Color
|
|
|
|
# \e[30m - Black
|
|
|
|
# \e[31m - Red
|
|
|
|
# \e[32m - Green
|
|
|
|
# \e[34m - Blue
|
|
|
|
#####################################################
|
|
|
|
|
|
|
|
# Some initial variables to work with
|
|
|
|
timestamp=$(date "+%Y%m%d_%H%M")
|
|
|
|
filename="backup_$timestamp.tar.gz"
|
|
|
|
|
|
|
|
# Initial Prompt
|
|
|
|
# Bash allows for linebreaks in string literals and will
|
|
|
|
# break lines accordingly in the shell
|
|
|
|
echo -e "
|
|
|
|
[ Hestia Control Panel ]
|
|
|
|
|
|
|
|
This script is being run from: '$(pwd)'
|
2023-01-23 03:50:09 +00:00
|
|
|
Active Nodes: $(ps ax -o pid,user,command | grep 'node main.js' | grep -v grep)
|
2023-01-12 23:34:58 +00:00
|
|
|
|
|
|
|
Please enter an option from below:
|
|
|
|
|
|
|
|
[1] Launch Hestia Web Portal
|
|
|
|
[2] Quit Hestia Web Portal
|
|
|
|
[3] View the logs
|
2023-01-23 03:43:31 +00:00
|
|
|
[4] Update Hestia
|
2023-01-23 03:52:05 +00:00
|
|
|
[5] Set up database
|
2023-01-12 23:34:58 +00:00
|
|
|
|
|
|
|
[0] Quit Control Panel"
|
|
|
|
|
|
|
|
# Wait for input
|
2023-01-13 00:51:41 +00:00
|
|
|
read -p "Option: " opt
|
2023-01-12 23:34:58 +00:00
|
|
|
|
|
|
|
# Execute the correct commands based on input.
|
|
|
|
case "$opt" in
|
|
|
|
1)
|
|
|
|
# Launch Hestia Web Portal
|
|
|
|
clear
|
|
|
|
echo "Launching Hestia Web Portal"
|
2023-01-22 16:27:58 +00:00
|
|
|
nohup node main.js > log.txt &
|
2023-01-12 23:34:58 +00:00
|
|
|
;;
|
|
|
|
2)
|
|
|
|
# Quit Hestia Web Portal
|
|
|
|
clear
|
|
|
|
echo "Quitting Hestia Web Portal Gracefully"
|
|
|
|
touch quit
|
|
|
|
;;
|
|
|
|
3)
|
|
|
|
# View logs
|
|
|
|
clear
|
2023-01-23 03:48:26 +00:00
|
|
|
tail -f log.txt
|
2023-01-12 23:34:58 +00:00
|
|
|
;;
|
2023-01-23 03:43:31 +00:00
|
|
|
4)
|
|
|
|
# Update Hestia
|
2023-01-23 03:46:14 +00:00
|
|
|
rm data/config.db
|
2023-01-23 03:43:31 +00:00
|
|
|
git pull && ./hestia.sh
|
|
|
|
;;
|
2023-01-23 03:52:05 +00:00
|
|
|
5)
|
|
|
|
# Set up database
|
|
|
|
node modules/_setupdb.js
|
|
|
|
;;
|
2023-01-12 23:34:58 +00:00
|
|
|
0)
|
|
|
|
# Exit the script
|
|
|
|
clear
|
|
|
|
echo "Quitting..."
|
|
|
|
exit
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
clear
|
|
|
|
echo "Invalid Option!"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exec ./hestia.sh
|