~ubuntu-branches/ubuntu/lucid/selinux/lucid

« back to all changes in this revision

Viewing changes to debian/selinux.prerm

  • Committer: Bazaar Package Importer
  • Author(s): J. Tang
  • Date: 2008-01-29 12:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20080129120000-lo5k9hah75x78n0o
Tags: 0.1
Initial Release.  The package supersedes selinux-basics.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
set -e
 
4
 
 
5
# summary of how this script can be called:
 
6
#        * <prerm> `remove'
 
7
#        * <old-prerm> `upgrade' <new-version>
 
8
#        * <new-prerm> `failed-upgrade' <old-version>
 
9
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
 
10
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
 
11
#          <package-being-installed> <version> `removing'
 
12
#          <conflicting-package> <version>
 
13
# for details, see http://www.debian.org/doc/debian-policy/ or
 
14
# the debian-policy package
 
15
 
 
16
 
 
17
case "$1" in
 
18
    remove|upgrade|deconfigure)
 
19
        /etc/init.d/selinux cancel
 
20
        if [ -e /usr/share/debconf/confmodule ]; then
 
21
            . /usr/share/debconf/confmodule
 
22
            db_get selinux/updategrub || true
 
23
            if [ "x$RET" = xtrue ]; then
 
24
                db_get selinux/grub
 
25
                grub="$RET"
 
26
                defopt_trim=`/bin/grep "^# defoptions" $grub | /bin/sed -r -e 's/# defoptions=(\s+)?//' -e 's/selinux=[01](\s+)?//' -e 's/apparmor.enabled=[01](\s+)?//' -e 's/enforcing=[01](\s+?)//' -e 's/\s+$//'`
 
27
                /bin/cp "$grub" "$grub"~
 
28
 
 
29
                set +e
 
30
                /bin/sed -i -e "s/^# defoptions=.*$/# defoptions=$defopt_trim/" "$grub"
 
31
                if [ $? != 0 ]
 
32
                then
 
33
                        /bin/cp "$grub"~ "$grub"
 
34
                        echo >&2 "Error: Unable to replace defoptions in menu.lst; changes reverted.";
 
35
                        exit 1
 
36
                fi
 
37
                set -e
 
38
 
 
39
                /usr/bin/dpkg-trigger update-grub
 
40
                db_input critical selinux/reboot || true
 
41
            else
 
42
                db_input critical selinux/uninstall || true
 
43
            fi
 
44
            db_go
 
45
        fi
 
46
    ;;
 
47
 
 
48
    failed-upgrade)
 
49
    ;;
 
50
 
 
51
    *)
 
52
        echo "prerm called with unknown argument \`$1'" >&2
 
53
        exit 1
 
54
    ;;
 
55
esac
 
56
 
 
57
# dh_installdeb will replace this with shell code automatically
 
58
# generated by other debhelper scripts.
 
59
 
 
60
#DEBHELPER#
 
61
 
 
62
exit 0
 
63
 
 
64