src.dualinventive.com/dinet/common/cmake/templates/debian/postinst.in

63 lines
1.2 KiB
Bash

#!/bin/sh
set -eu
USER="di"
GROUP="${USER}"
CONFFILE="/etc/di/@CPACK_PROJECT_APP_NAME@.conf"
case "${1}" in
configure)
if ! id -u ${USER} > /dev/null 2>&1; then
adduser \
--disabled-password \
--home /var/lib/di \
--quiet \
--system \
--group \
${USER}
fi
for DIR in /var/lib/di /var/log/di /var/run/di
do
mkdir -p ${DIR}
chown -R ${USER}:${GROUP} ${DIR}
done
chgrp root /var/log/di
if ! dpkg-statoverride --list ${CONFFILE} >/dev/null 2>&1
then
dpkg-statoverride --update --add ${USER} ${GROUP} 644 ${CONFFILE}
fi
@CPACK_DEBIAN_INSTALL_POSTINST_EXTRA@
if [ "@PROJECT_APP_NAME@" != "" ]; then
if [ -x /bin/systemctl ]; then
systemctl daemon-reload >/dev/null 2>&1 || true
if [ -e /lib/systemd/system/@PROJECT_APP_NAME@-db.service ]; then
systemctl enable @PROJECT_APP_NAME@-db >/dev/null 2>&1 || true
systemctl start @PROJECT_APP_NAME@-db >/dev/null 2>&1 || true
fi
systemctl enable @PROJECT_APP_NAME@ >/dev/null 2>&1 || true
systemctl start @PROJECT_APP_NAME@ >/dev/null 2>&1 || true
fi
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`${1}'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0