-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_volume.sh
executable file
·46 lines (39 loc) · 1.08 KB
/
create_volume.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
#!/bin/sh
# Construct and fill volumes needed by the ANMS compose config.
# Use:
# ./create_volume {optional tls file source path}
#
set -e
# Full name of the volume
VOLNAME=ammos-tls
# Directory to which the volume is mounted, and from which files are copied
VOLPATH=/ammos/etc/pki/tls
SRCPATH=$1
if [ -z "${SRCPATH}" ]
then
SRCPATH=$VOLPATH
fi
# Determine base command (docker or podman)
if [ -n "$DOCKER_CMD" ]; then
echo "Using defined DOCKER_CMD=${DOCKER_CMD}"
elif command -v podman &> /dev/null; then
echo "Podman is installed"
DOCKER_CMD="podman"
elif command -v docker &> /dev/null; then
echo "Docker is installed"
DOCKER_CMD="docker"
else
echo "Neither Docker nor Podman is installed"
exit 1
fi
${DOCKER_CMD} volume create ${VOLNAME}
CTRNAME=$(${DOCKER_CMD} run --detach --rm \
-v ${VOLNAME}:${VOLPATH} -it \
docker.io/redhat/ubi9 tail -f /dev/null)
${DOCKER_CMD} exec ${CTRNAME} rm -rf ${VOLPATH}/*
for FN in ${SRCPATH}/*
do
echo "Copying from ${FN}"
${DOCKER_CMD} cp ${FN} ${CTRNAME}:${VOLPATH}/
done
${DOCKER_CMD} stop ${CTRNAME} >/dev/null