summaryrefslogtreecommitdiff
path: root/debian/ifplugd.postinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/ifplugd.postinst')
-rw-r--r--debian/ifplugd.postinst73
1 files changed, 73 insertions, 0 deletions
diff --git a/debian/ifplugd.postinst b/debian/ifplugd.postinst
new file mode 100644
index 0000000..fc9bf89
--- /dev/null
+++ b/debian/ifplugd.postinst
@@ -0,0 +1,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#
+