55# Creates namespace, securecodebox-system, and installs the operator.
66# Then installs all possible resources (scanners, demo-apps, hooks).
77#
8- # There exist two modes:
8+ # There exist different modes:
99# Call without parameters to install interactively
1010# Call with --all to install all available resources automatically
1111# Call with --scanners / --demo-apps / --hooks to only install the wanted resources
1616set -euo pipefail
1717shopt -s extglob
1818
19+ USAGE=" Usage: $( basename " $0 " ) [--all] [--scanners] [--hooks] [--demo-apps] [--help|-h]"
20+
1921COLOR_HIGHLIGHT=" \e[35m"
2022COLOR_OK=" \e[32m"
2123COLOR_ERROR=" \e[31m"
@@ -45,12 +47,10 @@ function print() {
4547 fi
4648}
4749
48- # TODO: Separate usage from help.
49- function usage() {
50- local usage
51- usage=" Usage: $( basename " $0 " ) [--all] [--scanners] [--hooks] [--demo-apps] [--help|-h]"
50+ function printHelp() {
5251 local help
5352 help=$( cat << - EOT
53+ $USAGE
5454The installation is interactive if no arguments are provided.
5555
5656Options
@@ -66,13 +66,9 @@ Examples:
6666 install.sh --all Installs the operator in namespace: securecodebox-system and
6767 all resources in namespace: default
6868
69- install.sh --hooks --scanners
70- Installs only operator, scanners and hooks
69+ install.sh --hooks --scanners Installs only operator, scanners and hooks
7170EOT
7271 )
73- print " SecureCodeBox Install Script"
74- print " $usage "
75- print
7672 print " $help "
7773}
7874
@@ -211,8 +207,6 @@ function interactiveInstall() {
211207}
212208
213209function unattendedInstall() {
214-
215-
216210 if [[ $INSTALL_SCANNERS == true ]]; then
217211 print " Starting to install scanners..."
218212 installResources " $BASE_DIR /scanners" " default" True
@@ -258,12 +252,12 @@ function parseArguments() {
258252 shift
259253 ;;
260254 -h|--help)
261- usage
255+ printHelp
262256 exit
263257 ;;
264258 --* ) # unsupported flags
265259 print " Error: Unsupported flag $1 " >&2
266- usage
260+ print " $USAGE "
267261 exit 1
268262 ;;
269263 * ) # preserve positional arguments
@@ -273,6 +267,9 @@ function parseArguments() {
273267 done
274268}
275269
270+ # Main Script:
271+ parseArguments " $@ "
272+
276273print " $COLOR_HIGHLIGHT " " "
277274print " $COLOR_HIGHLIGHT " " _____ _ ____ "
278275print " $COLOR_HIGHLIGHT " " / ____| | | | _ \ "
@@ -282,8 +279,6 @@ print "$COLOR_HIGHLIGHT" " \__ \ __/ (__| |_| | | | __/ |___| (_) | (_| | __/
282279print " $COLOR_HIGHLIGHT " " |___/\___|\___|\__,_|_| \___|\_____\___/ \__,_|\___|____/ \___/_/\_\ "
283280print " $COLOR_HIGHLIGHT " " "
284281
285-
286- parseArguments " $@ "
287282if [[ $INSTALL_INTERACTIVE == true ]]; then
288283 welcomeToInteractiveInstall
289284fi
0 commit comments