#!/bin/sh set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # case "$1" in configure) # Ensure the logcheck user exists if ! getent passwd logcheck > /dev/null; then adduser --quiet --system --home /var/lib/logcheck --no-create-home \ --group logcheck || true # touch cron job to fix #284788 touch /etc/cron.d/logcheck || true fi # Ensure the logcheck group exists (the user could have been created without a group) if ! getent group logcheck > /dev/null; then addgroup --system logcheck usermod -g logcheck logcheck fi # Ensure the logcheck user's home directory exists if [ ! -d "$(getent passwd logcheck | cut -d: -f6)" ]; then usermod -d /var/lib/logcheck logcheck > /dev/null || true fi # Ensure logcheck is in the adm group if ! getent group adm | grep logcheck > /dev/null; then adduser --quiet logcheck adm || true fi # Ensure the logcheck user has a 'real name' if [ -z "$(getent passwd logcheck | cut -d: -f5)" ]; then chfn -f 'logcheck system account' logcheck fi # add logcheck to /etc/aliases (on install; not on upgrade) if [ -z "${2-}" ]; then if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then echo "logcheck: root" >> /etc/aliases if [ -x "$(command -v newaliases)" ]; then newaliases || : fi fi fi fi # revert previous behaviour of changing perms + group of contents # of /etc/logcheck - this avoids the piuparts error on 'install # (from bullseye)+upgrade (to bookworm)+purge' when other packages # have installed rules. The next two lines can be removed once # bookworm is stable. chown -R root:root /etc/logcheck chmod -R a-sx,u=rwX,go=rX /etc/logcheck # Restrict /var/lib/logcheck and /etc/logcheck for f in /var/lib/logcheck /etc/logcheck; do chown logcheck:logcheck "$f" || true chmod u=rwx,g=rx,o= "$f" || true # drwxr-x--- done ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 1 ;; esac exit 0