New tests
This commit is contained in:
parent
44104f11c1
commit
da745e212f
21
functions.js
21
functions.js
@ -24,14 +24,18 @@ const main = (gpio) => {
|
|||||||
functions.auger.cycle(gpio).then(res => {
|
functions.auger.cycle(gpio).then(res => {
|
||||||
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${res}`);
|
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: ${res}`);
|
||||||
// Recursion ecursion cursion ursion rsion sion ion on n
|
// Recursion ecursion cursion ursion rsion sion ion on n
|
||||||
main(gpio);
|
functions.checkForQuit().then(n => {
|
||||||
|
main(gpio);
|
||||||
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`);
|
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// If the auger is disabled
|
// If the auger is disabled
|
||||||
functions.commands.pause().then(res => {
|
functions.commands.pause().then(res => {
|
||||||
main(gpio);
|
functions.checkForQuit().then(n => {
|
||||||
|
main(gpio);
|
||||||
|
});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`);
|
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] E: ${err}`);
|
||||||
main(gpio);
|
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) {
|
time(stamp) {
|
||||||
const time = new Date(stamp);
|
const time = new Date(stamp);
|
||||||
return `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`;
|
return `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`;
|
||||||
|
81
hestia.sh
Executable file
81
hestia.sh
Executable 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
|
@ -7,7 +7,8 @@
|
|||||||
"igniterFinished": false,
|
"igniterFinished": false,
|
||||||
"shutdown": 0,
|
"shutdown": 0,
|
||||||
"vacuum": 0,
|
"vacuum": 0,
|
||||||
"pof": 0
|
"pof": 0,
|
||||||
|
"shutdownNextCycle": 0
|
||||||
},
|
},
|
||||||
"timestamps": {
|
"timestamps": {
|
||||||
"procStart": 0,
|
"procStart": 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user