summaryrefslogtreecommitdiff
path: root/community/nullmailer/nullmailer.install
diff options
context:
space:
mode:
Diffstat (limited to 'community/nullmailer/nullmailer.install')
-rw-r--r--community/nullmailer/nullmailer.install44
1 files changed, 44 insertions, 0 deletions
diff --git a/community/nullmailer/nullmailer.install b/community/nullmailer/nullmailer.install
new file mode 100644
index 000000000..823df6e27
--- /dev/null
+++ b/community/nullmailer/nullmailer.install
@@ -0,0 +1,44 @@
+# 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
+}