blob: d2a4b77355fc722e376c92cc1904dd2f03f5f6b1 (
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
45
46
47
48
49
50
51
52
53
|
setup_user() {
/usr/bin/getent group sa-milt >/dev/null || (/usr/bin/groupadd -r sa-milt && echo "Added sa-milt group")
/usr/bin/getent passwd sa-milt >/dev/null || \
(/usr/bin/useradd -r -g sa-milt -d /var/lib/spamass-milter \
-s /usr/bin/nologin -c "SpamAssassin Milter" sa-milt && echo "Added sa-milt user")
# Fix homedir for upgrades
/usr/bin/usermod --home /var/lib/spamass-milter sa-milt &>/dev/null
# This is needed because the milter needs to "give away" the MTA communication
# socket to the postfix group, and it needs to be a member of the group to do
# that.
# (Adds sa-milt user to postfix group if postfix group exists)
/usr/bin/getent group postfix >/dev/null && /usr/bin/usermod -a -G postfix sa-milt
}
# arg 1: the new package version
post_install() {
setup_user
systemctl daemon-reload
systemd-tmpfiles --create /usr/lib/tmpfiles.d/spamass-milter.conf
systemd-tmpfiles --create /usr/lib/tmpfiles.d/spamass-milter-postfix.conf
echo "Use the systemd unit spamass-milter.service or spamass-milter-root.service depending on your needs."
}
# arg 1: the new package version
# arg 2: the old package version
post_upgrade() {
setup_user
systemctl daemon-reload
systemd-tmpfiles --create /usr/lib/tmpfiles.d/spamass-milter.conf
systemd-tmpfiles --create /usr/lib/tmpfiles.d/spamass-milter-postfix.conf
systemctl try-restart spamass-milter.service
systemctl try-restart spamass-milter-root.service
}
# arg 1: the old package version
pre_remove() {
echo "Stopping and disabling spamass-milter service(s)"
systemctl disable spamass-milter.service
systemctl disable spamass-milter-root.service
systemctl stop spamass-milter.service
systemctl stop spamass-milter-root.service
}
# arg 1: the old package version
post_remove() {
systemctl daemon-reload
/usr/bin/userdel sa-milt && echo "Removed sa-milt user"
# Since sa-milt should be the only user in the sa-milt group, by default removing the user will also remove the group. But we add this extra check just in case.
/usr/bin/getent group sa-milt >/dev/null || (/usr/bin/groupdel sa-milt && echo "Removed sa-milt group")
}
# vim:set ts=2 sw=2 et:
|