summaryrefslogtreecommitdiff
path: root/debian/mdadm.preinst
blob: b90ffb87ae17220d91009f24bbbf7b80fdc06e10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
# Copyright © martin f. krafft <madduck@debian.org>
# Distributed under the terms of the Artistic Licence 2.0
#
set -e

# based on idea from http://www.dpkg.org/dpkg/ConffileHandling
rm_conffile() {
    local conffile md5sum package old_md5sum

    conffile="$1"
    if [ -e "$conffile" ]; then
        md5sum=$(md5sum "$conffile" | cut -d' ' -f1)
        package=$(dpkg -S "$conffile" | cut -d: -f1)
        old_md5sum=$(dpkg -s $package | sed -rne "s,[[:space:]]+${conffile}[[:space:]]+,,p")
        if [ "$md5sum" != "$old_md5sum" ]; then
            echo "Obsolete conffile $conffile has been modified by you."
            echo "Saving as ${conffile}.dpkg-bak ..."
            mv -f "$conffile" "$conffile".dpkg-bak
        else
            echo "Removing obsolete conffile $conffile ..."
            rm -f "$conffile"
        fi
    fi
}

case "$1" in

  upgrade|install)

    # migrate old configuration from *way back then*
    DEBIANCONFIG=/etc/default/mdadm
    OLDCONFIG=/etc/mdadm/debian.conf
    if [ -s $OLDCONFIG ] && [ ! -f $DEBIANCONFIG ]; then
      mv $OLDCONFIG $DEBIANCONFIG
    fi

    # Used incorrect name s/_/-/, keep all throughout until after jessie is released.
    rm_conffile /etc/udev/rules.d/65-mdadm.vol_id.rules
    ;;

  *) :;;
esac

#DEBHELPER#