source: trunk/debathena/config/apparmor-config/debian/debathena-apparmor-config.postinst @ 25184

Revision 25184, 2.8 KB checked in by jdreed, 13 years ago (diff)
* Ensure local directory exists * Only do this on releases with dh_apparmor
RevLine 
[24702]1#!/bin/sh
2# postinst script for debathena-apparmor-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
[24709]20# dh_installdeb will replace this with shell code automatically
21# generated by other debhelper scripts.
22
23#DEBHELPER#
24
[24726]25package=debathena-apparmor-config
26ours=.debathena
27theirs=.debathena-orig
28
29undivert_unlink_symlink()
30{
31    file="$1"
32    ourfile="$2"
33    theirfile="$3"
34    if [ ! -L "$file" ] || \
35        [ "$(readlink "$file")" != "$(basename "$ourfile")" -a \
36          "$(readlink "$file")" != "$(basename "$theirfile")" ]; then
37        echo "*** OMINOUS WARNING ***: $file is not linked to either $(basename "$ourfile") or $(basename "$theirfile")" >&2
38    else
39        rm -f "$file"
40    fi
41}
42
43undivert_unlink_divert()
44{
45    file="$1"
46    if [ ! -L "$file" ] && [ ! -e "$file" ]; then
47        dpkg-divert --remove --rename --package "$package" "$file"
48    else
49        echo "Not removing diversion of $file by $package" >&2
50    fi
51}
52
53undivert_unlink()
54{
55    prefix=$1
56    suffix=$2
57
58    file=$prefix$suffix
59    ourfile=$prefix$ours$suffix
60    theirfile=$prefix$theirs$suffix
61
62    undivert_unlink_symlink "$file" "$ourfile" "$theirfile"
63    undivert_unlink_divert "$file" "$package"
64}
65
66cleanup_old_diversion() {
67    file="$1"
68    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${file}${theirs} by ${package}"; then
69        undivert_unlink "$file"
70    fi
71}
72
73cleanup_old_removal() {
74    file="$1"
75    removedfile="$2"
76    if dpkg-divert --list "${file}" | grep -Fxq "diversion of ${file} to ${removedfile} by ${package}"; then
77        undivert_unlink_divert "$file"
78    fi
79}
80
[24702]81case "$1" in
82    configure)
[24726]83        if [ -d /etc/apparmor.d/tunables/home.d ]; then
84            cleanup_old_diversion /etc/apparmor.d/tunables/home
85        fi
86
[25174]87        # Ensure local files exist
[25184]88        if [ -x /usr/bin/dh_apparmor ]; then
89          mkdir -p /etc/apparmor.d/local
90          for f in usr.sbin.cupsd usr.sbin.ntpd; do
91            [ -f "/etc/apparmor.d/local/$f" ] || touch "/etc/apparmor.d/local/$f"
92          done
93        fi
[25174]94
[24703]95        if hash apparmor_status 2>/dev/null && apparmor_status --enabled; then
96            if hash invoke-rc.d 2>/dev/null; then
97                invoke-rc.d apparmor reload
98            else
99                /etc/init.d/apparmor reload
100            fi
[24702]101        fi
102    ;;
103
104    abort-upgrade|abort-remove|abort-deconfigure)
105    ;;
106
107    *)
108        echo "postinst called with unknown argument \`$1'" >&2
109        exit 1
110    ;;
111esac
112
113exit 0
Note: See TracBrowser for help on using the repository browser.