added short options
parent
dc16660e00
commit
8f3e5f14c7
66
setup.sh
66
setup.sh
|
|
@ -3,41 +3,75 @@
|
||||||
# Author : NTT Data AG
|
# Author : NTT Data AG
|
||||||
# Date : 11-05-2023
|
# Date : 11-05-2023
|
||||||
|
|
||||||
show_help() {
|
|
||||||
echo "Usage: $0 [-m <boolean>] [-a <app_name>]"
|
|
||||||
echo "Options:"
|
|
||||||
echo " -m <boolean> Install helm"
|
|
||||||
echo " -a <app_name> Specify the app name"
|
|
||||||
}
|
|
||||||
|
|
||||||
helm_install=false
|
helm_install=false
|
||||||
app_name=""
|
app_name=""
|
||||||
|
|
||||||
while getopts "hm:a:" option; do
|
# fetch helm resources
|
||||||
case $option in
|
# docs: https://helm.sh/docs/intro/install/
|
||||||
h)
|
install_helm () {
|
||||||
|
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||||||
|
chmod 700 get_helm.sh
|
||||||
|
./get_helm.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $0 [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show help information
|
||||||
|
-m, --helm Install Helm
|
||||||
|
-a, --app <app_name> Specify the app name
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
show_help
|
show_help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
m)
|
-m|--helm)
|
||||||
helm_install="$OPTARG"
|
helm_install=true
|
||||||
|
shift
|
||||||
;;
|
;;
|
||||||
a)
|
-a|--app)
|
||||||
app_name="$OPTARG"
|
if [ "$2" ]; then
|
||||||
|
app_name="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
echo "Error: Unrecognized option $1"
|
||||||
show_help
|
show_help
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$helm_install" = "true" ]; then
|
# Check if --helm was set
|
||||||
|
if [ "$helm_install" = true ]; then
|
||||||
echo "Installing helm"
|
echo "Installing helm"
|
||||||
|
# install_helm
|
||||||
|
else
|
||||||
|
echo "Skipping helm"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Validate app names
|
||||||
if [ -z "$app_name" ]; then
|
if [ -z "$app_name" ]; then
|
||||||
echo "Please specify app"
|
echo "Please specify app"
|
||||||
else
|
else
|
||||||
echo "Installing $app_name"
|
case $app_name in
|
||||||
|
"socks_shop")
|
||||||
|
echo "installing sock shop"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Only following apps allowed"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
Loading…
Reference in New Issue