summaryrefslogtreecommitdiffstats
path: root/content/opt/davmail/entrypoint.sh
blob: 150cb498435647bafb0c231503fc31547b54aa1b (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=$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

unset DAVMAIL_SSL_PASS

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