Statistics
| Branch: | Tag: | Revision:

root / debian / snf-image.postinst @ 99eb3bdf

History | View | Annotate | Download (1.5 kB)

1
#!/bin/bash -e
2

    
3

    
4
CONFFILE=/etc/default/snf-image-update-helper
5

    
6
update_helper_msg()
7
{
8
    echo "This package will not work until a working snf-image-helper images is"
9
    echo "installed under: \`/var/lib/snf-image/helper'. You can later download and"
10
    echo "install the snf-image-helper image using the command:"
11
    echo
12
    echo "    snf-image-update-helper"
13
    echo
14
}
15

    
16
create_conffile()
17
{
18
    cat > $1 <<EOF
19
###DEBCONF###
20
# the configuration of this file will be done by debconf as long as the
21
# first line of the file says '###DEBCONF###'
22
#
23
# you should use dpkg-reconfigure snf-image to configure this file and
24
# install the snf-image-helper image
25
#
26
# HELPER_URL: URL to use to download the snf-image-helper image
27
$(set | grep ^HELPER_URL=)
28

    
29
EOF
30
}
31

    
32
add_debconf_signature()
33
{
34
    TMPCONF=$(mktmep --tmpdir=/etc/default)
35
    mv "$1" "$TMPCONF"
36
    cat > "$1" <<EOF
37
###DEBCONF###
38
EOF
39
    cat "$TMPCONF" >> "$1"
40
    rm -f "$TMPCONF"
41
}
42

    
43
case "$1" in
44
   configure)
45
	. /usr/share/debconf/confmodule
46
	db_get snf-image/dlurl
47
	HELPER_URL="$RET"
48
        if [ -n "$HELPER_URL" ]; then
49
		if [ ! -e "$CONFFILE" ]; then
50
		    create_conffile "$CONFFILE"
51
        	elif head -1 "$CONFFILE" | grep -q '^###DEBCONF###' > /dev/null; then
52
		    create_conffile "$CONFFILE"
53
        	else
54
		    add_debconf_signature "$CONFFILE"
55
		fi
56
		snf-image-update-helper -y
57
	else
58
		update_helper_msg
59
	fi
60
	;;
61
    abort-upgrade|abort-remove|abort-deconfigure)
62
	exit 0
63
	;;
64
    *)
65
	echo "postinst called with unknown argument \`$1'" >&2
66
	exit 1
67
	;;
68
esac
69

    
70
#DEBHELPER#
71

    
72
exit 0
73