-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·47 lines (40 loc) · 1.17 KB
/
entrypoint.sh
File metadata and controls
executable file
·47 lines (40 loc) · 1.17 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
#!/bin/bash
function initial_config {
env_vars=(
"MAIL_DOMAIN"
"TLS_CERT_FILE"
"TLS_KEY_FILE"
"RELAY_HOST"
)
env_vars_subst=${env_vars[@]/#/$}
postfix_staging_directory=/tmp/postfix_staging
postfix_directory=/etc/postfix
# Check if all required variables have been set
for each in "${env_vars[@]}"; do
if ! [[ -v $each ]]; then
echo "$each has not been set!"
var_unset=true
fi
done
if [ $var_unset ]; then
echo "One or more required variables are unset. You must set them before setup can continue."
exit 1
fi
# Copy postfix config files into place
echo "Preparing configuration files"
cd $postfix_staging_directory
find . -type f -exec sh -c "cat {} | envsubst '$env_vars_subst' > $postfix_directory/{}" \;
# Clean up
cd $postfix_directory
rm -r $postfix_staging_directory
echo 'This file is used by docker to check whether the container has already been configured' > $configured_file
}
configured_file=/etc/docker.configured
if [ -f "$configured_file" ]; then
echo "Starting postfix..."
else
echo "Configuring postfix..."
initial_config
echo "Done. Starting postfix..."
fi
exec /usr/sbin/postfix start-fg