#!/bin/sh set -e TRYTON_USER="tryton" TRYTON_CONFDIR="/etc/tryton" TRYTON_SHAREDIR="/usr/share/tryton-server" TRYTON_CONFFILE="${TRYTON_CONFDIR}/trytond.conf" TRYTON_CONFTEMPLATE="${TRYTON_SHAREDIR}/default/trytond.conf" TRYTON_LOGCONFFILE="${TRYTON_CONFDIR}/trytond_log.conf" TRYTON_LOGCONFTEMPLATE="${TRYTON_SHAREDIR}/default/trytond_log.conf" TRYTON_LOGDIR="/var/log/tryton" TRYTON_HOMEDIR="/var/lib/tryton" # POSIX-compliant shell function to check for the existence of a command # s. developers-reference 6.4 pathfind() { OLDIFS="$IFS" IFS=: for p in $PATH; do if [ -x "$p/$*" ]; then IFS="$OLDIFS" return 0 fi done IFS="$OLDIFS" return 1 } case "${1}" in configure) # Creating system user adduser --home "${TRYTON_HOMEDIR}" --no-create-home --quiet --system --group "${TRYTON_USER}" # Creating home directory (also used for storage of attachments) mkdir -p "${TRYTON_HOMEDIR}" chown "${TRYTON_USER}":"${TRYTON_USER}" "${TRYTON_HOMEDIR}" # Creating log directory mkdir -p "${TRYTON_LOGDIR}" chown "${TRYTON_USER}":adm "${TRYTON_LOGDIR}" # Create the configuration directory, copy configuration defaults # if the target does not exist yet and register the configuration files mkdir -p "${TRYTON_CONFDIR}" if [ ! -e $TRYTON_CONFFILE ]; then cp "${TRYTON_CONFTEMPLATE}" "${TRYTON_CONFFILE}" if pathfind ucf; then ucf --debconf-ok --src-dir "$TRYTON_SHAREDIR/default/" "$TRYTON_CONFTEMPLATE" "$TRYTON_CONFFILE" ucfr --force tryton-server "${TRYTON_CONFFILE}" fi fi if [ ! -e $TRYTON_LOGCONFFILE ]; then cp "${TRYTON_LOGCONFTEMPLATE}" "${TRYTON_LOGCONFFILE}" if pathfind ucf; then ucf --debconf-ok --src-dir "$TRYTON_SHAREDIR/default/" "$TRYTON_LOGCONFTEMPLATE" "$TRYTON_LOGCONFFILE" ucfr --force tryton-server "${TRYTON_LOGCONFFILE}" fi fi # Set ownership and permissions on configuration files: # otherwise trytond uses internal defaults, if it cannot # read the configuration files. for _ITEM in "${TRYTON_CONFFILE}" "${TRYTON_LOGCONFFILE}"; do if ! dpkg-statoverride --list "${_ITEM}" > /dev/null 2>&1 then chown "${TRYTON_USER}":"${TRYTON_USER}" "${_ITEM}" chmod 0440 "${_ITEM}" fi done # Restricting access to home and log directories for security reasons (private information) for _DIRECTORY in "${TRYTON_HOMEDIR}" "${TRYTON_LOGDIR}" do if ! dpkg-statoverride --list "${_DIRECTORY}" > /dev/null 2>&1 then chmod 0750 "${_DIRECTORY}" fi done # Add the tryton user to the ssl-cert group on fresh installs if [ -z "$2" ]; then if getent group ssl-cert > /dev/null 2>&1 then adduser --quiet "${TRYTON_USER}" ssl-cert fi fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`{$1}'" >&2 exit 1 ;; esac # Automatically added by dh_python3 if command -v py3compile >/dev/null 2>&1; then py3compile -p tryton-server fi if command -v pypy3compile >/dev/null 2>&1; then pypy3compile -p tryton-server || true fi # End automatically added section # Automatically added by dh_installinit/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/tryton-server" ]; then update-rc.d tryton-server defaults-disabled >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native tryton-server $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installinit/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/tryton-server-cron" ]; then update-rc.d tryton-server-cron defaults-disabled >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native tryton-server-cron $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installinit/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/tryton-server-worker" ]; then update-rc.d tryton-server-worker defaults-disabled >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d --skip-systemd-native tryton-server-worker $_dh_action || exit 1 fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if deb-systemd-helper debian-installed 'tryton-server.service'; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'tryton-server.service' >/dev/null || true if deb-systemd-helper --quiet was-enabled 'tryton-server.service'; then # Create new symlinks, if any. deb-systemd-helper enable 'tryton-server.service' >/dev/null || true fi fi # Update the statefile to add new symlinks (if any), which need to be cleaned # up on purge. Also remove old symlinks. deb-systemd-helper update-state 'tryton-server.service' >/dev/null || true fi # End automatically added section # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'tryton-server.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'tryton-server.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'tryton-server.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'tryton-server.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'tryton-server.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.11.9 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'tryton-server.service' >/dev/null || true fi fi # End automatically added section exit 0