Skip to content

Commit 3f83ffd

Browse files
committed
Add support for including given plugins in configuration phase
1 parent 6a1bfac commit 3f83ffd

1 file changed

Lines changed: 42 additions & 5 deletions

File tree

virtualmin-install.sh

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ bundle='LAMP' # Other option is LEMP
4444
mode="${mode:-full}" # Other option is mini
4545
skipyesno=0
4646
config_excludes="${config_excludes:-}"
47+
config_includes="${config_includes:-}"
4748
extra_packages="${extra_packages:-}"
4849

4950
usage() {
@@ -61,6 +62,7 @@ usage() {
6162
printf " --os-grade|-g <A|B> operating system support grade (default: A)\\n\\n"
6263
printf " --extra|-E <name[,name..]> install extra packages before stack install\\n"
6364
printf " --exclude|-e <name[,name..]> exclude plugin from configuration phase\\n"
65+
printf " --include|-i <name[,name..]> include plugin in configuration phase\\n"
6466
echo
6567
printf " --module|-o load custom module in post-install phase\\n"
6668
echo
@@ -71,7 +73,7 @@ usage() {
7173
printf " --setup|-s reconfigure repos without installing\\n"
7274
printf " --connect|-C <ipv4|ipv6> test connectivity without installing\\n"
7375
echo
74-
printf " --insecure-downloads|-i skip SSL certificate check for downloads\\n"
76+
printf " --insecure-downloads|-I skip SSL certificate check for downloads\\n"
7577
echo
7678
printf " --uninstall|-u remove all packages and dependencies\\n"
7779
echo
@@ -230,6 +232,33 @@ add_config_excludes() {
230232
IFS=$old_ifs
231233
}
232234

235+
# Function to add config includes
236+
add_config_includes() {
237+
old_ifs=$IFS
238+
IFS=,
239+
set -f
240+
for raw in $1; do
241+
# Trim leading/trailing whitespace
242+
x=$(printf '%s' "$raw" | sed 's/^[[:space:]]*//; s/[[:space:]]*$//')
243+
[ -n "$x" ] || continue
244+
case "$x" in
245+
-*|*[!A-Za-z0-9]*)
246+
printf "Invalid include name: %s\n" "$x" >&2
247+
exit 1
248+
;;
249+
esac
250+
# Converts for some formatted names
251+
case "$x" in
252+
MariaDB)
253+
x="MySQL"
254+
;;
255+
esac
256+
config_includes="${config_includes} --include $x"
257+
done
258+
set +f
259+
IFS=$old_ifs
260+
}
261+
233262
# Default function to parse arguments
234263
parse_args() {
235264
while [ "$1" != "" ]; do
@@ -300,7 +329,7 @@ parse_args() {
300329
;;
301330
esac
302331
;;
303-
--insecure-downloads | -i)
332+
--insecure-downloads | -I)
304333
shift
305334
insecure_download_wget_flag=' --no-check-certificate'
306335
insecure_download_curl_flag=' -k'
@@ -343,7 +372,6 @@ parse_args() {
343372
B|b)
344373
shift
345374
unstable='unstable'
346-
virtualmin_stack_custom_packages=""
347375
;;
348376
*)
349377
printf "Unknown OS grade: $1\\n"
@@ -355,7 +383,6 @@ parse_args() {
355383
--unstable | -U)
356384
shift
357385
unstable='unstable'
358-
virtualmin_stack_custom_packages=""
359386
;;
360387
--extra | -E)
361388
shift
@@ -377,6 +404,16 @@ parse_args() {
377404
add_config_excludes "$1"
378405
shift
379406
;;
407+
--include | -i)
408+
shift
409+
if [ -z "$1" ] || [ "${1#-}" != "$1" ]; then
410+
printf "Missing value for include flag\\n"
411+
bind_hook "usage"
412+
exit 1
413+
fi
414+
add_config_includes "$1"
415+
shift
416+
;;
380417
--module | -o)
381418
shift
382419
module_name=$1
@@ -2021,7 +2058,7 @@ if [ "$mode" = "mini" ]; then
20212058
bundle="Mini${bundle}"
20222059
fi
20232060
# shellcheck disable=SC2086
2024-
virtualmin-config-system --bundle "$bundle" $config_excludes --log "$log"
2061+
virtualmin-config-system --bundle "$bundle" $config_excludes $config_includes --log "$log"
20252062
if [ "$?" != "0" ]; then
20262063
errorlist="${errorlist} ${YELLOW}${NORMAL} Postinstall configuration returned an error.\\n"
20272064
errors=$((errors + 1))

0 commit comments

Comments
 (0)