Skip to content

Commit 9ed2c23

Browse files
committed
update
1 parent 7056fa8 commit 9ed2c23

File tree

4 files changed

+80
-60
lines changed

4 files changed

+80
-60
lines changed

bin/armbian-config

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
#!/bin/bash
22

33
# initializes the terminal from TERM if stdin is a terminal
4-
[[ -t 0 ]] && tput init
5-
4+
unset UXMODE
5+
[[ -t 0 && "$1" =~ ^(|--cmd|--help)$ ]] && UXMODE="true" && tput init
66
# allows CTRL c to exit
77
trap "exit" INT TERM
8+
89
[[ $EUID != 0 ]] && exec sudo "$0" "$@"
910
#
1011
# Get the script directory
1112
script_dir="$(dirname "$0")"
1213

1314
declare -A module_options
1415

15-
# Conditional settings based on arguments
16-
# for interactive vs non-interactive modes
17-
if [[ "$1" == "--api" || "$1" == "--doc" ]]; then
18-
UXMODE="false"
19-
elif [[ -z "$1" || "$1" == "--cmd" || "$1" == "--help" ]]; then
20-
UXMODE="true"
21-
fi
22-
23-
# Additional check for interactive vs non-interactive mode
24-
if [[ ! -t 0 ]]; then
25-
UXMODE="false"
26-
fi
27-
2816
# Load the initialize modules
2917
source "$script_dir/../lib/armbian-config/config.initialize.sh"
3018

19+
# Start loading messages
3120
set_checkpoint start
32-
set_checkpoint mark "Initializing script" true
21+
set_checkpoint mark "Initializing script"
3322

3423
[[ -d "$script_dir/../tools" ]] && tools_dir="$script_dir/../tools"
3524
[[ ! -d "$script_dir/../lib" && -n "$tools_dir" ]] && die -e "Please run\nbash "$tools_dir/config-assemble.sh" to build the lib directory\n"
3625

