~ubuntu-branches/ubuntu/trusty/iscsitarget/trusty

« back to all changes in this revision

Viewing changes to debian/prerm

  • Committer: Colin Watson
  • Date: 2010-08-16 20:59:52 UTC
  • mfrom: (2.1.9 sid)
  • Revision ID: cjwatson@canonical.com-20100816205952-hyytf817ju6wk1bj
merge from Debian 1.4.20.2-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# prerm script for iscsitarget
3
 
#
4
 
# see: dh_installdeb(1)
5
 
 
6
 
set -e
7
 
 
8
 
# summary of how this script can be called:
9
 
#        * <prerm> `remove'
10
 
#        * <old-prerm> `upgrade' <new-version>
11
 
#        * <new-prerm> `failed-upgrade' <old-version>
12
 
#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
13
 
#        * <deconfigured's-prerm> `deconfigure' `in-favour'
14
 
#          <package-being-installed> <version> `removing'
15
 
#          <conflicting-package> <version>
16
 
# for details, see http://www.debian.org/doc/debian-policy/ or
17
 
# the debian-policy package
18
 
 
19
 
 
20
 
case "$1" in
21
 
    remove|upgrade|deconfigure)
22
 
    ;;
23
 
    failed-upgrade)
24
 
        # The iscsitarget init script matching this md5sum will exit non-zero
25
 
        # if the iscsi_trgt module cannot be unloaded, even if the daemon is killed.
26
 
        #
27
 
        # Compounding the issue is the fact that the iscsi_trgt module provided by
28
 
        # the Ubuntu kernel (circa Intrepid) does not unload properly (LP: #278625).
29
 
        #
30
 
        # Newer iscsitarget init scripts should handle this more gracefully.
31
 
        #
32
 
        # This maintainer-script code is intended to stop the iscsi target, and
33
 
        # ignore the module unloading error, and thus allow the upgrade to proceed.
34
 
        if md5sum /etc/init.d/iscsitarget 2>/dev/null | grep -qs "^f0f3eed8e9f7daddb7dcb31004633a16"; then
35
 
                # The old package's init script will succeed in stopping the daemon,
36
 
                # but fail in unloading the module.  Restart the daemon here
37
 
                /etc/init.d/iscsitarget start || true
38
 
                # Now try to stop it, capturing the output
39
 
                RC=0
40
 
                OUT=`/etc/init.d/iscsitarget stop 2>&1` || RC=$?
41
 
                # If the exit code is non-zero, and the error reported is the known
42
 
                # module issue, exit 0
43
 
                if [ "$RC" != "0" ]; then
44
 
                        if echo "$OUT" | grep -qs "Module iscsi_trgt is in use"; then
45
 
                                echo "WARNING: Ignoring the fact that module iscsi_trgt is in use"
46
 
                                exit 0
47
 
                        fi
48
 
                fi
49
 
                exit $RC
50
 
        fi
51
 
    ;;
52
 
    *)
53
 
        echo "prerm called with unknown argument \`$1'" >&2
54
 
        exit 1
55
 
    ;;
56
 
esac
57
 
 
58
 
        
59
 
# dh_installdeb will replace this with shell code automatically
60
 
# generated by other debhelper scripts.
61
 
 
62
 
#DEBHELPER#
63
 
 
64
 
exit 0