-
Notifications
You must be signed in to change notification settings - Fork 2
/
start.sh
executable file
·42 lines (33 loc) · 1.05 KB
/
start.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
#!/bin/bash
set -e;
HOSTNAME="gnuweeb.org";
CONTAINER_NAME="server-a001-ct";
MYSQL_DATA_DIR="./storage/mysql_data";
KEYS_DIR="./storage/keys";
SSL_KEYS_DIR="./storage/ssl";
DKIM_KEYS_DIR="./storage/dkim";
mkdir -pv "$MYSQL_DATA_DIR";
mkdir -pv "${KEYS_DIR}/ssl";
mkdir -pv "${KEYS_DIR}/dkim";
MYSQL_DATA_DIR="$(readlink -e "${MYSQL_DATA_DIR}")";
KEYS_DIR="$(readlink -e "${KEYS_DIR}")";
CMD="$1";
if [[ "${CMD}" == "force-run" ]]; then
docker rm -f "${CONTAINER_NAME}" || true;
CMD="run";
fi;
if [[ "${CMD}" == "run" ]]; then
docker run \
--name "${CONTAINER_NAME}" \
--privileged \
--hostname "${HOSTNAME}" \
--mount "type=volume,dst=/var/keys,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=${KEYS_DIR}" \
--mount "type=volume,dst=/var/lib/mysql,volume-driver=local,volume-opt=type=none,volume-opt=o=bind,volume-opt=device=${MYSQL_DATA_DIR}" \
--tty \
--interactive \
--detach \
server-a001:latest;
exit 0;
fi;
echo "Unknown command ${CMD}!";
exit 1;