From 0b6e2b7447dcdb61564bdd54f7ed1c0ba65e671e Mon Sep 17 00:00:00 2001 From: Tearran Date: Wed, 18 Dec 2024 04:48:13 +0000 Subject: [PATCH 01/10] start remove sanitize_input --- bin/armbian-config | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/armbian-config b/bin/armbian-config index 30590e663..0a056b94a 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -96,6 +96,12 @@ case "$1" in exit 0 ;; "--api") + shift + # stage for seperation + [[ -z "$@" ]] && generate_json_options ; + exit 0 + ;; +"--noint") shift if [[ -z "$1" || "$1" == "help" ]]; then see_use @@ -103,7 +109,7 @@ case "$1" in fi option="$1" shift - args=$(sanitize_input "$@") + args="$@" # echo -e "\"$option\" \"$args\"" "$option" "$args" exit 0 From b89d82bd63e391df5f4f270628c136c1af0eb4e7 Mon Sep 17 00:00:00 2001 From: Tearran Date: Wed, 18 Dec 2024 05:32:14 +0000 Subject: [PATCH 02/10] fi shell check --- bin/armbian-config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/armbian-config b/bin/armbian-config index 0a056b94a..dfdf462a2 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -98,7 +98,8 @@ case "$1" in "--api") shift # stage for seperation - [[ -z "$@" ]] && generate_json_options ; + args="$@" + [[ -z "$args" ]] && generate_json_options ; exit 0 ;; "--noint") From 292a5878c6d7f1c9246bee72aeef9700463e23d1 Mon Sep 17 00:00:00 2001 From: Tearran Date: Wed, 18 Dec 2024 07:20:40 +0000 Subject: [PATCH 03/10] moved sourcing rutime --- bin/armbian-config | 51 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/bin/armbian-config b/bin/armbian-config index dfdf462a2..d6aac0f33 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -14,7 +14,7 @@ trap "exit" INT TERM script_dir="$(dirname "$0")" [[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools" -[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 +[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 # 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. [[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" @@ -36,10 +36,11 @@ declare -A module_options # Load configng core functions and module options array source "$lib_dir/config.functions.sh" +# TODO move to runtime file set_runtime_variables check_distro_status echo "Loaded Runtime variables..." #| show_infobox ; -#set_newt_colors 2 +# TODO echo "Loaded Dialog..." #| show_infobox ; source "$lib_dir/config.docs.sh" echo "Loaded Docs..." #| show_infobox ; @@ -52,8 +53,7 @@ echo "Loaded Software helpers..." #| show_infobox ; # # Loads the variables from beta armbian-config for runtime handling -source "$lib_dir/config.runtime.sh" -echo "Loaded Runtime conditions..." #| show_infobox ; + clear @@ -70,20 +70,25 @@ case "$1" in --help [category] Use [category] to filter specific menu options. --cmd [option] Run a command from the menu (simple) --api [option] Run a helper command (advanced) - --doc Generate the README.md file + --doc Generate the README.md file Examples: armbian-config --help [cmd||System||Software||Network||Localisation] - armbian-config --cmd help + armbian-config --cmd help armbian-config --api help " exit 0 ;; "--doc") + # TODO: move --doc to --api generate_readme exit 0 ;; "--cmd") + # TODO move source for related groups + # to respective case switch + # Interface group not sepeated and mixed in functions and docs etc.. + # TODO Sort and group interface for source file INPUTMODE="cmd" shift if [[ -z "$1" || "$1" == "help" ]]; then @@ -91,28 +96,39 @@ case "$1" in exit 0 fi - args=$(sanitize_input "$@") + args="$@" execute_command "$args" exit 0 ;; "--api") + # move source for related groups + # to respective case switch + # source "$lib_dir/config.docs.sh" + # TODO remove interface spacifice function from docs into there own group files. + shift + option="$1" + [[ "$option" == "json" ]] && generate_json_options && exit 0 ; + [[ "$option" == "docs" ]] && generate_readme && exit 0 ; + if [[ -z "$option" || "$option" == "help" ]] ; then + echo "Options:" + echo " json - database in json format" + echo " docs - generate DOCUMEMT.md" + echo "" + exit 0 ; + fi shift - # stage for seperation args="$@" - [[ -z "$args" ]] && generate_json_options ; + # echo -e "\"$option\" \"$args\"" + "$option" "$args" exit 0 ;; "--noint") shift - if [[ -z "$1" || "$1" == "help" ]]; then - see_use - exit 0 - fi option="$1" + [[ "$option" == "help" ]] && see_use ; exit 0 ; shift args="$@" - # echo -e "\"$option\" \"$args\"" - "$option" "$args" + "$option" "$args" <&- exit 0 ;; "main=help" | "main=Help") @@ -163,6 +179,11 @@ case "$1" in ;; esac +clear +echo "Almost there ..." #| show_infobox ; +echo "Checking Runtime conditions..." #| show_infobox ; +source "$lib_dir/config.runtime.sh" +echo "Loaded Runtime conditions..." #| show_infobox ; # # Generate the top menu with the modified Object data From 3fee98ab67500320578821c0fb682f70eb03ac24 Mon Sep 17 00:00:00 2001 From: Tearran Date: Wed, 18 Dec 2024 07:43:18 +0000 Subject: [PATCH 04/10] fix gabage when piping --api to file --- bin/armbian-config | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/bin/armbian-config b/bin/armbian-config index d6aac0f33..fb1442531 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -1,6 +1,6 @@ #!/bin/bash -tput init +[[ -t 1 ]] && tput init # # Language-based variable assignment for script directory path # This serves as a Rosetta Stone for developers, @@ -38,25 +38,22 @@ declare -A module_options source "$lib_dir/config.functions.sh" # TODO move to runtime file set_runtime_variables -check_distro_status -echo "Loaded Runtime variables..." #| show_infobox ; +#check_distro_status +#echo "Loaded Runtime variables..." #| show_infobox ; # TODO -echo "Loaded Dialog..." #| show_infobox ; +[[ -t 1 ]] && echo "Loaded Dialog..." #| show_infobox ; source "$lib_dir/config.docs.sh" -echo "Loaded Docs..." #| show_infobox ; +#echo "Loaded Docs..." #| show_infobox ; source "$lib_dir/config.system.sh" -echo "Loaded System helpers..." #| show_infobox ; +#echo "Loaded System helpers..." #| show_infobox ; source "$lib_dir/config.network.sh" -echo "Loaded Network helpers..." #| show_infobox ; +#echo "Loaded Network helpers..." #| show_infobox ; source "$lib_dir/config.software.sh" -echo "Loaded Software helpers..." #| show_infobox ; +#echo "Loaded Software helpers..." #| show_infobox ; # # Loads the variables from beta armbian-config for runtime handling - -clear - case "$1" in "--help") if [[ -n "$2" ]]; then From 3d2f19e8a6de95902d7f251009419f57461f543d Mon Sep 17 00:00:00 2001 From: Tearran Date: Wed, 18 Dec 2024 07:52:54 +0000 Subject: [PATCH 05/10] cleaned --api can now be cleanly piped to a file --- bin/armbian-config | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/armbian-config b/bin/armbian-config index fb1442531..b04dc1433 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -43,13 +43,13 @@ set_runtime_variables # TODO [[ -t 1 ]] && echo "Loaded Dialog..." #| show_infobox ; source "$lib_dir/config.docs.sh" -#echo "Loaded Docs..." #| show_infobox ; +[[ -t 1 ]] && echo "Loaded Docs..." #| show_infobox ; source "$lib_dir/config.system.sh" -#echo "Loaded System helpers..." #| show_infobox ; +[[ -t 1 ]] && echo "Loaded System helpers..." #| show_infobox ; source "$lib_dir/config.network.sh" -#echo "Loaded Network helpers..." #| show_infobox ; +[[ -t 1 ]] && echo "Loaded Network helpers..." #| show_infobox ; source "$lib_dir/config.software.sh" -#echo "Loaded Software helpers..." #| show_infobox ; +[[ -t 1 ]] && echo "Loaded Software helpers..." #| show_infobox ; # # Loads the variables from beta armbian-config for runtime handling @@ -104,7 +104,7 @@ case "$1" in # TODO remove interface spacifice function from docs into there own group files. shift option="$1" - [[ "$option" == "json" ]] && generate_json_options && exit 0 ; + [[ "$option" == "json" ]] && generate_json_options | jq --tab '.' && exit 0 ; [[ "$option" == "docs" ]] && generate_readme && exit 0 ; if [[ -z "$option" || "$option" == "help" ]] ; then echo "Options:" From 63fdf638cb78a639d8d37c9f386b8d70c0d20b77 Mon Sep 17 00:00:00 2001 From: Tearran Date: Fri, 27 Dec 2024 03:52:22 +0000 Subject: [PATCH 06/10] cp armbian-config to armbian-config-dev --- tools/armbian-config-dev | 172 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100755 tools/armbian-config-dev diff --git a/tools/armbian-config-dev b/tools/armbian-config-dev new file mode 100755 index 000000000..30590e663 --- /dev/null +++ b/tools/armbian-config-dev @@ -0,0 +1,172 @@ +#!/bin/bash + +tput init +# +# Language-based variable assignment for script directory path +# This serves as a Rosetta Stone for developers, +# allowing them to use the variable name they are most comfortable with. + +# allows CTRL c to exit +trap "exit" INT TERM +[[ $EUID != 0 ]] && exec sudo "$0" "$@" +# +# Get the script directory +script_dir="$(dirname "$0")" + +[[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools" +[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 + +# 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. +[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" + +# Define the lib directory one level up from the script directory +lib_dir="$script_dir/../lib/armbian-config" +doc_dir="$script_dir/../share/doc/armbian-config" +json_file="$lib_dir/config.jobs.json" + +# +# Load The Bash procedure Objects +json_data=$(<"$json_file") + +# +# Prepare the module options array +declare -A module_options + +# +# Load configng core functions and module options array + +source "$lib_dir/config.functions.sh" +set_runtime_variables +check_distro_status +echo "Loaded Runtime variables..." #| show_infobox ; +#set_newt_colors 2 +echo "Loaded Dialog..." #| show_infobox ; +source "$lib_dir/config.docs.sh" +echo "Loaded Docs..." #| show_infobox ; +source "$lib_dir/config.system.sh" +echo "Loaded System helpers..." #| show_infobox ; +source "$lib_dir/config.network.sh" +echo "Loaded Network helpers..." #| show_infobox ; +source "$lib_dir/config.software.sh" +echo "Loaded Software helpers..." #| show_infobox ; +# +# Loads the variables from beta armbian-config for runtime handling + +source "$lib_dir/config.runtime.sh" +echo "Loaded Runtime conditions..." #| show_infobox ; + +clear + +case "$1" in +"--help") + if [[ -n "$2" ]]; then + see_cmd_list "$2" + echo "" + exit 0 + fi + + echo "Usage: armbian-config --[option] + Options: + --help [category] Use [category] to filter specific menu options. + --cmd [option] Run a command from the menu (simple) + --api [option] Run a helper command (advanced) + --doc Generate the README.md file + + Examples: + armbian-config --help [cmd||System||Software||Network||Localisation] + armbian-config --cmd help + armbian-config --api help +" + exit 0 + ;; +"--doc") + generate_readme + exit 0 + ;; +"--cmd") + INPUTMODE="cmd" + shift + if [[ -z "$1" || "$1" == "help" ]]; then + see_cmd_list + exit 0 + fi + + args=$(sanitize_input "$@") + execute_command "$args" + exit 0 + ;; +"--api") + shift + if [[ -z "$1" || "$1" == "help" ]]; then + see_use + exit 0 + fi + option="$1" + shift + args=$(sanitize_input "$@") + # echo -e "\"$option\" \"$args\"" + "$option" "$args" + exit 0 + ;; +"main=help" | "main=Help") + see_cli_legacy + echo "" + exit 0 + ;; +"main="*) + declare -A main_map + main_map=( + # map name to menu category + ["System"]="S" + ["Software"]="I" + ["Network"]="N" + ["Localisation"]="L" + ) + main_value="${1#main=}" + main_value="${main_map[$main_value]}" + + if [ -z "$main_value" ]; then + echo "Error: Invalid List $1" + exit 1 + fi + declare -A select_map + # map name to menu number + select_map=( + ["Headers"]="04" + ["Headers_install"]="04" + ["Headers_remove"]="05" + ["Firmware"]="06" + ["Nightly"]="07" + ) + select_value="${2#selection=}" + select_value="${select_map[$select_value]}" + if [ -z "$select_value" ]; then + echo "Error: Invalid Option $2" + exit 1 + fi + echo "$main_value""$select_value" + execute_command "$main_value""$select_value" + exit 0 + ;; +*) + if [[ $EUID != 0 ]]; then + echo -e "error: Exiting \nTry: 'sudo armbian-config'\n or: 'armbian-config --help' for More info\n\n" + exit 0 + fi + ;; +esac + + +# +# Generate the top menu with the modified Object data +set_colors 4 +generate_top_menu "$json_data" + +# +# Exit the script with a success status code + +# +# Show about this tool on exit +about_armbian_configng + +exit 0 From 14a73ade8169230cdb5431d081a1c94c848ec12a Mon Sep 17 00:00:00 2001 From: Tearran Date: Fri, 27 Dec 2024 03:54:36 +0000 Subject: [PATCH 07/10] revert armbian-config --- bin/armbian-config | 69 +++++++++++++++------------------------------- 1 file changed, 22 insertions(+), 47 deletions(-) diff --git a/bin/armbian-config b/bin/armbian-config index b04dc1433..30590e663 100755 --- a/bin/armbian-config +++ b/bin/armbian-config @@ -1,6 +1,6 @@ #!/bin/bash -[[ -t 1 ]] && tput init +tput init # # Language-based variable assignment for script directory path # This serves as a Rosetta Stone for developers, @@ -14,7 +14,7 @@ trap "exit" INT TERM script_dir="$(dirname "$0")" [[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools" -[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 +[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 # 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. [[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" @@ -36,23 +36,26 @@ declare -A module_options # Load configng core functions and module options array source "$lib_dir/config.functions.sh" -# TODO move to runtime file set_runtime_variables -#check_distro_status -#echo "Loaded Runtime variables..." #| show_infobox ; -# TODO -[[ -t 1 ]] && echo "Loaded Dialog..." #| show_infobox ; +check_distro_status +echo "Loaded Runtime variables..." #| show_infobox ; +#set_newt_colors 2 +echo "Loaded Dialog..." #| show_infobox ; source "$lib_dir/config.docs.sh" -[[ -t 1 ]] && echo "Loaded Docs..." #| show_infobox ; +echo "Loaded Docs..." #| show_infobox ; source "$lib_dir/config.system.sh" -[[ -t 1 ]] && echo "Loaded System helpers..." #| show_infobox ; +echo "Loaded System helpers..." #| show_infobox ; source "$lib_dir/config.network.sh" -[[ -t 1 ]] && echo "Loaded Network helpers..." #| show_infobox ; +echo "Loaded Network helpers..." #| show_infobox ; source "$lib_dir/config.software.sh" -[[ -t 1 ]] && echo "Loaded Software helpers..." #| show_infobox ; +echo "Loaded Software helpers..." #| show_infobox ; # # Loads the variables from beta armbian-config for runtime handling +source "$lib_dir/config.runtime.sh" +echo "Loaded Runtime conditions..." #| show_infobox ; + +clear case "$1" in "--help") @@ -67,25 +70,20 @@ case "$1" in --help [category] Use [category] to filter specific menu options. --cmd [option] Run a command from the menu (simple) --api [option] Run a helper command (advanced) - --doc Generate the README.md file + --doc Generate the README.md file Examples: armbian-config --help [cmd||System||Software||Network||Localisation] - armbian-config --cmd help + armbian-config --cmd help armbian-config --api help " exit 0 ;; "--doc") - # TODO: move --doc to --api generate_readme exit 0 ;; "--cmd") - # TODO move source for related groups - # to respective case switch - # Interface group not sepeated and mixed in functions and docs etc.. - # TODO Sort and group interface for source file INPUTMODE="cmd" shift if [[ -z "$1" || "$1" == "help" ]]; then @@ -93,41 +91,23 @@ case "$1" in exit 0 fi - args="$@" + args=$(sanitize_input "$@") execute_command "$args" exit 0 ;; "--api") - # move source for related groups - # to respective case switch - # source "$lib_dir/config.docs.sh" - # TODO remove interface spacifice function from docs into there own group files. shift - option="$1" - [[ "$option" == "json" ]] && generate_json_options | jq --tab '.' && exit 0 ; - [[ "$option" == "docs" ]] && generate_readme && exit 0 ; - if [[ -z "$option" || "$option" == "help" ]] ; then - echo "Options:" - echo " json - database in json format" - echo " docs - generate DOCUMEMT.md" - echo "" - exit 0 ; + if [[ -z "$1" || "$1" == "help" ]]; then + see_use + exit 0 fi + option="$1" shift - args="$@" + args=$(sanitize_input "$@") # echo -e "\"$option\" \"$args\"" "$option" "$args" exit 0 ;; -"--noint") - shift - option="$1" - [[ "$option" == "help" ]] && see_use ; exit 0 ; - shift - args="$@" - "$option" "$args" <&- - exit 0 - ;; "main=help" | "main=Help") see_cli_legacy echo "" @@ -176,11 +156,6 @@ case "$1" in ;; esac -clear -echo "Almost there ..." #| show_infobox ; -echo "Checking Runtime conditions..." #| show_infobox ; -source "$lib_dir/config.runtime.sh" -echo "Loaded Runtime conditions..." #| show_infobox ; # # Generate the top menu with the modified Object data From 95dffd722e4dde5466f5a34cab4c382cd9c5c6b3 Mon Sep 17 00:00:00 2001 From: Tearran Date: Sat, 4 Jan 2025 07:56:43 +0000 Subject: [PATCH 08/10] Addded timer --- tools/armbian-config-dev | 220 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) diff --git a/tools/armbian-config-dev b/tools/armbian-config-dev index 30590e663..8ece351bc 100755 --- a/tools/armbian-config-dev +++ b/tools/armbian-config-dev @@ -170,3 +170,223 @@ generate_top_menu "$json_data" about_armbian_configng exit 0 +#!/bin/bash + +# Prepare the module options array +declare -A module_options + +module_options+=( + ["set_checkpoint,author"]="@armbian" + ["set_checkpoint,maintainer"]="@igorpecovnik" + ["set_checkpoint,feature"]="set_checkpoint" + ["set_checkpoint,example"]="start stop show" + ["set_checkpoint,desc"]="Helper module for timing code execution" + ["set_checkpoint,status"]="Active" +) +# +# Function to manage timer with multiple checkpoints +function set_checkpoint() { + case "$1" in + help) + echo "Usage: set_checkpoint [description] [show]" + echo "Commands:" + echo " start Start the timer." + echo " stop Stop the timer." + echo " mark [description] [show] Mark a checkpoint with an optional description and an optional flag to show the output." + echo " show Show the total elapsed time and checkpoints." + ;; + start) + set_checkpoint_START=$(date +%s) + set_checkpoint_CHECKPOINTS=() + set_checkpoint_DESCRIPTIONS=() + set_checkpoint_PREV=$set_checkpoint_START + ;; + stop) + set_checkpoint_STOP=$(date +%s) + ;; + mark) + local checkpoint_time=$(date +%s) + local checkpoint_duration=$((checkpoint_time - set_checkpoint_PREV)) + set_checkpoint_PREV=$checkpoint_time + set_checkpoint_CHECKPOINTS+=($checkpoint_time) + set_checkpoint_DESCRIPTIONS+=("$2") + local count=${#set_checkpoint_DESCRIPTIONS[@]} + if [ "$3" == "true" ]; then + echo "$2: ${checkpoint_duration} seconds" + fi + ;; + show) + if [[ -n "$set_checkpoint_START" && -n "$set_checkpoint_STOP" ]]; then + set_checkpoint_DURATION=$((set_checkpoint_STOP - set_checkpoint_START)) + echo "Total elapsed time: ${set_checkpoint_DURATION} seconds" + + local previous_time=$set_checkpoint_START + for i in "${!set_checkpoint_CHECKPOINTS[@]}"; do + local checkpoint_time=${set_checkpoint_CHECKPOINTS[$i]} + local checkpoint_duration=$((checkpoint_time - previous_time)) + local description=${set_checkpoint_DESCRIPTIONS[$i]} + echo "${description:-Checkpoint $((i+1))}: ${checkpoint_duration} seconds" + previous_time=$checkpoint_time + done + + local final_duration=$((set_checkpoint_STOP - previous_time)) + echo "Final segment: ${final_duration} seconds" + else + echo "Timer has not been started and stopped properly." + fi + ;; + *) + echo "Usage: set_checkpoint [description]" + ;; + esac +} + + +set_checkpoint start + +tput init + +set_checkpoint mark "Initializing script" true +# +# Language-based variable assignment for script directory path +# This serves as a Rosetta Stone for developers, +# allowing them to use the variable name they are most comfortable with. + +# allows CTRL c to exit +trap "exit" INT TERM +[[ $EUID != 0 ]] && exec sudo "$0" "$@" +# +# Get the script directory +script_dir="$(dirname "$0")" +set_checkpoint mark "Setting base data" true + +[[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools" +[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash \"$tools_dir/config-assemble.sh\" to build the lib directory\n" && exit 1 + +# 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. +[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" + +# Define the lib directory one level up from the script directory +lib_dir="$script_dir/../lib/armbian-config" +doc_dir="$script_dir/../share/doc/armbian-config" +json_file="$lib_dir/config.jobs.json" + +# +# Load The Bash procedure Objects +json_data=$(<"$json_file") + + + +# +# Load configng core functions and module options array + +source "$lib_dir/config.functions.sh" + +set_runtime_variables + +check_distro_status + +set_checkpoint mark "Loaded Runtime variables..." true #| show_infobox ; +#set_newt_colors 2 +set_checkpoint mark "Loaded Dialog..." true #| show_infobox ; +source "$lib_dir/config.docs.sh" + +set_checkpoint mark "Loaded Docs..." true #| show_infobox ; +source "$lib_dir/config.system.sh" + +set_checkpoint mark "Loaded System helpers..." true #| show_infobox ; +source "$lib_dir/config.network.sh" + +set_checkpoint mark "Loaded Network helpers..." true #| show_infobox ; +source "$lib_dir/config.software.sh" + +set_checkpoint mark "Loaded Software helpers..." true #| show_infobox ; +# +# Loads the variables from beta armbian-config for runtime handling + +source "$lib_dir/config.runtime.sh" +set_checkpoint mark "Loaded Runtime conditions..." true #| show_infobox ; + + + +case "$1" in +"--help") + if [[ -n "$2" ]]; then + see_cmd_list "$2" + echo "" + exit 0 + fi + + echo "Usage: armbian-config --[option] + Options: + --help [category] Use [category] to filter specific menu options. + --cmd [option] Run a command from the menu (simple) + --api [option] Run a helper command (advanced) + --doc Generate the README.md file + + Examples: + armbian-config --help [cmd||System||Software||Network||Localisation] + armbian-config --cmd help + armbian-config --api help +" + exit 0 + ;; +"--doc") + generate_readme + exit 0 + ;; +"--cmd") + INPUTMODE="cmd" + shift + if [[ -z "$1" || "$1" == "help" ]]; then + see_cmd_list + exit 0 + fi + + args=$(sanitize_input "$@") + execute_command "$args" + exit 0 + ;; +"--api") + shift + if [[ -z "$1" || "$1" == "help" ]]; then + see_use + exit 0 + fi + option="$1" + shift + "$option" "$@" + exit 0 + ;; +*) + if [[ $EUID != 0 ]]; then + echo -e "error: Exiting \nTry: 'sudo armbian-config'\n or: 'armbian-config --help' for More info\n\n" + exit 0 + fi + ;; +esac + + + +# +# Generate the top menu with the modified Object data +set_colors 4 + +generate_top_menu "$json_data" + + +set_checkpoint stop + + +# +# Exit the script with a success status code + +# +# Show about this tool on exit +about_armbian_configng + +echo "" + +#set_checkpoint show + +exit 0 \ No newline at end of file From 21902b86f3b9163381223638475eafcac9b019ce Mon Sep 17 00:00:00 2001 From: Tearran Date: Sat, 4 Jan 2025 07:59:22 +0000 Subject: [PATCH 09/10] modified: tools/armbian-config-dev --- tools/armbian-config-dev | 175 +-------------------------------------- 1 file changed, 2 insertions(+), 173 deletions(-) diff --git a/tools/armbian-config-dev b/tools/armbian-config-dev index 8ece351bc..90ca336bf 100755 --- a/tools/armbian-config-dev +++ b/tools/armbian-config-dev @@ -1,177 +1,5 @@ #!/bin/bash -tput init -# -# Language-based variable assignment for script directory path -# This serves as a Rosetta Stone for developers, -# allowing them to use the variable name they are most comfortable with. - -# allows CTRL c to exit -trap "exit" INT TERM -[[ $EUID != 0 ]] && exec sudo "$0" "$@" -# -# Get the script directory -script_dir="$(dirname "$0")" - -[[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools" -[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && echo -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n" && exit 1 - -# 'whiptail' is a simple dialog box utility that works well with Bash. It doesn't have all the features of some other dialog box utilities, but it does everything we need for this script. -[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail" - -# Define the lib directory one level up from the script directory -lib_dir="$script_dir/../lib/armbian-config" -doc_dir="$script_dir/../share/doc/armbian-config" -json_file="$lib_dir/config.jobs.json" - -# -# Load The Bash procedure Objects -json_data=$(<"$json_file") - -# -# Prepare the module options array -declare -A module_options - -# -# Load configng core functions and module options array - -source "$lib_dir/config.functions.sh" -set_runtime_variables -check_distro_status -echo "Loaded Runtime variables..." #| show_infobox ; -#set_newt_colors 2 -echo "Loaded Dialog..." #| show_infobox ; -source "$lib_dir/config.docs.sh" -echo "Loaded Docs..." #| show_infobox ; -source "$lib_dir/config.system.sh" -echo "Loaded System helpers..." #| show_infobox ; -source "$lib_dir/config.network.sh" -echo "Loaded Network helpers..." #| show_infobox ; -source "$lib_dir/config.software.sh" -echo "Loaded Software helpers..." #| show_infobox ; -# -# Loads the variables from beta armbian-config for runtime handling - -source "$lib_dir/config.runtime.sh" -echo "Loaded Runtime conditions..." #| show_infobox ; - -clear - -case "$1" in -"--help") - if [[ -n "$2" ]]; then - see_cmd_list "$2" - echo "" - exit 0 - fi - - echo "Usage: armbian-config --[option] - Options: - --help [category] Use [category] to filter specific menu options. - --cmd [option] Run a command from the menu (simple) - --api [option] Run a helper command (advanced) - --doc Generate the README.md file - - Examples: - armbian-config --help [cmd||System||Software||Network||Localisation] - armbian-config --cmd help - armbian-config --api help -" - exit 0 - ;; -"--doc") - generate_readme - exit 0 - ;; -"--cmd") - INPUTMODE="cmd" - shift - if [[ -z "$1" || "$1" == "help" ]]; then - see_cmd_list - exit 0 - fi - - args=$(sanitize_input "$@") - execute_command "$args" - exit 0 - ;; -"--api") - shift - if [[ -z "$1" || "$1" == "help" ]]; then - see_use - exit 0 - fi - option="$1" - shift - args=$(sanitize_input "$@") - # echo -e "\"$option\" \"$args\"" - "$option" "$args" - exit 0 - ;; -"main=help" | "main=Help") - see_cli_legacy - echo "" - exit 0 - ;; -"main="*) - declare -A main_map - main_map=( - # map name to menu category - ["System"]="S" - ["Software"]="I" - ["Network"]="N" - ["Localisation"]="L" - ) - main_value="${1#main=}" - main_value="${main_map[$main_value]}" - - if [ -z "$main_value" ]; then - echo "Error: Invalid List $1" - exit 1 - fi - declare -A select_map - # map name to menu number - select_map=( - ["Headers"]="04" - ["Headers_install"]="04" - ["Headers_remove"]="05" - ["Firmware"]="06" - ["Nightly"]="07" - ) - select_value="${2#selection=}" - select_value="${select_map[$select_value]}" - if [ -z "$select_value" ]; then - echo "Error: Invalid Option $2" - exit 1 - fi - echo "$main_value""$select_value" - execute_command "$main_value""$select_value" - exit 0 - ;; -*) - if [[ $EUID != 0 ]]; then - echo -e "error: Exiting \nTry: 'sudo armbian-config'\n or: 'armbian-config --help' for More info\n\n" - exit 0 - fi - ;; -esac - - -# -# Generate the top menu with the modified Object data -set_colors 4 -generate_top_menu "$json_data" - -# -# Exit the script with a success status code - -# -# Show about this tool on exit -about_armbian_configng - -exit 0 -#!/bin/bash - # Prepare the module options array declare -A module_options @@ -355,6 +183,7 @@ case "$1" in fi option="$1" shift + # echo -e "\"$option\" \"$args\"" "$option" "$@" exit 0 ;; @@ -387,6 +216,6 @@ about_armbian_configng echo "" -#set_checkpoint show +set_checkpoint show exit 0 \ No newline at end of file From d80e4ab38a566f9819567c1fb9dbc9616d6a8c5f Mon Sep 17 00:00:00 2001 From: Tearran Date: Sat, 4 Jan 2025 08:15:37 +0000 Subject: [PATCH 10/10] added checkpoint --- tools/armbian-config-dev | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/armbian-config-dev b/tools/armbian-config-dev index 90ca336bf..3b3c14258 100755 --- a/tools/armbian-config-dev +++ b/tools/armbian-config-dev @@ -112,7 +112,7 @@ source "$lib_dir/config.functions.sh" set_runtime_variables -check_distro_status +set_checkpoint mark "$(check_distro_status)" true set_checkpoint mark "Loaded Runtime variables..." true #| show_infobox ; #set_newt_colors 2 @@ -214,8 +214,4 @@ set_checkpoint stop # Show about this tool on exit about_armbian_configng -echo "" - -set_checkpoint show - exit 0 \ No newline at end of file