File: logcheck.postinst

package info (click to toggle)
logcheck 1.2.39
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,008 kB
  • ctags: 53
  • sloc: sh: 889; python: 158; makefile: 126; perl: 98
file content (99 lines) | stat: -rw-r--r-- 3,318 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
#!/bin/sh

# $Id: logcheck.postinst,v 1.35 2005/04/19 15:54:49 ttroxell 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'.

# Source debconf library.
. /usr/share/debconf/confmodule

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 --no-create-home --group \
	      --home /var/lib/logcheck logcheck || true
	  touch /etc/cron.d/logcheck || true
    	elif dpkg --compare-versions "$2" eq 1.2.19; then
	   usermod -d /var/lib/logcheck logcheck > /dev/null 2>&1 || true
	fi
	# check for logcheck in adm group
	if ! getent group adm | grep logcheck > /dev/null; then
	  adduser --quiet logcheck adm || true
	fi  

	# Remove old directory
	if dpkg --compare-versions "$2" lt "1.1.1-13.2"; then
	    if [ -d /var/cache/logcheck ]; then
		rm -fr /var/cache/logcheck
	    fi
	fi
	# Remove unused old directory
	if dpkg --compare-versions "$2" lt "1.2.25"; then
	    if [ -d /var/state/logcheck ]; then
		rm -fr /var/state/logcheck
	    fi
	fi
        if [ "$2" = "" -a ! -f /etc/logcheck/header.txt ]; then
          cp -p /usr/share/logcheck/header.txt /etc/logcheck
        fi

	if dpkg --compare-versions "$2" lt "1.2.39"; then
          chown -R logcheck:logcheck /var/lock/logcheck || true
        fi

	# This gets executed even if there is no $2.
	if dpkg --compare-versions "$2" lt "1.2.34"; then
    	  # Fix Permissions
    	  chown -R logcheck:logcheck /var/lib/logcheck  || true
          chgrp -R logcheck /etc/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 2>&1 || 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