File: logcheck.postinst

package info (click to toggle)
logcheck 1.2.54
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,372 kB
  • ctags: 54
  • sloc: sh: 872; python: 158; perl: 138; makefile: 136
file content (112 lines) | stat: -rw-r--r-- 3,850 bytes parent folder | download
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh

# $Id: logcheck.postinst,v 1.48 2006/07/04 17:35:14 maks-guest Exp $

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
#     Any necessary prompting should almost always be confined to the
#     post-installation script, and should be protected with a conditional
#     so that unnecessary prompting doesn't happen if a package's
#     installation fails and the `postinst' is called with `abort-upgrade',
#     `abort-remove' or `abort-deconfigure'.

case "$1" in
    configure)
	# Add logcheck user
	# check for logcheck user or bad version without home
	# touch cron job on updating accounts to fix #284788
	if ! getent passwd logcheck > /dev/null; then
	  adduser --quiet --system --home /var/lib/logcheck --no-create-home \
      --group logcheck ||true
	  touch /etc/cron.d/logcheck || true
	fi

  # make sure the home directory exists
  if [ ! -d "$(getent passwd logcheck | cut -d: -f6)" ]; then
    usermod -d /var/lib/logcheck logcheck > /dev/null || true
  fi

	# check for logcheck in adm group
	if ! getent group adm | grep logcheck > /dev/null; then
	  adduser --quiet logcheck adm || true
	fi  

	# add logcheck to /etc/aliases
	if [ -f /etc/aliases ] || [ -L /etc/aliases ]; then
    if ! grep -qi "^logcheck[[:space:]]*:" /etc/aliases; then
      echo "logcheck: root" >> /etc/aliases
      test -x "$(command -v newaliases)" && newaliases || :
    fi
	fi

  # give logcheck system user a real name unless it has one.
  if [ -z "$(getent passwd logcheck | cut -d: -f5)" ]; then
    chfn -f 'logcheck system account' logcheck
  fi

	# Remove unused old directory on upgrade
	if [ -n "$2" ] && dpkg --compare-versions "$2" lt "1.2.25"; then
	    if [ -d /var/state/logcheck ]; then
		rm -fr /var/state/logcheck
	    fi
	fi
	# Add logcheck mail header on install
        if [ ! -n "$2" ] && [ ! -f /etc/logcheck/header.txt ]; then
          cp -p /usr/share/logcheck/header.txt /etc/logcheck
        fi

	# Fix permissions for lock on install or upgrade
	if [ ! -n "$2" ] || dpkg --compare-versions "$2" lt "1.2.39"; then
          chown -R logcheck:logcheck /var/lock/logcheck || true
	  chmod 755 /var/lock/logcheck || true
        fi

	# Unconditionalizing this for now as we have files that are
	# unreadable upon upgrade.  <ttroxell@debian.org>
	chgrp -R logcheck /etc/logcheck || true

    	# Set Permissions on install or upgrade
	if [ ! -n "$2" ] || dpkg --compare-versions "$2" lt "1.2.34"; then
    	  chown -R logcheck:logcheck /var/lib/logcheck  || true
          chmod 2750 /etc/logcheck/ignore.d.paranoid || true
          chmod 2750 /etc/logcheck/ignore.d.workstation || true
          chmod 2750 /etc/logcheck/ignore.d.server || true
          chmod 2750 /etc/logcheck/cracking.d || true
          chmod 2750 /etc/logcheck/cracking.ignore.d || true
          chmod 2750 /etc/logcheck/violations.d || true
          chmod 2750 /etc/logcheck/violations.ignore.d || true
    	  chmod -R g+rX /etc/logcheck || true
          # just in case
          chown logcheck /var/lock/logcheck > /dev/null || true
	fi

	;;
    
    abort-upgrade|abort-remove|abort-deconfigure)
	
	;;
    
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
	;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0