summaryrefslogtreecommitdiffstats
path: root/content/opt/davmail/entrypoint.sh
blob: 65555034013697e5ec4f856d93247b5fe12450e7 (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

if [ -z "$DAVMAIL_SSL_PASS" ] || [ ! -s /etc/davmail/davmail.p12 ]

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