Skip to content

Commit be1d9b0

Browse files
committed
Change menu.ini to dockstarter.ini
1 parent 9653caa commit be1d9b0

File tree

12 files changed

+112
-50
lines changed

12 files changed

+112
-50
lines changed
File renamed without changes.

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
# Alternative configuration directory - legacy path, referenced in migration scripts
3838
/configs/
3939

40+
# DockSTARTer preferences file
41+
/dockstarter.ini
42+
4043
# Application log file - created by .scripts/log.sh for DockSTARTer output
4144
/dockstarter.log
4245

43-
# Menu configuration file - created by .scripts/menu.sh for storing menu preferences
44-
/menu.ini
45-
4646
# Shared data directory - created by .scripts/compose_setup.sh for container volume mounts
4747
/share/
4848

.includes/dialog_functions.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ DIALOG=$(command -v dialog) || true
88
declare -Agx DC
99

1010
declare -rgx DIALOGRC_NAME='.dialogrc'
11-
declare -rgx DIALOGRC="${TEMP_FOLDER}/${DIALOGRC_NAME}"
12-
declare -rgx DIALOG_OPTIONS_FILE="${TEMP_FOLDER}/.dialogoptions"
11+
declare -rgx DIALOG_OPTIONS_NAME='.dialogoptions'
12+
13+
declare -rgx DIALOGRC="${SCRIPTPATH}/${DIALOGRC_NAME}"
14+
declare -rgx DIALOG_OPTIONS_FILE="${SCRIPTPATH}/${DIALOG_OPTIONS_NAME}"
1315

1416
declare -rigx DIALOGTIMEOUT=3
1517
declare -rigx DIALOG_OK=0

.includes/global_variables.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,30 @@ sudo chown "${DETECTED_PUID}":"${DETECTED_PGID}" "${TEMP_FOLDER}"
1414
sudo chmod a=,a+rX,u+w,g+w "${TEMP_FOLDER}"
1515

1616
declare -rgx COMPOSE_FOLDER_NAME="compose"
17+
declare -rgx DEFAULTS_FOLDER_NAME=".defaults"
1718
declare -rgx THEME_FOLDER_NAME=".themes"
19+
1820
declare -rgx COMPOSE_FOLDER="${SCRIPTPATH}/${COMPOSE_FOLDER_NAME}"
21+
declare -rgx DEFAULTS_FOLDER="${SCRIPTPATH}/${DEFAULTS_FOLDER_NAME}"
1922
declare -rgx THEME_FOLDER="${SCRIPTPATH}/${THEME_FOLDER_NAME}"
2023

21-
declare -rgx INSTANCES_FOLDER_NAME=".instances"
22-
declare -rgx TEMPLATES_FOLDER_NAME=".apps"
23-
declare -rgx APP_ENV_FOLDER_NAME="env_files"
2424
declare -rgx DOCKER_COMPOSE_FILE="${COMPOSE_FOLDER}/docker-compose.yml"
2525
declare -rgx COMPOSE_OVERRIDE_NAME="docker-compose.override.yml"
2626
declare -rgx COMPOSE_ENV="${COMPOSE_FOLDER}/.env"
2727
declare -rgx COMPOSE_ENV_DEFAULT_FILE="${COMPOSE_FOLDER}/.env.example"
2828
declare -rgx COMPOSE_OVERRIDE="${COMPOSE_FOLDER}/${COMPOSE_OVERRIDE_NAME}"
29+
30+
declare -rgx APP_ENV_FOLDER_NAME="env_files"
31+
declare -rgx INSTANCES_FOLDER_NAME=".instances"
32+
declare -rgx TEMPLATES_FOLDER_NAME=".apps"
33+
declare -rgx TIMESTAMPS_FOLDER_NAME=".timestamps"
34+
2935
declare -rgx APP_ENV_FOLDER="${COMPOSE_FOLDER}/${APP_ENV_FOLDER_NAME}"
30-
declare -rgx TEMPLATES_FOLDER="${COMPOSE_FOLDER}/${TEMPLATES_FOLDER_NAME}"
3136
declare -rgx INSTANCES_FOLDER="${COMPOSE_FOLDER}/${INSTANCES_FOLDER_NAME}"
32-
declare -rgx TIMESTAMPS_FOLDER="${COMPOSE_FOLDER}/.timestamps"
37+
declare -rgx TEMPLATES_FOLDER="${COMPOSE_FOLDER}/${TEMPLATES_FOLDER_NAME}"
38+
declare -rgx TIMESTAMPS_FOLDER="${COMPOSE_FOLDER}/${TIMESTAMPS_FOLDER_NAME}"
39+
40+
declare -rgx APPLICATION_INI_NAME="dockstarter.ini"
41+
declare -rgx APPLICATION_INI_FILE="${SCRIPTPATH}/${APPLICATION_INI_NAME}"
3342

