New tests

This commit is contained in:
Skylar Grant 2023-01-12 18:34:58 -05:00
parent 44104f11c1
commit da745e212f
4 changed files with 102 additions and 3 deletions

View File

@ -24,14 +24,18 @@ const main = (gpio) => {
functions.auger.cycle(gpio).then(res => {
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${res}`);
// Recursion ecursion cursion ursion rsion sion ion on n
functions.checkForQuit().then(n => {
main(gpio);
});
}).catch(err => {
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`);
});
} else {
// If the auger is disabled
functions.commands.pause().then(res => {
functions.checkForQuit().then(n => {
main(gpio);
});
}).catch(err => {
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`);
main(gpio);
@ -234,6 +238,19 @@ const functions = {
}
});
},
checkForQuit() {
if (config.status.shutdownNextCycle == 1) process.exit();
return new Promise((resolve, reject) => {
if (fs.existsSync('./quit')) {
fs.unlink('./quit', err => {
if (err) console.log('Error removing the quit file: ' + err);
config.status.shutdownNextCycle = 1;
config.status.auger = 0;
resolve();
});
}
});
},
time(stamp) {
const time = new Date(stamp);
return `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`;

81
hestia.sh Executable file
View File

@ -0,0 +1,81 @@
#!/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)'
Please enter an option from below:
[1] Launch Hestia Web Portal
[2] Quit Hestia Web Portal
[3] View the logs
[0] Quit Control Panel"
# Wait for input
read -p " Option: " opt
# Execute the correct commands based on input.
case "$opt" in
1)
# Launch Hestia Web Portal
clear
echo "Launching Hestia Web Portal"
nohup node websvr.js > log.txt &
;;
2)
# Quit Hestia Web Portal
clear
echo "Quitting Hestia Web Portal Gracefully"
touch quit
;;
3)
# View logs
clear
cat log.txt | less
;;
0)
# Exit the script
clear
echo "Quitting..."
exit
;;
*)
clear
echo "Invalid Option!"
;;
esac
exec ./hestia.sh

0
quit Normal file
View File

View File

@ -7,7 +7,8 @@
"igniterFinished": false,
"shutdown": 0,
"vacuum": 0,
"pof": 0
"pof": 0,
"shutdownNextCycle": 0
},
"timestamps": {
"procStart": 0,