| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6adff91 commit 0c113af
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,11 @@ COLOR_RESET="\e[0m" | |||
| 27 | 27 | ||
| 28 | 28 | BASE_DIR=$(dirname "${SCRIPT_DIRECTORY}") | |
| 29 | 29 | ||
| 30 | + INSTALL_INTERACTIVE='' | ||
| 31 | + INSTALL_SCANNERS='' | ||
| 32 | + INSTALL_DEMO_APPS='' | ||
| 33 | + INSTALL_HOOKS='' | ||
| 34 | + | ||
| 30 | 35 | function print() { | |
| 31 | 36 | if [[ $# == 0 ]]; then | |
| 32 | 37 | echo | |
@@ -154,7 +159,7 @@ function installResources() { | |||
| 154 | 159 | print "$COLOR_OK" "Completed to install '$resource_directory'!" | |
| 155 | 160 | } | |
| 156 | 161 | ||
| 157 | - function interactiveInstall() { | ||
| 162 | + function welcomeToInteractiveInstall() { | ||
| 158 | 163 | print "$COLOR_HIGHLIGHT" "Welcome to the secureCodeBox!" | |
| 159 | 164 | print "This interactive installation script will guide you through all the relevant installation steps in order to have you ready to scan." | |
| 160 | 165 | print "Start? [y/N]" | |
@@ -166,11 +171,9 @@ function interactiveInstall() { | |||
| 166 | 171 | else | |
| 167 | 172 | exit | |
| 168 | 173 | fi | |
| 174 | + } | ||
| 169 | 175 | ||
| 170 | - exitIfKubectlIsNotInstalled | ||
| 171 | - exitIfHelmIsNotInstalled | ||
| 172 | - createNamespaceAndInstallOperator | ||
| 173 | - | ||
| 176 | + function interactiveInstall() { | ||
| 174 | 177 | print | |
| 175 | 178 | print "Starting to install scanners..." | |
| 176 | 179 | installResources "$BASE_DIR/scanners" "default" False | |
@@ -205,25 +208,17 @@ function interactiveInstall() { | |||
| 205 | 208 | } | |
| 206 | 209 | ||
| 207 | 210 | function unattendedInstall() { | |
| 208 | - exitIfKubectlIsNotInstalled | ||
| 209 | - exitIfHelmIsNotInstalled | ||
| 210 | - createNamespaceAndInstallOperator | ||
| 211 | - | ||
| 212 | - local install_scanners=$1 | ||
| 213 | - local install_demo_apps=$2 | ||
| 214 | - local install_hooks=$3 | ||
| 215 | - | ||
| 216 | - if [[ $install_scanners == true ]]; then | ||
| 211 | + if [[ -n "${INSTALL_SCANNERS}" ]]; then | ||
| 217 | 212 | print "Starting to install scanners..." | |
| 218 | 213 | installResources "$BASE_DIR/scanners" "default" True | |
| 219 | 214 | fi | |
| 220 | 215 | ||
| 221 | - if [[ $install_demo_apps == true ]]; then | ||
| 216 | + if [[ -n "${INSTALL_DEMO_APPS}" ]]; then | ||
| 222 | 217 | print "Starting to install demo-apps..." | |
| 223 | 218 | installResources "$BASE_DIR/demo-apps" "default" True | |
| 224 | 219 | fi | |
| 225 | 220 | ||
| 226 | - if [[ $install_hooks == true ]]; then | ||
| 221 | + if [[ -n "${INSTALL_HOOKS}" ]]; then | ||
| 227 | 222 | print "Starting to install hooks..." | |
| 228 | 223 | installResources "$BASE_DIR/hooks" "default" True | |
| 229 | 224 | fi | |
@@ -232,36 +227,37 @@ function unattendedInstall() { | |||
| 232 | 227 | } | |
| 233 | 228 | ||
| 234 | 229 | function parseArguments() { | |
| 235 | - local install_scanners=false | ||
| 236 | - local install_demo_apps=false | ||
| 237 | - local install_hooks=false | ||
| 230 | + if [[ $# == 0 ]]; then | ||
| 231 | + INSTALL_INTERACTIVE=true | ||
| 232 | + return | ||
| 233 | + fi | ||
| 238 | 234 | ||
| 239 | 235 | while (( "$#" )); do | |
| 240 | 236 | case "$1" in | |
| 241 | 237 | --scanners) | |
| 242 | - install_scanners=true | ||
| 238 | + INSTALL_SCANNERS='true' | ||
| 243 | 239 | shift # Pop current argument from array | |
| 244 | 240 | ;; | |
| 245 | 241 | --demo-apps) | |
| 246 | - install_demo_apps=true | ||
| 242 | + INSTALL_DEMO_APPS='true' | ||
| 247 | 243 | shift | |
| 248 | 244 | ;; | |
| 249 | 245 | --hooks) | |
| 250 | - install_hooks=true | ||
| 246 | + INSTALL_HOOKS='true' | ||
| 251 | 247 | shift | |
| 252 | 248 | ;; | |
| 253 | 249 | --all) | |
| 254 | - install_scanners=true | ||
| 255 | - install_demo_apps=true | ||
| 256 | - install_hooks=true | ||
| 250 | + INSTALL_SCANNERS='true' | ||
| 251 | + INSTALL_DEMO_APPS='true' | ||
| 252 | + INSTALL_HOOKS='true' | ||
| 257 | 253 | shift | |
| 258 | 254 | ;; | |
| 259 | 255 | -h|--help) | |
| 260 | 256 | usage | |
| 261 | 257 | exit | |
| 262 | 258 | ;; | |
| 263 | 259 | --*) # unsupported flags | |
| 264 | - echo "Error: Unsupported flag $1" >&2 | ||
| 260 | + print "Error: Unsupported flag $1" >&2 | ||
| 265 | 261 | usage | |
| 266 | 262 | exit 1 | |
| 267 | 263 | ;; | |
@@ -270,8 +266,6 @@ function parseArguments() { | |||
| 270 | 266 | ;; | |
| 271 | 267 | esac | |
| 272 | 268 | done | |
| 273 | - | ||
| 274 | - unattendedInstall $install_scanners $install_demo_apps $install_hooks | ||
| 275 | 269 | } | |
| 276 | 270 | ||
| 277 | 271 | print "$COLOR_HIGHLIGHT" " " | |
@@ -284,8 +278,17 @@ print "$COLOR_HIGHLIGHT" " |___/\___|\___|\__,_|_| \___|\_____\___/ \__,_|\___| | |||
| 284 | 278 | print "$COLOR_HIGHLIGHT" " " | |
| 285 | 279 | ||
| 286 | 280 | ||
| 287 | - if [[ $# == 0 ]]; then | ||
| 281 | + parseArguments "$@" | ||
| 282 | + if [[ -n "${INSTALL_INTERACTIVE}" ]]; then | ||
| 283 | + welcomeToInteractiveInstall | ||
| 284 | + fi | ||
| 285 | + | ||
| 286 | + exitIfKubectlIsNotInstalled | ||
| 287 | + exitIfHelmIsNotInstalled | ||
| 288 | + createNamespaceAndInstallOperator | ||
| 289 | + | ||
| 290 | + if [[ -n "${INSTALL_INTERACTIVE}" ]]; then | ||
| 288 | 291 | interactiveInstall | |
| 289 | 292 | else | |
| 290 | - parseArguments "$@" | ||
| 293 | + unattendedInstall | ||
| 291 | 294 | fi | |
| Back | FazBrowse Home | New Git URL |
0 commit comments