34-
declare -rgx MENU_INI_NAME='menu.ini'
35-
declare -rgx MENU_INI_FILE="${SCRIPTPATH}/${MENU_INI_NAME}"
36-
declare -rgx THEME_FILE_NAME='theme.ini'
43+
declare -rgx THEME_FILE_NAME="theme.ini"

.scripts/apply_config.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
IFS=$'\n\t'
4+
5+
apply_config() {
6+
if [[ ! -f ${APPLICATION_INI_FILE} ]]; then
7+
run_script 'config_create'
8+
fi
9+
run_script 'apply_theme'
10+
sort -o "${APPLICATION_INI_FILE}" "${APPLICATION_INI_FILE}"
11+
}
12+
13+
test_apply_config() {
14+
warn "CI does not test apply_config."
15+
}

.scripts/apply_theme.sh

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ apply_theme() {
1010
Default
1111
)
1212

13+
if [[ ! -f ${APPLICATION_INI_FILE} ]]; then
14+
run_script 'config_create'
15+
fi
16+
1317
local ThemeFile DialogFile
14-
local DefaultMenuIniFile="${THEME_FOLDER}/${MENU_INI_NAME}"
18+
local DefaultIniFile="${DEFAULTS_FOLDER}/${APPLICATION_INI_NAME}"
1519
if [[ -z ${ThemeName-} ]]; then
16-
if [[ ! -f ${MENU_INI_FILE} ]]; then
17-
cp "${DefaultMenuIniFile}" "${MENU_INI_FILE}"
18-
fi
19-
ThemeName="$(run_script 'config_get' Theme "${MENU_INI_FILE}")"
20+
ThemeName="$(run_script 'config_get' Theme)"
2021
if ! run_script 'theme_exists' "${ThemeName}"; then
2122
for Name in "${DefaultThemes[@]}"; do
2223
if run_script 'theme_exists' "${Name}"; then
@@ -95,37 +96,39 @@ apply_theme() {
9596
local DialogOptions="--colors --output-fd 1 --cr-wrap --no-collapse"
9697

9798
local LineCharacters Borders Scrollbar Shadow
98-
if run_script 'env_var_exists' Scrollbar "${MENU_INI_FILE}"; then
99-
Scrollbar="$(run_script 'config_get' Scrollbar "${MENU_INI_FILE}")"
99+
if run_script 'env_var_exists' Scrollbar "${APPLICATION_INI_FILE}"; then
100+
Scrollbar="$(run_script 'config_get' Scrollbar)"
100101
else
101-
Scrollbar="$(run_script 'config_get' Scrollbar "${DefaultMenuIniFile}")"
102-
run_script 'config_set' Scrollbar "${Scrollbar}" "${MENU_INI_FILE}"
102+
Scrollbar="$(run_script 'config_get' Scrollbar "${DefaultIniFile}")"
103+
run_script 'config_set' Scrollbar "${Scrollbar}"
103104
fi
104-
if run_script 'env_var_exists' Shadow "${MENU_INI_FILE}"; then
105-
Shadow="$(run_script 'config_get' Shadow "${MENU_INI_FILE}")"
105+
if run_script 'env_var_exists' Shadow "${APPLICATION_INI_FILE}"; then
106+
Shadow="$(run_script 'config_get' Shadow)"
106107
else
107-
Shadow="$(run_script 'config_get' Shadow "${DefaultMenuIniFile}")"
108-
run_script 'config_set' Shadow "${Shadow}" "${MENU_INI_FILE}"
108+
Shadow="$(run_script 'config_get' Shadow "${DefaultIniFile}")"
109+
run_script 'config_set' Shadow "${Shadow}"
109110
fi
110111
# Migrate old LineCharacters variable to Borders if Borders doesn't exist
111-
if run_script 'env_var_exists' Borders "${MENU_INI_FILE}"; then
112-
Borders="$(run_script 'config_get' Borders "${MENU_INI_FILE}")"
113-
if run_script 'env_var_exists' LineCharacters "${MENU_INI_FILE}"; then
114-
LineCharacters="$(run_script 'config_get' LineCharacters "${MENU_INI_FILE}")"
112+
if run_script 'env_var_exists' Borders "${APPLICATION_INI_FILE}"; then
113+
Borders="$(run_script 'config_get' Borders)"
114+
if run_script 'env_var_exists' LineCharacters "${APPLICATION_INI_FILE}"; then
115+
LineCharacters="$(run_script 'config_get' LineCharacters)"
115116
else
116-
LineCharacters="$(run_script 'config_get' LineCharacters "${DefaultMenuIniFile}")"
117-
run_script 'config_set' LineCharacters "${LineCharacters}" "${MENU_INI_FILE}"
117+
LineCharacters="$(run_script 'config_get' LineCharacters "${DefaultIniFile}")"
118+
run_script 'config_set' LineCharacters "${LineCharacters}"
118119
fi
119120
else
120-
if run_script 'env_var_exists' LineCharacters "${MENU_INI_FILE}"; then
121-
Borders="$(run_script 'config_get' LineCharacters "${MENU_INI_FILE}")"
121+
if run_script 'env_var_exists' LineCharacters "${APPLICATION_INI_FILE}"; then
122+
Borders="$(run_script 'config_get' LineCharacters)"
122123
else
123-
Borders="$(run_script 'config_get' Borders "${DefaultMenuIniFile}")"
124+
Borders="$(run_script 'config_get' Borders "${DefaultIniFile}")"
124125
fi
125-
run_script 'config_set' Borders "${Borders}" "${MENU_INI_FILE}"
126-
LineCharacters="$(run_script 'config_get' LineCharacters "${DefaultMenuIniFile}")"
127-
run_script 'config_set' LineCharacters "${LineCharacters}" "${MENU_INI_FILE}"
126+
run_script 'config_set' Borders "${Borders}"
127+
LineCharacters="$(run_script 'config_get' LineCharacters "${DefaultIniFile}")"
128+
run_script 'config_set' LineCharacters "${LineCharacters}"
128129
fi
130+
131+
# Set the dialog options based on the settings in the .ini file
129132
if is_true "${Borders}"; then
130133
if is_false "${LineCharacters}"; then
131134
DialogOptions+=" --ascii-lines"
@@ -145,13 +148,17 @@ apply_theme() {
145148
else
146149
DialogOptions+=" --no-shadow"
147150
fi
151+
148152
echo "${DialogOptions}" > "${DIALOG_OPTIONS_FILE}" ||
149-
fatal "Failed to save dialog options file.\nFailing command: ${C["FailingCommand"]}echo \"${DialogOptions}\" > \"${DIALOG_OPTIONS_FILE}\""
153+
fatal \
154+
"Failed to save dialog options file.\n" \
155+
"Failing command: ${C["FailingCommand"]}echo \"${DialogOptions}\" > \"${DIALOG_OPTIONS_FILE}\""
150156
run_script 'set_permissions' "${DIALOG_OPTIONS_FILE}"
151157

152158
cp "${DialogFile}" "${DIALOGRC}"
153-
run_script 'config_set' Theme "${ThemeName}" "${MENU_INI_FILE}"
154-
sort -o "${MENU_INI_FILE}" "${MENU_INI_FILE}"
159+
run_script 'set_permissions' "${DIALOGRC}"
160+
161+
run_script 'config_set' Theme "${ThemeName}"
155162
}
156163

157164
test_apply_theme() {

.scripts/config_create.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
IFS=$'\n\t'
4+
5+
config_create() {
6+
if [[ ! -f ${APPLICATION_INI_FILE} ]]; then
7+
local OldIniFile="${SCRIPTPATH}/menu.ini"
8+
if [[ -f ${OldIniFile} ]]; then
9+
# Migrate from the old menu.ini file
10+
notice "Renaming '${C["File"]-}${OldIniFile}${NC-}' to '${C["File"]-}${APPLICATION_INI_FILE}${NC-}'."
11+
mv "${OldIniFile}" "${APPLICATION_INI_FILE}" ||
12+
fatal \
13+
"Failed to rename old config file.\n" \
14+
"Failing command: ${C["FailingCommand"]}mv \"${OldIniFile}\" \"${APPLICATION_INI_FILE}\""
15+
16+
else
17+
# Copy the default .ini file
18+
local DefaultIniFile="${DEFAULTS_FOLDER}/${APPLICATION_INI_NAME}"
19+
notice "Copying '${C["File"]-}${DefaultIniFile}${NC-}' to '${C["File"]-}${APPLICATION_INI_FILE}${NC-}'."
20+
cp "${DefaultIniFile}" "${APPLICATION_INI_FILE}" ||
21+
fatal \
22+
"Failed to copy default config file.\n" \
23+
"Failing command: ${C["FailingCommand"]}cp \"${DefaultIniFile}\" \"${APPLICATION_INI_FILE}\""
24+
25+
fi
26+
fi
27+
}
28+
29+
test_config_create() {
30+
warn "CI does not test create_config."
31+
}

.scripts/config_get.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ declare -a _dependencies_list=(
99
config_get() {
1010
# config_get GET_VAR [VAR_FILE]
1111
local GET_VAR=${1-}
12-
local VAR_FILE=${2:-}
12+
local VAR_FILE=${2:-$APPLICATION_INI_FILE}
1313

1414
if [[ -f ${VAR_FILE} ]]; then
1515
${SED} -nE "s/^\s*${GET_VAR}\s*=\s*(.*)/\1/p" "${VAR_FILE}" | tail -1 | xargs || true

.scripts/config_set.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ config_set() {
1010
# config_set SET_VAR NEW_VAL [VAR_FILE]
1111
local SET_VAR=${1-}
1212
local NEW_VAL=${2-}
13-
local VAR_FILE=${3-}
13+
local VAR_FILE=${3-$APPLICATION_INI_FILE}
1414

1515
# https://unix.stackexchange.com/questions/422165/escape-double-quotes-in-variable/422170#422170
1616
NEW_VAL="$(printf "%s\n" "${NEW_VAL-}" | ${SED} -e "s/'/'\"'\"'/g" -e "1s/^/'/" -e "\$s/\$/'/")"

.scripts/menu_options_display.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ menu_options_display() {
99

1010
local Title="Display Options"
1111

12-
#run_script 'apply_theme'
12+
run_script 'apply_theme' &> /dev/null
1313

1414
local DrawLineOption="Draw Lines"
1515
local ShowBordersOption="Show Borders"
@@ -33,7 +33,7 @@ menu_options_display() {
3333
local Opts=()
3434
for Option in "${DrawLineOption}" "${ShowBordersOption}" "${ShowScrollbarOption}" "${ShowShadowOption}"; do
3535
local Value
36-
Value="$(run_script 'config_get' "${OptionVariable["${Option}"]}" "${MENU_INI_FILE}")"
36+
Value="$(run_script 'config_get' "${OptionVariable["${Option}"]}")"
3737
if is_true "${Value}"; then
3838
EnabledOptions+=("${Option}")
3939
Opts+=("${Option}" "${OptionDescription["${Option}"]}" ON)
@@ -66,15 +66,15 @@ menu_options_display() {
6666
if [[ -n ${OptionsToTurnOff[*]-} || ${OptionsToTurnOn[*]-} ]]; then
6767
if [[ -n ${OptionsToTurnOff[*]-} ]]; then
6868
for Option in "${OptionsToTurnOff[@]}"; do
69-
run_script 'config_set' "${OptionVariable["${Option}"]}" OFF "${MENU_INI_FILE}"
69+
run_script 'config_set' "${OptionVariable["${Option}"]}" OFF
7070
done
7171
fi
7272
if [[ -n ${OptionsToTurnOn[*]-} ]]; then
7373
for Option in "${OptionsToTurnOn[@]}"; do
74-
run_script 'config_set' "${OptionVariable["${Option}"]}" ON "${MENU_INI_FILE}"
74+
run_script 'config_set' "${OptionVariable["${Option}"]}" ON
7575
done
7676
fi
77-
run_script 'apply_theme'
77+
run_script 'apply_theme' &> /dev/null
7878
fi
7979
;;
8080
CANCEL | ESC)

0 commit comments

Comments
 (0)