-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.sh
32 lines (28 loc) · 851 Bytes
/
init.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
#! /bin/sh
init_fn() {
if [ "${DEBUG:-}" = '1' ]; then
set -x
fi
data_dir=/etc/reverse_proxy/data
acme_dir="$data_dir/.acme.sh"
nginx_file="/etc/reverse_proxy/nginx.conf"
acme() {
"$acme_dir/acme.sh" --home "$acme_dir" "$@"
}
if [ ! -d "$data_dir" ]; then
echo "$data_dir does not exist. Did you forget to mount the volume?"
exit 1
fi
cp "$nginx_file" /etc/nginx/conf.d/default.conf || exit 1
# Add the cron job to create the initial certificates
(crontab -l; echo "* * * * * /etc/reverse_proxy/create_certs.sh") | sort -u | crontab -
if [ "${SKIP_RENEW_CERTS:-}" = "1" ]; then
echo "Skipping acme --install-cronjob due to SKIP_RENEW_CERTS"
else
# Add the cron job to renew the certificates
acme --install-cronjob
fi
}
(set -u; init_fn) || exit $?
# Start crond in the background
crond &