Reorder code sections based on usage

This commit is contained in:
Nick Chambers 2021-11-06 04:00:02 -05:00
parent 52697be100
commit 65eee69f8e
1 changed files with 38 additions and 34 deletions

72
rowbot
View File

@ -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
###