-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·40 lines (31 loc) · 1.2 KB
/
entrypoint.sh
File metadata and controls
executable file
·40 lines (31 loc) · 1.2 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
#!/bin/bash
set -e
USERS_FILE="users.txt"
function load_users() {
while read username || [ -n "$username" ]; do
echo -e "Setting up system user ${username}"
adduser "$username" --quiet --disabled-password --shell /usr/sbin/nologin --gecos "" --force-badname || true
password=$(diceware -d-)
echo "$username:$password" | chpasswd || true
done < $USERS_FILE
}
function update_configs() {
if [ "$MY_DOMAIN" == "localhost" ]; then
echo -e "setting cert/key to default for localhost"
export CERT_FILE="/etc/ssl/certs/ssl-cert-snakeoil.pem"
export KEY_FILE="/etc/ssl/private/ssl-cert-snakeoil.key"
envsubst '\$MY_DOMAIN \$CERT_FILE \$KEY_FILE' < /tmp/main.cf > /etc/postfix/main.cf
else
echo -e "setting cert/key to certbot for ${MY_DOMAIN}"
export CERT_FILE="/etc/letsencrypt/live/${MY_DOMAIN}/fullchain.pem"
export KEY_FILE="/etc/letsencrypt/live/${MY_DOMAIN}/privkey.pem"
envsubst '\$MY_DOMAIN \$CERT_FILE \$KEY_FILE' < /tmp/main.cf > /etc/postfix/main.cf
fi
}
# check if users file exists
if [ -f "$USERS_FILE" ]; then
echo -e "Found users file to process"
load_users
fi
update_configs
exec "$@"