source: trunk/debathena/config/syslog-config/debian/debathena-syslog-config.postinst @ 24246

Revision 24246, 2.3 KB checked in by broder, 14 years ago (diff)
Update the postinst for dealing with rsyslog.
Line 
1#!/bin/sh
2# postinst script for debathena-syslog-config
3#
4# see: dh_installdeb(1)
5
6set -e
7
8# summary of how this script can be called:
9#        * <postinst> `configure' <most-recently-configured-version>
10#        * <old-postinst> `abort-upgrade' <new version>
11#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12#          <new-version>
13#        * <postinst> `abort-remove'
14#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15#          <failed-install-package> <version> `removing'
16#          <conflicting-package> <version>
17# for details, see http://www.debian.org/doc/debian-policy/ or
18# the debian-policy package
19
20
21#DEBHELPER#
22
23package=debathena-syslog-config
24ours=.debathena
25theirs=.debathena-orig
26
27undivert_unlink_symlink()
28{
29    file="$1"
30    ourfile="$2"
31    theirfile="$3"
32    if [ ! -L "$file" ] || \
33        [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
34          "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
35        echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
36    else
37        rm -f "$file"
38    fi
39}
40
41undivert_unlink_divert()
42{
43    file="$1"
44    if [ ! -L "$file" ] && [ ! -e "$file" ]; then
45        dpkg-divert --remove --rename --package "$package" "$file"
46    else
47        echo "Not removing diversion of $file by $package" >&2
48    fi
49}
50
51undivert_unlink()
52{
53    prefix=$1
54    suffix=$2
55
56    file=$prefix$suffix
57    ourfile=$prefix$ours$suffix
58    theirfile=$prefix$theirs$suffix
59
60    undivert_unlink_symlink "$file" "$ourfile" "$theirfile"
61    undivert_unlink_divert "$file" "$package"
62}
63
64cleanup_old_diversion() {
65    file="$1"
66    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then
67        undivert_unlink "$file"
68    fi
69}
70
71case "$1" in
72    configure)
73        if [ -d /etc/rsyslog.d ]; then
74            cleanup_old_diversion /etc/syslog.conf.debathena
75
76            if hash invoke-rc.d; then
77                invoke-rc.d rsyslog reload
78            else
79                /etc/init.d/rsyslog reload
80            fi
81        else
82            # We're using sysklogd
83            if hash invoke-rc.d; then
84                invoke-rc.d sysklogd restart
85            else
86                /etc/init.d/sysklogd restart
87            fi
88        fi
89    ;;
90
91    abort-upgrade|abort-remove|abort-deconfigure)
92    ;;
93
94    *)
95        echo "postinst called with unknown argument \`$1'" >&2
96        exit 1
97    ;;
98esac
Note: See TracBrowser for help on using the repository browser.