summaryrefslogtreecommitdiff
path: root/community/nullmailer/nullmailer.install
blob: 823df6e270186ce56566e09bc684d1d88148ca26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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
}