source: trunk/debathena/config/cluster-login-config/debian/debathena-cluster-login-config.postinst @ 25754

Revision 25754, 4.1 KB checked in by jdreed, 12 years ago (diff)
In cluster-login-config: * Stop scribbling over sudoers and use sudoers.d (Trac: #1219)
Line 
1#!/bin/sh
2# postinst script for debathena-cluster-login-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-cluster-login-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
71rm_conffile() {
72    local PKGNAME="$1" # Unused
73    local CONFFILE="$2"
74    if [ -f "$CONFFILE".dpkg-del ]; then
75        rm -f "$CONFFILE".dpkg-del
76    fi
77}
78
79case "$1" in
80    configure)
81        gdm_version="$(dpkg-query -W -f '${Version}' gdm)"
82        if dpkg --compare-versions "$gdm_version" ge '2.25.2~'; then
83            cleanup_old_diversion /etc/gdm/gdm.conf.debathena
84            cleanup_old_diversion /etc/gdm/gdm.conf-custom.debathena
85        fi
86
87        if dpkg --compare-versions "$2" lt 1.24~; then
88            rm_conffile debathena-cluster-login-config "/etc/event.d/ttymsg"
89            rm_conffile debathena-cluster-login-config "/etc/init/ttymsg.conf"
90        fi
91
92        if dpkg --compare-versions "$2" lt '1.36.2~'; then
93            # Cleanup from previous installs
94            # /etc/apt/preferences was frobbed due to (LP:508545)
95            if grep -qxF "Package: libstdc++5" /etc/apt/preferences 2>/dev/null; then
96                rm /etc/apt/preferences
97            fi
98            # Cleanup conffiles
99            rm_conffile debathena-cluster-login-config /etc/apt/sources.list.d/debathena-backports.list
100            rm_conffile debathena-cluster-login-config /etc/apt/preferences.d/debathena-libstdcplusplus.pref
101        fi
102
103        if dpkg --compare-versions "$2" lt 1.35.2~; then
104            update-grub
105        fi
106
107        # Shut down sshd and reload gdm.
108        if hash invoke-rc.d; then
109            invoke-rc.d ssh stop
110            invoke-rc.d gdm reload || true
111        else
112            /etc/init.d/ssh stop
113            /etc/init.d/gdm reload || true
114        fi
115
116        # Make sure the gettys are running
117        initctl stop ttymsg >/dev/null 2>&1 || true
118        for i in $(seq 1 6); do
119            initctl stop "tty$i" >/dev/null 2>&1 || true
120            initctl start "tty$i" >/dev/null 2>&1 || true
121        done
122
123        # Configure dns-nameservers if they're not there
124        if ! egrep -q '^[[:space:]]+dns-nameservers' /etc/network/interfaces; then
125            echo '  dns-nameservers 18.70.0.160 18.71.0.151 18.72.0.3' >>/etc/network/interfaces
126            /usr/share/update-notifier/notify-reboot-required
127        fi
128
129        # Attempt to initially set the root password.
130        /usr/sbin/athena-root-password
131
132        # Files in sudoers.d must be chmod 0440 and not contain . or ~
133        # Sadly, dh_installsudoers is not a thing.
134        chmod 0440 /etc/sudoers.d/debathena-cluster-login-config-sudoers
135
136        exit 0
137    ;;
138
139    abort-upgrade|abort-remove|abort-deconfigure)
140    ;;
141
142    *)
143        echo "postinst called with unknown argument \`$1'" >&2
144        exit 1
145    ;;
146esac
Note: See TracBrowser for help on using the repository browser.