-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-certs.sh
More file actions
executable file
·33 lines (26 loc) · 848 Bytes
/
update-certs.sh
File metadata and controls
executable file
·33 lines (26 loc) · 848 Bytes
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
#!/bin/bash
if [[ ! -f .env ]]; then
echo "Missing required .env file, refer to README.md."
exit 1
fi
source .env
if [[ "${EXTERNAL_HOSTNAME}" == "" ]]; then
echo ".env file missing EXTERNAL_HOSTNAME"
exit 1
fi
if [[ "${DOCKER_HTTP_PORT}" == "" ]]; then
echo ".env file missing DOCKER_HTTP_PORT"
exit 1
fi
CERT_DIR=./data/certs
mkdir -p "$CERT_DIR"
sudo certbot certonly --standalone --keep \
-d "$EXTERNAL_HOSTNAME" \
--http-01-port "$DOCKER_HTTP_PORT" || exit $?
sudo cp "/etc/letsencrypt/live/$EXTERNAL_HOSTNAME/cert.pem" \
"/etc/letsencrypt/live/$EXTERNAL_HOSTNAME/privkey.pem" \
"$CERT_DIR" || exit $?
sudo chown -R `id -u`:`id -g` "$CERT_DIR" || exit $?
sudo chmod 700 "$CERT_DIR" || exit $?
sudo chmod 600 "$CERT_DIR/cert.pem" "$CERT_DIR/privkey.pem" || exit $?
echo "Certificates copied to $CERT_DIR"