# arg 1: the new package version post_install() { if ! getent passwd nullmail > /dev/null; then echo "==> Creating nullmail user" usr/bin/useradd --comment "nullmailer MTA" --shell /bin/sh --home /var/nullmailer --system --user-group nullmail fi echo "==> Creating trigger fifo" rm -f var/nullmailer/trigger && mkfifo -m 600 var/nullmailer/trigger echo "==> Fixing permissions" chown nullmail var/nullmailer/* chown nullmail usr/bin/nullmailer-queue chmod u+s usr/bin/nullmailer-queue chown nullmail usr/bin/mailq chmod u+s usr/bin/mailq if ! [ -s etc/nullmailer/me ]; then echo "==> Configuring" hostnamectl --static > etc/nullmailer/me fi if ! [ -s etc/nullmailer/remotes ]; then echo "smarthost.example.org smtp --port=25 --auth-login --user=user --pass=pass" > etc/nullmailer/remotes chgrp nullmail etc/nullmailer/remotes chmod 640 etc/nullmailer/remotes fi } # arg 1: the new package version # arg 2: the old package version post_upgrade() { post_install $1 } # arg 1: the old package version pre_remove() { systemctl stop nullmailer # Leave the 'queue' directory intact rm -rf var/service/nullmailer/{tmp,trigger} echo "==> Removing nullmailer user and group" userdel nullmail if getent group nullmail > /dev/null; then groupdel nullmail fi }