From 0258c623e68e782f5dc27b25d7f5986ba2149cc7 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 19 Sep 2021 16:53:13 +0200 Subject: [PATCH 1/2] Adding a minio startup script The script makes it easy to run the local minio instance without copy&pasting the instructions from the installation tutorial. It also prints the access and secret key necessary to access the minio instance. Signed-off-by: Sebastian --- bin/minio-port-forward.sh | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 bin/minio-port-forward.sh diff --git a/bin/minio-port-forward.sh b/bin/minio-port-forward.sh new file mode 100755 index 0000000000..14d92b4177 --- /dev/null +++ b/bin/minio-port-forward.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2021 iteratec GmbH +# +# SPDX-License-Identifier: Apache-2.0 +# +# Convenience script to start a local minio instance, where your scanner results and findings are stored by default. +# The instance runs on your localhost at port 9000. +# +# The script (i.e. the port forwarding) must run while you want to access the minio instance. +# However, it does not need to run while scans are executed in order to store the results. +# +# Will also print your access key and secret key. +# +# For more information see +# https://docs.securecodebox.io/docs/getting-started/installation/#accessing-the-included-minio-instance + +set -euo pipefail +shopt -s extglob + +COLOR_EMPHASIS="\e[32m" +COLOR_RESET="\e[0m" + +function print() { + if [[ $# == 0 ]]; then + echo + elif [[ $# == 1 ]]; then + local message="${1}" + echo "${message}" + elif [[ $# == 2 ]]; then + local color="${1}" + local message="${2}" + echo -e "${color}${message}${COLOR_RESET}" + fi +} + +print "$COLOR_EMPHASIS" "Starting minio instance on localhost:9000..\n" + +print "Your access key: " +ACCESS_KEY=$(kubectl get secret securecodebox-operator-minio -n securecodebox-system -o=jsonpath='{.data.accesskey}' \ +| base64 --decode;) +print "$COLOR_EMPHASIS" "$ACCESS_KEY" + +print "Your secret key: " +SECRET_KEY=$(kubectl get secret securecodebox-operator-minio -n securecodebox-system -o=jsonpath='{.data.secretkey}' \ +| base64 --decode;) +print "$COLOR_EMPHASIS" "$SECRET_KEY" + +kubectl port-forward -n securecodebox-system service/securecodebox-operator-minio 9000:9000 From dca7e69e5ebcf385f0103b8093f303e0271ec7af Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 28 Sep 2021 13:02:42 +0200 Subject: [PATCH 2/2] Adding option to set individual port Signed-off-by: Sebastian --- bin/minio-port-forward.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/minio-port-forward.sh b/bin/minio-port-forward.sh index 14d92b4177..2a4483d197 100755 --- a/bin/minio-port-forward.sh +++ b/bin/minio-port-forward.sh @@ -5,7 +5,8 @@ # SPDX-License-Identifier: Apache-2.0 # # Convenience script to start a local minio instance, where your scanner results and findings are stored by default. -# The instance runs on your localhost at port 9000. +# Port can be set via -p option. +# The instance runs on your localhost at your defined port (default: 9000). # # The script (i.e. the port forwarding) must run while you want to access the minio instance. # However, it does not need to run while scans are executed in order to store the results. @@ -20,6 +21,7 @@ shopt -s extglob COLOR_EMPHASIS="\e[32m" COLOR_RESET="\e[0m" +HOST_PORT=9000 # Default port function print() { if [[ $# == 0 ]]; then @@ -34,6 +36,15 @@ function print() { fi } +if [[ "$#" -eq 2 ]]; then + if [[ $1 = "-p" || $1 = "--port" ]]; then + HOST_PORT=$2 + print "Using host port $HOST_PORT" + fi +else + print "No port with option -p set. Using default host port 9000" +fi + print "$COLOR_EMPHASIS" "Starting minio instance on localhost:9000..\n" print "Your access key: " @@ -46,4 +57,4 @@ SECRET_KEY=$(kubectl get secret securecodebox-operator-minio -n securecodebox-sy | base64 --decode;) print "$COLOR_EMPHASIS" "$SECRET_KEY" -kubectl port-forward -n securecodebox-system service/securecodebox-operator-minio 9000:9000 +kubectl port-forward -n securecodebox-system service/securecodebox-operator-minio "$HOST_PORT":9000