From 65eee69f8e0da4cb1ee050f7fb054f3657d8a999 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sat, 6 Nov 2021 04:00:02 -0500 Subject: [PATCH] Reorder code sections based on usage --- rowbot | 72 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/rowbot b/rowbot index e4948cc..b5b7360 100755 --- a/rowbot +++ b/rowbot @@ -241,39 +241,6 @@ get_option owner "${USER:-uplime}" get_option trigger \` get_option dev yes -### -# bootup/shutdown sequence -### - -on_sys_first_001_bootup() { - log_info "rowbot's pid is %d" "$$" -} - -on_sys_before_999_bootup() { - local setting setting_name - log_debug "storing the config" - - for setting in "${!config[@]}"; do - setting_name=${setting//-/_} - export "CONFIG_${setting_name^^}=${config[$setting]}" - done -} - -on_sys_after_001_bootup() { - log_debug "reloading the config" - local setting setting_name - - while IFS= read -r setting; do - setting_name=${setting#CONFIG_} setting_name=${setting_name//_/-} - config[${setting_name,,}]=${!setting} - unset "$setting" - done < <(compgen -e CONFIG_) -} - -on_sys_exit_999_bootup() { - log_info "There's a lot of beauty in ordinary things. Isn't that kind of the point?" -} - ### # logger ### @@ -284,6 +251,10 @@ log() { fi } +log_trace() { + LOG_LEVEL=trace log "$@" +} + log_debug() { LOG_LEVEL=debug log "$@" } @@ -313,7 +284,7 @@ log_has_level() { } on_sys_init_001_log() { - declare -gA log_levels=( [debug]=1 [info]=2 [warn]=3 [error]=4 ) + declare -gA log_levels=( [debug]=1 [info]=2 [warn]=3 [error]=4 [trace]=5 ) get_option log-level info if ! log_has_level "${config[log-level]}"; then @@ -349,6 +320,39 @@ on_sys_exit_999_log() { fi } +### +# bootup/shutdown sequence +### + +on_sys_first_001_bootup() { + log_info "rowbot's pid is %d" "$$" +} + +on_sys_before_999_bootup() { + local setting setting_name + log_debug "storing the config" + + for setting in "${!config[@]}"; do + setting_name=${setting//-/_} + export "CONFIG_${setting_name^^}=${config[$setting]}" + done +} + +on_sys_after_001_bootup() { + log_debug "reloading the config" + local setting setting_name + + while IFS= read -r setting; do + setting_name=${setting#CONFIG_} setting_name=${setting_name//_/-} + config[${setting_name,,}]=${!setting} + unset "$setting" + done < <(compgen -e CONFIG_) +} + +on_sys_exit_999_bootup() { + log_info "There's a lot of beauty in ordinary things. Isn't that kind of the point?" +} + ### # net code ###