forked from OneIdentity/safeguard-bash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·65 lines (53 loc) · 1.68 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
ScriptDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
print_usage()
{
cat <<EOF
USAGE: run.sh -v volume [-h] [args]
-h Show help and exit
-v Directory from host to mount into container at /volume
This is useful for mounting a directory with certificates and private keys
Additional options that will be passed on to 'docker run' command line
before the image specification. Using this run.sh script you cannot
modify the command being run to start the container. You would have to
do that by calling 'docker run' directly.
This script will create an image (if not already created) and run a container
based on that image that listens to A2A for password change events and calls
the generic sample script that prints the current password.
You could easily extend this image using the Dockerfile to run a container that
does something much more interesting in your environment.
EOF
exit 0
}
while getopts ":v:h" opt; do
case $opt in
v)
Volume=$OPTARG
shift; shift;
;;
h)
print_usage
;;
?)
break
;;
esac
done
if test -t 1; then
YELLOW='\033[1;33m'
NC='\033[0m'
fi
if [ -z "$Volume" ]; then
>&2 echo "You must specify a directory to mount using the -v option"
exit 1
fi
# Make sure they have docker installed
if [ ! -z "$(which docker)" ]; then
echo "Rebuilding the image: safeguard-certdemo ..."
$ScriptDir/build.sh
# Run a container based on safeguard-a2ademo and pass additional arguments to it
docker run -v "$Volume:/volume" "$@" -it safeguard-a2ademo
else
>&2 echo "You must install docker to use this script"
exit 1
fi