Skip to content

Commit c4aad1b

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
server: allow passing long-options args to packages script
I start to lose track of things and find it difficult to extend the CLI of the script when using positional-only arguments. Create a simplistic long-options style of passing arguments to the install-packages.sh script. Signed-off-by: John Mulligan <[email protected]>
1 parent b54fbf2 commit c4aad1b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

images/server/install-packages.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,27 @@ get_ceph_shaman_repo() {
7373
cat "/etc/yum.repos.d/ceph-${ceph_ref}.repo"
7474
}
7575

76-
install_packages_from="$1"
77-
samba_version_suffix="$2"
78-
install_custom_repo="$3"
79-
package_selection="$4"
76+
if [[ "$1" =~ ^--.+$ ]]; then
77+
# named (activated if first arg starts with `--`
78+
for arg in "$@"; do
79+
case "$arg" in
80+
--install-packages-from=*) install_packages_from="${arg/*=/}" ;;
81+
--samba-version-suffix=*) samba_version_suffix="${arg/*=/}" ;;
82+
--install-custom-repo=*) install_custom_repo="${arg/*=/}" ;;
83+
--package-selection=*) package_selection="${arg/*=/}" ;;
84+
*)
85+
echo "error: unexpected argument: ${arg}"
86+
exit 2
87+
;;
88+
esac
89+
done
90+
else
91+
# legacy positional only
92+
install_packages_from="$1"
93+
samba_version_suffix="$2"
94+
install_custom_repo="$3"
95+
package_selection="$4"
96+
fi
8097

8198
# shellcheck disable=SC1091
8299
OS_BASE="$(. /etc/os-release && echo "${ID}")"

0 commit comments

Comments
 (0)