~ubuntu-branches/ubuntu/saucy/cloud-init/saucy

« back to all changes in this revision

Viewing changes to debian/cloud-init.preinst

  • Committer: Bazaar Package Importer
  • Author(s): Scott Moser
  • Date: 2010-02-04 03:00:05 UTC
  • Revision ID: james.westby@ubuntu.com-20100204030005-49ceaveyurbclc0b
Tags: 0.5.3-0ubuntu1
* Rename ec2-init to cloud-init.  New upstream release.
* set hostname to ip-u.x.y.z if local-hostname provides a ip addr
  (LP: #475354)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# Remove a no-longer used conffile
 
4
rm_conffile() {
 
5
        local PKGNAME="$1"
 
6
        local CONFFILE="$2"
 
7
 
 
8
        [ -e "$CONFFILE" ] || return 0
 
9
 
 
10
        local md5sum="$(md5sum $CONFFILE | sed -e 's/ .*//')"
 
11
        local old_md5sum="$(dpkg-query -W -f='${Conffiles}' $PKGNAME | \
 
12
                        sed -n -e "\' $CONFFILE ' { s/ obsolete$//; s/.* //; p }")"
 
13
        if [ "$md5sum" != "$old_md5sum" ]; then
 
14
                echo "Obsolete conffile $CONFFILE has been modified by you."
 
15
                echo "Saving as $CONFFILE.dpkg-bak ..."
 
16
                mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
 
17
        else
 
18
                echo "Removing obsolete conffile $CONFFILE ..."
 
19
                rm -f "$CONFFILE"
 
20
        fi
 
21
}
 
22
 
 
23
 
 
24
case "$1" in
 
25
        install|upgrade)
 
26
                # removing obsolete conffiles from the 'ec2-init' package
 
27
                if dpkg --compare-versions "$2" le "0.5.1"; then
 
28
                        rm_conffile ec2-init "/etc/init/cloud-ssh-keygen.conf"
 
29
                fi
 
30
                if dpkg --compare-versions "$2" lt "0.5.3"; then
 
31
                        rm_conffile ec2-init "/etc/init/ec2init.conf"
 
32
                fi
 
33
esac
 
34