1
1
#! /bin/bash
2
2
3
3
# initializes the terminal from TERM if stdin is a terminal
4
- [[ -t 0 ]] && tput init
5
-
6
- # Language-based variable assignment for script directory path
7
- # This serves as a Rosetta Stone for developers,
8
- # allowing them to use the variable name they are most comfortable with.
9
-
4
+ unset UXMODE
5
+ [[ -t 0 && " $1 " =~ ^(| --cmd| --help)$ ]] && UXMODE=" true" && tput init
10
6
# allows CTRL c to exit
11
7
trap " exit" INT TERM
8
+
12
9
[[ $EUID != 0 ]] && exec sudo " $0 " " $@ "
13
10
#
14
11
# Get the script directory
15
12
script_dir=" $( dirname " $0 " ) "
16
13
14
+ declare -A module_options
15
+
16
+ # Load the initialize modules
17
+ source " $script_dir /../lib/armbian-config/config.initialize.sh"
18
+
19
+ # Start loading messages
20
+ set_checkpoint start
21
+ set_checkpoint mark " Initializing script"
22
+
17
23
[[ -d " $script_dir /../tools" ]] && tools_dir=" $script_dir /../tools"
18
24
[[ ! -d " $script_dir /../lib" && -n " $tools_dir " ]] && die -e " Please run\nbash " $tools_dir /config-assemble.sh" to build the lib directory\n"
19
25
@@ -29,32 +35,33 @@ json_file="$lib_dir/config.jobs.json"
29
35
# Load The Bash procedure Objects
30
36
json_data=$( < " $json_file " )
31
37
32
- #
33
- # Prepare the module options array
34
- declare -A module_options
35
38
36
- #
37
39
# Load configng core functions and module options array
38
40
39
41
source " $lib_dir /config.functions.sh"
40
42
set_runtime_variables
41
- check_distro_status
42
- echo " Loaded Runtime variables..." # | show_infobox ;
43
- # set_newt_colors 2
44
- echo " Loaded Dialog..." # | show_infobox ;
43
+ set_checkpoint mark " Loaded Runtime variables..."
44
+ # checks for supported os
45
+ set_checkpoint mark " $( check_distro_status) "
46
+
47
+ set_checkpoint mark " Loaded Dialog..."
45
48
source " $lib_dir /config.docs.sh"
46
- echo " Loaded Docs..." # | show_infobox ;
49
+ set_checkpoint mark " Loaded Docs..."
47
50
source " $lib_dir /config.system.sh"
48
- echo " Loaded System helpers..." # | show_infobox ;
51
+ set_checkpoint mark " Loaded System helpers..."
49
52
source " $lib_dir /config.network.sh"
50
- echo " Loaded Network helpers..." # | show_infobox ;
53
+ set_checkpoint mark " Loaded Network helpers..."
51
54
source " $lib_dir /config.software.sh"
52
- echo " Loaded Software helpers..." # | show_infobox ;
55
+ set_checkpoint mark " Loaded Software helpers..."
53
56
#
54
57
# Loads the variables from beta armbian-config for runtime handling
55
58
56
59
source " $lib_dir /config.runtime.sh"
57
- echo " Loaded Runtime conditions..." # | show_infobox ;
60
+ set_checkpoint mark " Loaded Runtime conditions..."
61
+
62
+ # usage: sudo DEBUG=1 ./config-time/bin/armbian-config $@
63
+ # place one in a section with a quoted "about message"
64
+ [[ -n " $DEBUG " ]] && set_checkpoint mark " DEBUG Messages on" ;
58
65
59
66
case " $1 " in
60
67
" --help" )
@@ -63,7 +70,7 @@ case "$1" in
63
70
echo " "
64
71
else
65
72
echo " Usage: armbian-config --[option]
66
- Options:
73
+ Options:
67
74
--help [category] Use [category] to filter specific menu options.
68
75
--cmd [option] Run a command from the menu (simple)
69
76
--api [option] Run a helper command (advanced)
@@ -82,6 +89,7 @@ case "$1" in
82
89
;;
83
90
84
91
" --cmd" )
92
+ checkpoint debug " Starting Command line UX option"
85
93
INPUTMODE=" cmd"
86
94
case " $2 " in
87
95
" " |" help" )
@@ -90,11 +98,13 @@ case "$1" in
90
98
* )
91
99
cmd=$( sanitize " $2 " ) || die
92
100
execute_command " $cmd "
101
+ checkpoint debug " Starting Command line options UX"
93
102
;;
94
103
esac
95
104
;;
96
105
97
106
" --api" )
107
+ checkpoint debug " Starting --api options"
98
108
case " $2 " in
99
109
" " |" help" )
100
110
see_use
@@ -103,6 +113,7 @@ case "$1" in
103
113
fn=$( sanitize " $2 " ) || die
104
114
shift 2
105
115
" $fn " " $@ "
116
+ checkpoint debug " Exiting --api"
106
117
;;
107
118
esac
108
119
;;
@@ -145,9 +156,13 @@ case "$1" in
145
156
* )
146
157
# Generate the top menu with the modified Object data
147
158
set_colors 4
159
+ checkpoint debug " Starting Text User Interface (TUI)"
148
160
generate_top_menu " $json_data "
149
-
150
- # Show about this tool on exit
161
+ checkpoint debug " Exiting TUI "
162
+ # Show about this tool on exit
151
163
about_armbian_configng
164
+
152
165
;;
153
166
esac
167
+
168
+ [[ -n " $DEBUG " && -n $tools_dir ]] && set_checkpoint show
0 commit comments