Skip to content

Commit

Permalink
Rename ds-container-stop.sh to ds-stop.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Aug 9, 2024
1 parent ce10a94 commit c2b4b83
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ca-clone-secure-ds-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ 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 primaryds
- name: Install CA in primary PKI container
Expand Down Expand Up @@ -210,7 +210,7 @@ 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 secondaryds
- name: Install CA in secondary PKI container
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ca-secure-ds-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ 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 ds
- name: Install CA
Expand Down
22 changes: 0 additions & 22 deletions tests/bin/ds-container-stop.sh

This file was deleted.

89 changes: 89 additions & 0 deletions tests/bin/ds-stop.sh
Original file line number Diff line number Diff line change
@@ -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] <name>"
echo
echo "Options:"
echo " --image=<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"

0 comments on commit c2b4b83

Please sign in to comment.