summaryrefslogtreecommitdiff
path: root/debian/ifplugd.postinst
blob: fc9bf89db14dcde5c10b810bcb9e3f9b2dc690d4 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh -e
 
# source debconf library
. /usr/share/debconf/confmodule
 
CONFIGFILE=/etc/ifplugd/ifplugd.conf
CONFIGTMP=${CONFIGFILE}.tmp

DEFAULTFILE=/etc/default/ifplugd
DEFAULTTMP=${DEFAULTFILE}.tmp

write_db_conf (){

	rm -f ${CONFIGTMP}

	echo "# this file is deprecated - use /etc/default/ifplugd." >> ${CONFIGTMP}
 
	mv ${CONFIGTMP} ${CONFIGFILE}
}

write_default (){

	rm -f ${DEFAULTTMP}

	(
	    echo "# This file may be changed either manually or by running dpkg-reconfigure."
	    echo "#"
	    echo "# N.B.: dpkg-reconfigure deletes everything from this file except for"
	    echo "# the assignments to variables INTERFACES, HOTPLUG_INTERFACES, ARGS and"
	    echo "# SUSPEND_ACTION.  When run it uses the current values of those variables"
	    echo "# as their default values, thus preserving the administrator's changes."
	) >> $DEFAULTTMP

	db_get ifplugd/interfaces || true
	echo "INTERFACES=\"$RET\"" >> $DEFAULTTMP
	db_get ifplugd/hotplug_interfaces || true
	echo "HOTPLUG_INTERFACES=\"$RET\"" >> $DEFAULTTMP
	db_get ifplugd/args || true
	echo "ARGS=\"$RET\"" >> $DEFAULTTMP
	db_get ifplugd/suspend_action || true
	echo "SUSPEND_ACTION=\"$RET\"" >> $DEFAULTTMP
 
	mv ${DEFAULTTMP} ${DEFAULTFILE}
}

case "$1" in
    configure)
 
		write_db_conf
		write_default
		if [ ! "$2" ] || [ "$2" = "<unknown>" ] ; then
		# Fresh install
		for F in /etc/apm/suspend.d/20ifplugd \
			    /etc/apm/resume.d/80ifplugd /etc/apm/other.d/50ifplugd ; do
			[ -e $F ] && mv -f $F ${F}.dpkg-old
			ln -nsf ../scripts.d/ifplugd $F
		done

		fi

        ;;
 
    abort-upgrade|abort-remove|abort-deconfigure)
        ;;
esac

db_stop

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
 
#DEBHELPER#