#!/bin/sh # postinst script for x2gobroker-daemon # # see: dh_installdeb(1) set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package case "$1" in configure) # setup user/group x2gobroker if ! getent group x2gobroker 1>/dev/null; then echo "Creating x2gobroker group." 1>&2 addgroup --system x2gobroker else echo "Group x2gobroker already exists." 1>&2 fi if ! getent passwd x2gobroker 1>/dev/null; then echo "Creating x2gobroker user." 1>&2 adduser --system \ --disabled-password --disabled-login \ --shell /bin/bash --group --home /var/lib/x2gobroker x2gobroker else echo "User x2gobroker already exists." 1>&2 # make sure the home directory exists belongs to x2gobroker:x2gobroker mkdir -p /var/lib/x2gobroker chown x2gobroker:x2gobroker /var/lib/x2gobroker -f # make sure all settings are appropriate if getent passwd x2gobroker | grep /dev/null 1>/dev/null 2>/dev/null; then usermod --home /var/lib/x2gobroker x2gobroker fi if getent passwd x2gobroker | grep /bin/false 1>/dev/null 2>/dev/null; then usermod --shell /bin/bash x2gobroker fi fi # the x2gobroker-daemon needs special permissions on its log directory if ! dpkg-statoverride --list /var/log/x2gobroker 1>/dev/null; then dpkg-statoverride --add --update x2gobroker adm 2750 /var/log/x2gobroker fi mkdir -p /var/log/x2gobroker && chown x2gobroker:adm /var/log/x2gobroker && chmod 2755 /var/log/x2gobroker touch /var/log/x2gobroker/access.log && chown x2gobroker:adm /var/log/x2gobroker/access.log touch /var/log/x2gobroker/broker.log && chown x2gobroker:adm /var/log/x2gobroker/broker.log touch /var/log/x2gobroker/error.log && chown x2gobroker:adm /var/log/x2gobroker/error.log ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" 1>&2 exit 1 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. # Automatically added by dh_systemd_enable/13.11.4 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 'x2gobroker-daemon.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'x2gobroker-daemon.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'x2gobroker-daemon.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 'x2gobroker-daemon.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installinit/13.11.4 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -z "${DPKG_ROOT:-}" ] && [ -x "/etc/init.d/x2gobroker-daemon" ]; then update-rc.d x2gobroker-daemon defaults >/dev/null if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi invoke-rc.d x2gobroker-daemon $_dh_action || exit 1 fi fi # End automatically added section exit 0