diff --git a/.github/workflows/ca-clone-secure-ds-test.yml b/.github/workflows/ca-clone-secure-ds-test.yml index 97cbd58c4ef..2c97c35ff05 100644 --- a/.github/workflows/ca-clone-secure-ds-test.yml +++ b/.github/workflows/ca-clone-secure-ds-test.yml @@ -96,7 +96,10 @@ jobs: -n Server-Cert docker cp primary:ds_server.p12 primaryds_server.p12 tests/bin/ds-container-certs-import.sh primaryds primaryds_server.p12 - tests/bin/ds-container-stop.sh primaryds + + tests/bin/ds-stop.sh \ + --image=pki-runner \ + primaryds tests/bin/ds-start.sh \ --image=pki-runner \ @@ -205,7 +208,10 @@ jobs: -n Server-Cert docker cp secondary:ds_server.p12 secondaryds_server.p12 tests/bin/ds-container-certs-import.sh secondaryds secondaryds_server.p12 - tests/bin/ds-container-stop.sh secondaryds + + tests/bin/ds-stop.sh \ + --image=pki-runner \ + secondaryds tests/bin/ds-start.sh \ --image=pki-runner \ diff --git a/.github/workflows/ca-secure-ds-test.yml b/.github/workflows/ca-secure-ds-test.yml index cd3bfee313c..89eb2172097 100644 --- a/.github/workflows/ca-secure-ds-test.yml +++ b/.github/workflows/ca-secure-ds-test.yml @@ -95,7 +95,10 @@ jobs: -n Server-Cert docker cp pki:ds_server.p12 ds_server.p12 tests/bin/ds-container-certs-import.sh ds ds_server.p12 - tests/bin/ds-container-stop.sh ds + + tests/bin/ds-stop.sh \ + --image=pki-runner \ + ds tests/bin/ds-start.sh \ --image=pki-runner \ diff --git a/tests/bin/ds-container-stop.sh b/tests/bin/ds-container-stop.sh deleted file mode 100755 index fb5ac728fee..00000000000 --- a/tests/bin/ds-container-stop.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -e - -# https://fy.blackhats.net.au/blog/html/2020/03/28/389ds_in_containers.html - -NAME=$1 - -if [ "$NAME" == "" ] -then - echo "Usage: ds-container-stop.sh " - exit 1 -fi - -echo "Stopping DS container" - -if [ "$IMAGE" == "" ] -then - docker exec $NAME dsctl localhost stop -else - docker stop $NAME > /dev/null -fi - -echo "DS container is stopped" diff --git a/tests/bin/ds-stop.sh b/tests/bin/ds-stop.sh new file mode 100755 index 00000000000..8fa92427287 --- /dev/null +++ b/tests/bin/ds-stop.sh @@ -0,0 +1,89 @@ +#!/bin/bash -e + +# https://fy.blackhats.net.au/blog/html/2020/03/28/389ds_in_containers.html + +SCRIPT_PATH=$(readlink -f "$0") +SCRIPT_NAME=$(basename "$SCRIPT_PATH") +SCRIPT_DIR=$(dirname "$SCRIPT_PATH") + +VERBOSE= +DEBUG= + +usage() { + echo "Usage: $SCRIPT_NAME [OPTIONS] " + echo + echo "Options:" + echo " --image= Container image (default: quay.io/389ds/dirsrv)" + echo " -v,--verbose Run in verbose mode." + echo " --debug Run in debug mode." + echo " --help Show help message." +} + +while getopts v-: arg ; do + case $arg in + v) + VERBOSE=true + ;; + -) + LONG_OPTARG="${OPTARG#*=}" + + case $OPTARG in + image=?*) + IMAGE="$LONG_OPTARG" + ;; + verbose) + VERBOSE=true + ;; + debug) + VERBOSE=true + DEBUG=true + ;; + help) + usage + exit + ;; + '') + break # "--" terminates argument processing + ;; + image*) + echo "ERROR: Missing argument for --$OPTARG option" >&2 + exit 1 + ;; + *) + echo "ERROR: Illegal option --$OPTARG" >&2 + exit 1 + ;; + esac + ;; + \?) + exit 1 # getopts already reported the illegal option + ;; + esac +done + +# remove parsed options and args from $@ list +shift $((OPTIND-1)) + +NAME=$1 + +if [ "$NAME" == "" ] +then + echo "ERROR: Missing container name" + exit 1 +fi + +if [ "$IMAGE" = "" ] +then + IMAGE=quay.io/389ds/dirsrv +fi + +echo "Stopping DS container" + +if [ "$IMAGE" == "pki-runner" ] +then + docker exec $NAME dsctl localhost stop +else + docker stop $NAME > /dev/null +fi + +echo "DS container is stopped"