source: trunk/debathena/config/cluster-cups-config/debian/postinst @ 24838

Revision 24838, 2.0 KB checked in by geofft, 14 years ago (diff)
In cluster-cups-config: * Also do something useful with the printers.conf and classes.conf files, and bail in the postinst/prerm if we can't stop CUPS while attempting to do said useful thing. In cupsys-config: other stuff while cups is down (or if we're not restarting it)
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
21# dh_installdeb will replace this with shell code automatically
22# generated by other debhelper scripts.
23
24#DEBHELPER#
25
26. /usr/lib/debathena-cupsys-config/restart-cups.sh
27
28restart_cups_extra()
29{
30    # CUPS needs to not be running while we do this.
31    if [ "$1" -gt 0 ]; then
32        echo "CUPS is running and cannot be stopped automatically!" >&2
33        echo "Please shut down CUPS and retry configuring this package." >&2
34        return 1
35    fi
36
37    # Make a directory to back up the old printers/classes.conf if we
38    # haven't previously done so.
39    if ! [ -e /etc/cups/debathena-cluster-cups-config-saved ]; then
40        mkdir /etc/cups/debathena-cluster-cups-config-saved
41        for file in printers.conf printers.conf.O classes.conf classes.conf.O; do
42            if [ -e /etc/cups/"$file" ]; then
43                mv /etc/cups/"$file" /etc/cups/debathena-cluster-cups-config-saved
44            fi
45        done
46    fi
47    # However, unconditionally copy printers.conf and classes.conf so we
48    # pick up changes in them.
49    cp /usr/share/debathena-cluster-cups-config/printers.conf /etc/cups
50    cp /usr/share/debathena-cluster-cups-config/classes.conf /etc/cups
51}
52
53case "$1" in
54    configure)
55        restart_cups
56    ;;
57
58    abort-upgrade|abort-remove|abort-deconfigure)
59    ;;
60
61    *)
62        echo "postinst called with unknown argument \`$1'" >&2
63        exit 1
64    ;;
65esac
66
67exit 0
Note: See TracBrowser for help on using the repository browser.