Fixed bug with debugging mode

Script now takes flag '--mode=' appended with a mode.
    - only current mode is 'debug'. Use this to enter debug run mode.
    - script now outputs the session log is mode is in debug.
This commit is contained in:
Ethan Smith-Coss 2021-06-21 18:31:52 +01:00
parent 39b0b06a8c
commit 8f21f3903d

14
updater
View File

@ -18,7 +18,7 @@
# Author: Ethan Smith-Coss # # Author: Ethan Smith-Coss #
# Version: 0.1.4 # # Version: 0.1.4 #
# Created: 2021-05-20T16:47+0100 # # Created: 2021-05-20T16:47+0100 #
# Last Modified: 2021-06-21T14:29+0100 # # Last Modified: 2021-06-21T18:23+0100 #
# # # #
# #################################### # # #################################### #
# # # #
@ -73,8 +73,6 @@ function clean_up {
log "DEBUG" "EXIT signal was raised, cleaning up system after session before exiting..." "$log_file" log "DEBUG" "EXIT signal was raised, cleaning up system after session before exiting..." "$log_file"
printf "Cleaning up system after session..." printf "Cleaning up system after session..."
cp "$log_file" "$logs_dir/updater.log" # && rm "$log_file" cp "$log_file" "$logs_dir/updater.log" # && rm "$log_file"
# [[ -d "$tmp_path/opt" ]] && rm -r "$tmp_path/opt"
# [[ -d "$tmp_path/usr" ]] && rm -r "$tmp_path/usr"
while read -r garbage_collection ; do while read -r garbage_collection ; do
[[ -f "$garbage_collection" || -d "$garbage_collection" ]] && rm -r "$garbage_collection" [[ -f "$garbage_collection" || -d "$garbage_collection" ]] && rm -r "$garbage_collection"
@ -92,7 +90,7 @@ function clean_up {
echo >> "$runtime_dir/logs/updater.log" echo >> "$runtime_dir/logs/updater.log"
cat "$logs_dir/updater.log" >> "$logs_dir/updater.history" cat "$logs_dir/updater.log" >> "$logs_dir/updater.history"
[[ -e $test_run ]] && cat "$logs_dir/updater.log" [[ $debug_run -eq 0 ]] && cat "$logs_dir/updater.log"
} }
function check_restoration { function check_restoration {
@ -123,8 +121,9 @@ while test $# -gt 0 ; do
-nn | --no-notify) -nn | --no-notify)
nn_flag=0 ; shift nn_flag=0 ; shift
;; ;;
--dev-test) --mode=*)
test_run=0 ; shift [[ "$1" == "--mode=debug" ]] && debug_run=0
shift
;; ;;
*) *)
shift shift
@ -148,6 +147,9 @@ log "DEBUG" "The yes flag has been set to: $yes_flag." "$log_file"
## setup the no-notify (nn) flag if notify-send isn't installed ## setup the no-notify (nn) flag if notify-send isn't installed
command -v notify-send >/dev/null 2>&1 || nn_flag=0 command -v notify-send >/dev/null 2>&1 || nn_flag=0
nn_flag=${nn_flag:-1} nn_flag=${nn_flag:-1}
## set the testing flag if not already
debug_run=${debug_run:-1}
[[ $debug_run -eq 0 ]] && log "DEBUG" "The mode flag has been set so script will operate in debug mode." "$log_file"
## check if Microsoft Edge (Beta) is already installed ## check if Microsoft Edge (Beta) is already installed
command -v microsoft-edge-beta &>/dev/null command -v microsoft-edge-beta &>/dev/null