updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / logcheck / logcheck.install
blobd64a5d6c86973cdcdffed957263776731f54b530
1 # arg 1:  the new package version
2 post_install() {
4     # check for logcheck group in case account exists without group
5     if ! getent group logcheck >/dev/null; then
6         groupadd logcheck
7     fi
9     # Add logcheck user
10     # check for logcheck user or bad version without home
11     if ! getent passwd logcheck > /dev/null; then
12         useradd --home /var/log/logcheck -g logcheck --groups log,adm logcheck || true
13     fi
15     # give logcheck system user a real name unless it has one.
16     if [ -z "$(getent passwd logcheck | cut -d: -f5)" ]; then
17         chfn -f 'logcheck system account' logcheck
18     fi
20     # make sure the home directory exists
21     if [ ! -d "$(getent passwd logcheck | cut -d: -f6)" ]; then
22         usermod -d /var/lib/logcheck logcheck > /dev/null || true
23     fi
25     # add logcheck to /etc/aliases
26     if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
27         if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then
28             echo "logcheck: root" >> /etc/aliases
29             test -x "$(command -v newaliases)" && newaliases || :
30         fi
31     fi
33     # add logcheck to /etc/postfix/aliases
34     aliases="/etc/postfix/aliases"
35     if [ -f $aliases ] || [ -L $aliases ]; then
36         if ! grep -qi "^logcheck[[:space:]]*:" $aliases; then
37             echo "logcheck: root" >> $aliases
38             test -x "`command -v newaliases`" && newaliases || :
39         fi
40     fi
42     # permissions
43     chown -R logcheck:logcheck /etc/logcheck /var/lock/logcheck /var/lib/logcheck || true
44     chmod 750 /etc/logcheck
45     chmod 755 /var/lock/logcheck
47     # tell the user how to test it
48     echo ">>> To test your installation run 'logcheck -ot'"
51 # arg 1:  the new package version
52 # arg 2:  the old package version
53 post_upgrade() {
54     post_install $1
55     usermod -G log,adm,logcheck logcheck
58 # arg 1:  the old package version
59 pre_remove() {
60     userdel logcheck &> /dev/null
61     groupdel logcheck &> /dev/null
62     rmdir --ignore-fail-on-non-empty /etc/logcheck/cracking.ignore.d
63     rmdir --ignore-fail-on-non-empty /var/lib/logcheck /var/lock/logcheck
66 op=$1
67 shift
69 $op $*