26+
27+
DEV=$([[ "$(basename "$0")" =~ .*"-dev"$ ]] && echo "true")
28+
29+
# If the script name ends with "-dev", source all .sh files in the dev directory
30+
if [[ "$DEV" == "true" ]]; then
31+
for file in "$tools_dir/development"/*.sh; do
32+
set_checkpoint mark "Loading development modules"
33+
. "$file"
34+
done
35+
fi
36+
3737
# '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.
3838
[[ -x "$(command -v whiptail)" ]] && DIALOG="whiptail"
3939

@@ -51,24 +51,25 @@ json_data=$(<"$json_file")
5151

5252
source "$lib_dir/config.functions.sh"
5353
set_runtime_variables
54-
set_checkpoint mark "Loaded Runtime variables..." true
54+
set_checkpoint mark "Loaded Runtime variables..."
5555
# checks for supported os
56-
set_checkpoint mark "$(check_distro_status)" true
56+
set_checkpoint mark "$(check_distro_status)"
5757

58-
set_checkpoint mark "Loaded Dialog..." true
58+
set_checkpoint mark "Loaded Dialog..."
5959
source "$lib_dir/config.docs.sh"
60-
set_checkpoint mark "Loaded Docs..." true
60+
set_checkpoint mark "Loaded Docs..."
6161
source "$lib_dir/config.system.sh"
62-
set_checkpoint mark "Loaded System helpers..." true
62+
set_checkpoint mark "Loaded System helpers..."
6363
source "$lib_dir/config.network.sh"
64-
set_checkpoint mark "Loaded Network helpers..." true
64+
set_checkpoint mark "Loaded Network helpers..."
6565
source "$lib_dir/config.software.sh"
66-
set_checkpoint mark "Loaded Software helpers..." true
66+
set_checkpoint mark "Loaded Software helpers..."
6767
#
6868
# Loads the variables from beta armbian-config for runtime handling
6969

7070
source "$lib_dir/config.runtime.sh"
71-
echo "Loaded Runtime conditions..." true
71+
set_checkpoint mark "Loaded Runtime conditions..."
72+
set_checkpoint stop
7273

7374
case "$1" in
7475
"--help")
@@ -77,7 +78,7 @@ case "$1" in
7778
echo ""
7879
else
7980
echo "Usage: armbian-config --[option]
80-
Options:
81+
Options:
8182
--help [category] Use [category] to filter specific menu options.
8283
--cmd [option] Run a command from the menu (simple)
8384
--api [option] Run a helper command (advanced)

tools/armbian-config-dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../bin/armbian-config

tools/development/dev_message.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
#
4+
dev_playground() {
5+
# playground
6+
set_checkpoint mark "Loading Production modules in [##########]"
7+
sleep 0.25
8+
set_checkpoint mark "Loading Production modules in [####### ]"
9+
sleep 0.25
10+
set_checkpoint mark "Loading Production modules in [##### ]"
11+
sleep 0.25
12+
set_checkpoint mark "Loading Production modules in [## ]"
13+
sleep 0.25
14+
echo "Loading Production modules "
15+
16+
}
17+
18+
dev_playground

tools/modules/initialize/message_checkpoint.sh

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,52 @@ module_options+=(
1616
function set_checkpoint() {
1717
case "$1" in
1818
help)
19-
echo "Usage: set_checkpoint <start|stop|mark|show> [description] [show]"
20-
echo "Commands:"
21-
echo " start Start the timer."
22-
echo " stop Stop the timer."
23-
echo " mark [description] [time] Mark a checkpoint with an optional description and an optional flag to show the output."
24-
echo " show Show the total elapsed time and checkpoints."
19+
echo "Usage: set_checkpoint <start|stop|mark|show> [description] [show]"
20+
echo "Commands:"
21+
echo " start Start the timer."
22+
echo " stop Stop the timer."
23+
echo " mark [description] [time] Mark a checkpoint with an optional description and an optional flag to show the output."
24+
echo " show Show the total elapsed time and checkpoints."
2525
;;
2626
start)
27-
set_checkpoint_START=$(date +%s)
28-
set_checkpoint_CHECKPOINTS=()
29-
set_checkpoint_DESCRIPTIONS=()
30-
set_checkpoint_PREV=$set_checkpoint_START
27+
set_checkpoint_START=$(date +%s)
28+
set_checkpoint_CHECKPOINTS=()
29+
set_checkpoint_DESCRIPTIONS=()
30+
set_checkpoint_PREV=$set_checkpoint_START
3131
;;
3232
stop)
33-
set_checkpoint_STOP=$(date +%s)
33+
set_checkpoint_STOP=$(date +%s)
3434
;;
3535
mark)
36-
local checkpoint_time=$(date +%s)
37-
local checkpoint_duration=$((checkpoint_time - set_checkpoint_PREV))
38-
set_checkpoint_PREV=$checkpoint_time
39-
set_checkpoint_CHECKPOINTS+=($checkpoint_time)
40-
set_checkpoint_DESCRIPTIONS+=("$2")
41-
local count=${#set_checkpoint_DESCRIPTIONS[@]}
42-
if [[ "$3" == "true" && $UXMODE == "true" ]]; then
43-
printf "%-30s %10d seconds\n" "$2:" "${checkpoint_duration}"
44-
fi
36+
if [[ "$UXMODE" == "true" ]]; then
37+
local checkpoint_time=$(date +%s)
38+
local checkpoint_duration=$((checkpoint_time - set_checkpoint_PREV))
39+
set_checkpoint_PREV=$checkpoint_time
40+
set_checkpoint_CHECKPOINTS+=($checkpoint_time)
41+
set_checkpoint_DESCRIPTIONS+=("$2")
42+
local count=${#set_checkpoint_DESCRIPTIONS[@]}
43+
printf "%-30s %10d seconds\n" "$2 " "${checkpoint_duration}"
44+
fi
4545
;;
4646
show)
47-
if [[ -n "$set_checkpoint_START" && -n "$set_checkpoint_STOP" ]]; then
48-
set_checkpoint_DURATION=$((set_checkpoint_STOP - set_checkpoint_START))
49-
printf "%-30s: %d seconds\n" "Total elapsed time" "${set_checkpoint_DURATION}"
47+
if [[ -n "$set_checkpoint_START" && -n "$set_checkpoint_STOP" ]]; then
48+
set_checkpoint_DURATION=$((set_checkpoint_STOP - set_checkpoint_START))
49+
printf "%-30s: %d seconds\n" "Total elapsed time" "${set_checkpoint_DURATION}"
5050

51-
local previous_time=$set_checkpoint_START
52-
for i in "${!set_checkpoint_CHECKPOINTS[@]}"; do
53-
local checkpoint_time=${set_checkpoint_CHECKPOINTS[$i]}
54-
local checkpoint_duration=$((checkpoint_time - previous_time))
55-
local description=${set_checkpoint_DESCRIPTIONS[$i]}
56-
printf "%-30s: %d seconds\n" "${description:-Checkpoint $((i+1))}" "${checkpoint_duration}"
57-
previous_time=$checkpoint_time
58-
done
59-
else
60-
echo "Timer has not been started and stopped properly."
61-
fi
51+
local previous_time=$set_checkpoint_START
52+
for i in "${!set_checkpoint_CHECKPOINTS[@]}"; do
53+
local checkpoint_time=${set_checkpoint_CHECKPOINTS[$i]}
54+
local checkpoint_duration=$((checkpoint_time - previous_time))
55+
local description=${set_checkpoint_DESCRIPTIONS[$i]}
56+
printf "%-30s: %d seconds\n" "${description:-Checkpoint $((i+1))}" "${checkpoint_duration}"
57+
previous_time=$checkpoint_time
58+
done
59+
else
60+
echo "Timer has not been started and stopped properly."
61+
fi
6262
;;
6363
*)
64-
echo "Usage: set_checkpoint <start|stop|mark|show> [description]"
64+
echo "Usage: set_checkpoint <start|stop|mark|show> [description]"
6565
;;
6666
esac
6767
}

0 commit comments

Comments
 (0)