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

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

CONFIG=${1:-/etc/davmail/davmail.properties}
if [ -n "$DAVMAIL_CONFIG_URL" ]; then
  CONFIG=$HOME/davmail.properties
  wget -qO $CONFIG "$DAVMAIL_CONFIG_URL"
elif [ -n "$DAVMAIL_URL" ]; then
  CONFIG=$HOME/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

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