summaryrefslogtreecommitdiffstats
path: root/content/opt/davmail/entrypoint.sh
blob: 518bb1dce463a6fbb840510c179bb5a4c279cfd5 (plain)
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
#!/bin/sh -el

[ -z "$*" ] || exec "$@"

CONFIG=${1:-/etc/davmail/davmail.properties}
if [ -n "$DAVMAIL_CONFIG_URL" ]; then
  CONFIG=/tmp/davmail.properties
  wget -qO $CONFIG "$DAVMAIL_CONFIG_URL"
elif [ -n "$DAVMAIL_URL" ]; then
  CONFIG=/tmp/davmail.properties
  while read line; do
    eval echo "$line"
  done < /etc/davmail/davmail.properties.template > $CONFIG
fi

if [ -n "$DAVMAIL_SSL_PASS" ]; then
  if [ ! -r /etc/davmail/davmail.p12 ] || [ ! -s /etc/davmail/davmail.p12 ]; then
    echo "ERROR: can't read ssl keystore [/etc/davmail/davmail.p12]!"
    return 2
  fi
fi

unset DAVMAIL_SSL_PASS

if [ -r "$CONFIG" ]; then
  exec /opt/davmail/davmail "$CONFIG"
else
  echo "ERROR: can't read [$CONFIG]!"
  return 1
fi