56 lines
2.0 KiB
Bash
56 lines
2.0 KiB
Bash
#!/usr/bin/sh
|
|
|
|
set -e
|
|
set -u
|
|
|
|
if [ -d '/run/systemd/system' ]; then
|
|
/usr/bin/systemctl --system daemon-reload > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
fi
|
|
|
|
case "${1}" in
|
|
configure)
|
|
if [ -x '/usr/bin/deb-systemd-helper' ]; then
|
|
/usr/bin/deb-systemd-helper unmask 'stalwart.service' > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
fi
|
|
if /usr/bin/deb-systemd-helper --quiet was-enabled 'stalwart.service'; then
|
|
/usr/bin/deb-systemd-helper enable 'stalwart.service' > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
else
|
|
/usr/bin/deb-systemd-helper update-state 'stalwart.service' > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
fi
|
|
if [ -x '/etc/init.d/stalwart' ]; then
|
|
/usr/sbin/update-rc.d 'stalwart' defaults > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
fi
|
|
/usr/bin/install --directory --group='stalwart' --mode='750' --owner='stalwart' '/var/lib/stalwart'
|
|
/usr/bin/install --directory --group='stalwart' --mode='750' --owner='stalwart' '/var/log/stalwart'
|
|
/usr/bin/install --directory --group='stalwart' --mode='750' --owner='stalwart' '/var/logrotate/stalwart'
|
|
if ! /usr/bin/grep --quiet "secret =" '/etc/stalwart.toml'; then
|
|
PASSWORD=$(/usr/bin/openssl rand -base64 '18')
|
|
PASSWORD_SHA512=$(/usr/bin/echo "${PASSWORD}" | /usr/bin/openssl passwd -noverify -stdin -quiet -6)
|
|
/usr/bin/echo "secret = \"${PASSWORD_SHA512}\"" >> '/etc/stalwart.toml'
|
|
/usr/bin/chown 'stalwart' '/etc/stalwart.toml'
|
|
/usr/bin/echo '##'
|
|
/usr/bin/echo '##'
|
|
/usr/bin/echo '## User: root '
|
|
/usr/bin/echo "## Password: ${PASSWORD}"
|
|
/usr/bin/echo '##'
|
|
/usr/bin/echo '##'
|
|
fi
|
|
if [ -x '/usr/bin/deb-systemd-invoke' ]; then
|
|
/usr/bin/systemctl --system daemon-reload > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
if [ -n "${2}" ]; then
|
|
_dh_action='restart'
|
|
else
|
|
_dh_action='start'
|
|
fi
|
|
/usr/bin/deb-systemd-invoke "${_dh_action}" 'stalwart.service' > '/dev/null' 2>&1 || \
|
|
/usr/bin/true
|
|
fi
|
|
;;
|
|
esac
|