Repository navigation
Expand file tree
/
Copy pathshell.sh
More file actions
executable file
·84 lines (76 loc) · 2.3 KB
/
Copy pathshell.sh
File metadata and controls
executable file
·84 lines (76 loc) · 2.3 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env sh
set -e
CONTAINER=gdcn-local-bootstrap
usage() {
echo "Usage: $0 {up|stop|rm}"
exit 1
}
cmd="${1:-}"
if [ -z "$cmd" ]; then
usage
fi
case "$cmd" in
up)
# If the bootstrap container already exists just (re)attach to it
if docker container inspect "$CONTAINER" >/dev/null 2>&1; then
echo "Found existing container: $CONTAINER"
# Start it if it's not running
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER")" != "true" ]; then
echo "Starting container $CONTAINER ..."
docker start "$CONTAINER"
fi
echo "Attaching to $CONTAINER ..."
docker exec -it "$CONTAINER" bash -c "./permissions.sh"
docker exec -it "$CONTAINER" bash
exit 0
fi
# Build the base image
docker build -t gdcn-local-base:latest .
# Create a fresh bootstrap container and run cluster setup
docker run -d --privileged --init \
--name $CONTAINER \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)/setup":/workspace -w /workspace \
-e HOST_PWD="$(pwd)" \
--add-host=host.docker.internal:host-gateway \
gdcn-local-base:latest \
bash -c "sleep infinity"
docker exec -it "$CONTAINER" bash -c "./permissions.sh"
docker exec -it "$CONTAINER" bash
;;
stop)
if docker container inspect "$CONTAINER" >/dev/null 2>&1; then
if [ "$(docker inspect -f '{{.State.Running}}' "$CONTAINER" 2>/dev/null)" = "true" ]; then
echo "Stopping '$CONTAINER'..."
docker stop "$CONTAINER" >/dev/null
echo "Container '$CONTAINER' stopped."
else
echo "Container '$CONTAINER' is not running."
fi
else
echo "Container '$CONTAINER' does not exist."
fi
;;
rm)
echo "This will stop and remove the bootstrap container '$CONTAINER'."
printf "Are you sure you want to continue? [y/N]: "
read -r confirm
case "$confirm" in
[yY][eE][sS] | [yY])
if docker container inspect "$CONTAINER" >/dev/null 2>&1; then
echo "Stopping and removing '$CONTAINER'..."
docker rm -f "$CONTAINER"
echo "Container '$CONTAINER' removed."
else
echo "Container '$CONTAINER' does not exist."
fi
;;
*)
echo "Aborted."
;;
esac
;;
*)
usage
;;
esac