#!/bin/sh

if [ -z "$DAVMAIL_SERVER" ];
then
    DAVMAIL_SERVER="yes"
fi

if [ "$DAVMAIL_SERVER" = "yes" ];
then
    server="-server"
fi

# The --add-export argument is a workaround for O356Interactive current
# implementation needing a custom https connection wrapper
exec /usr/bin/java \
    -Xmx512M -Dsun.net.inetaddr.ttl=60 \
    --add-exports java.base/sun.net.www.protocol.https=ALL-UNNAMED \
    -jar /usr/share/davmail/davmail.jar $server "$@"
