source: trunk/debathena/config/reactivate/debian/debathena-reactivate.postinst @ 24231

Revision 24231, 3.4 KB checked in by broder, 15 years ago (diff)
In reactivate: * Ignore removal of the CUPS remote queue cache.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2# postinst script for #PACKAGE#
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
21package=debathena-reactivate
22ours=.debathena
23theirs=.debathena-orig
24
25undivert_unlink_symlink()
26{
27    file="$1"
28    ourfile="$2"
29    theirfile="$3"
30    if [ ! -L "$file" ] || \
31        [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
32          "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
33        echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
34    else
35        rm -f "$file"
36    fi
37}
38
39undivert_unlink_divert()
40{
41    file="$1"
42    if [ ! -L "$file" ] && [ ! -e "$file" ]; then
43        dpkg-divert --remove --rename --package "$package" "$file"
44    else
45        echo "Not removing diversion of $file by $package" >&2
46    fi
47}
48
49undivert_unlink()
50{
51    prefix=$1
52    suffix=$2
53
54    file=$prefix$suffix
55    ourfile=$prefix$ours$suffix
56    theirfile=$prefix$theirs$suffix
57
58    undivert_unlink_symlink "$file" "$ourfile" "$theirfile"
59    undivert_unlink_divert "$file" "$package"
60}
61
62cleanup_old_diversion() {
63    file="$1"
64    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then
65        undivert_unlink "$file"
66    fi
67}
68
69
70case "$1" in
71    configure)
72        # Users logging in will be added to several different
73        # groups. Make sure they all exist.
74        for group in $(sed -ne 's/^addgroups="\(.*\)"/\1/p' /etc/gdm/Xsession.debathena); do
75            getent group "$group" >/dev/null || addgroup --system "$group"
76        done
77        cat >>/etc/sudoers <<EOF
78### BEGIN debathena-reactivate
79Defaults lecture_file=/etc/athena/sudo-error, lecture=always
80Defaults:%admin lecture_file=/etc/athena/sudo-warning, lecture=once
81### END debathena-reactivate
82EOF
83
84        if dpkg --compare-versions "$2" lt 1.25.5~ && \
85            dpkg --compare-versions "$2" ge 1.25.2; then
86            ln -nsf su.debathena /etc/pam.d/su
87        fi
88
89        cleanup_old_diversion /etc/gdm/PreSession/Default
90        cleanup_old_diversion /etc/gdm/PostSession/Default
91
92        # Make printing suck less
93        if hash invoke-rc.d >/dev/null 2>&1; then
94            invoke-rc.d cups stop || invoke-rc.d cupsys stop
95        else
96            /etc/init.d/cups stop || /etc/init.d/cupsys stop
97        fi
98        rm -f /var/cache/cups/remote.cache
99        if hash invoke-rc.d >/dev/null 2>&1; then
100            invoke-rc.d cups start || invoke-rc.d cupsys start
101        else
102            /etc/init.d/cups stop || /etc/init.d/cupsys start
103        fi
104
105        browse_host="$(sed -ne '/^BrowsePoll/ { s/^BrowsePoll //p; q }' /etc/cups/cupsd.conf)"
106        if [ -n "$browse_host" ]; then
107            queue_count=$(lpstat -h "$browse_host" -a | wc -l)
108            while [ $(lpstat -a | wc -l) -lt $queue_count ]; do
109                sleep 1
110            done
111        fi
112    ;;
113
114    abort-upgrade|abort-remove|abort-deconfigure)
115    ;;
116
117    *)
118        echo "postinst called with unknown argument \`$1'" >&2
119        exit 1
120    ;;
121esac
122
123# dh_installdeb will replace this with shell code automatically
124# generated by other debhelper scripts.
125
126#DEBHELPER#
127
128exit 0
129
130
Note: See TracBrowser for help on using the repository browser.