-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathentry.sh
More file actions
executable file
·46 lines (37 loc) · 983 Bytes
/
entry.sh
File metadata and controls
executable file
·46 lines (37 loc) · 983 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
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
# Fail on errors
set -e
[ "${DEBUG:-false}" == 'true' ] && set -x
echo ">> Running entry.sh"
# Defaults
: "${HOSTNAME:=$(hostname)}"
: "${EMAIL_FROM:='cron'}"
: "${EMAIL_TO:='cron'}"
: "${SMTP_HOST:='localhost'}"
: "${SMTP_PORT:='25'}"
: "${SMTP_USER:=''}"
: "${SMTP_PASS:=''}"
# Config checks
[ ! -f "/crontab" ] && echo "Error: crontab must be mounted at /crontab" && exit 128 || true
# Create the crontab
crontab -u cron /crontab
# Configure Mail Sending
cat > /etc/ssmtp/ssmtp.conf << EOF
root=${EMAIL_TO}
mailhub=${SMTP_HOST}:${SMTP_PORT}
hostname=${HOSTNAME}
EOF
# if username / pass set
if [ -n "${SMTP_USER}" ] && [ -n "${SMTP_PASS}" ]; then
{
echo "UseSTARTTLS=Yes"
echo "AuthUser=${SMTP_USER}"
echo "AuthPass=${SMTP_PASS}"
} >> /etc/ssmtp/ssmtp.conf
fi
cat > /etc/ssmtp/revaliases << EOF
root:${EMAIL_FROM}:${SMTP_HOST}:${SMTP_PORT}
cron:${EMAIL_FROM}:${SMTP_HOST}:${SMTP_PORT}
EOF
# Start supervisord
exec "$@"