Add debug mode 2

Restores functionality of running script as a non-root user for testing purposes.
Resolves issue #88
This commit is contained in:
Sam Ess
2021-10-16 18:46:36 -04:00
parent cbb1e08e26
commit b6bc0b1269
3 changed files with 29 additions and 29 deletions

View File

@@ -4,7 +4,7 @@ cleanupAndExit() { # $1 = exit code, $2 message
if [[ -n $2 && $1 -ne 0 ]]; then
printlog "ERROR: $2"
fi
if [ "$DEBUG" -eq 0 ]; then
if [ "$DEBUG" -ne 1 ]; then
# remove the temporary working directory when done
printlog "Deleting $tmpDir"
rm -Rf "$tmpDir"
@@ -192,9 +192,9 @@ getAppVersion() {
}
checkRunningProcesses() {
# don't check in DEBUG mode
if [[ $DEBUG -ne 0 ]]; then
printlog "DEBUG mode, not checking for blocking processes"
# don't check in DEBUG mode 1
if [[ $DEBUG -eq 1 ]]; then
printlog "DEBUG mode 1, not checking for blocking processes"
return
fi
@@ -299,9 +299,9 @@ reopenClosedProcess() {
return
fi
# don't reopen in DEBUG mode
if [[ $DEBUG -ne 0 ]]; then
printlog "DEBUG mode, not reopening anything"
# don't reopen in DEBUG mode 1
if [[ $DEBUG -eq 1 ]]; then
printlog "DEBUG mode 1, not reopening anything"
return
fi
@@ -358,16 +358,15 @@ installAppWithPath() { # $1: path to app to install in $targetDir
printlog "Downloaded version of $name is $appNewVersion (replacing version $appversion)."
fi
# skip install for DEBUG
if [ "$DEBUG" -ne 0 ]; then
printlog "DEBUG enabled, skipping remove, copy and chown steps"
# skip install for DEBUG 1
if [ "$DEBUG" -eq 1 ]; then
printlog "DEBUG mode 1 enabled, skipping remove, copy and chown steps"
return 0
fi
# check for root
if [ "$(whoami)" != "root" ]; then
# not running as root
cleanupAndExit 6 "not running as root, exiting"
# skip install for DEBUG 2
if [ "$DEBUG" -eq 2 ]; then
cleanupAndExit 0 "DEBUG mode 2 enabled, exiting"
fi
# remove existing application
@@ -462,16 +461,15 @@ installFromPKG() {
fi
fi
# skip install for DEBUG
if [ "$DEBUG" -ne 0 ]; then
# skip install for DEBUG 1
if [ "$DEBUG" -eq 1 ]; then
printlog "DEBUG enabled, skipping installation"
return 0
fi
# check for root
if [ "$(whoami)" != "root" ]; then
# not running as root
cleanupAndExit 6 "not running as root, exiting"
# skip install for DEBUG 2
if [ "$DEBUG" -eq 2 ]; then
cleanupAndExit 0 "DEBUG 2 enabled, exiting"
fi
# install pkg