Bug#755848: Patch in preseed src code

2016-10-05 Thread Eric Desrochers
This patch in preseed source code addresses the situation.

This is the patch we pushed in Ubuntu[1] releases.

Thanks to cyphermox for the joint works (co-authorship).

[1] - https://bugs.launchpad.net/ubuntu/+source/preseed/+bug/1452202

Eric
>From 742808a23407772c516628daecab29b4cbd12b22 Mon Sep 17 00:00:00 2001
From: Eric Desrochers 
Date: Thu, 6 Oct 2016 00:01:59 -0400
Subject: [PATCH] Fix for netcfg/hostname,if set, to take precedence

 Modify debian/network-preseed.postinst
---
 debian/network-preseed.postinst | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/debian/network-preseed.postinst b/debian/network-preseed.postinst
index bf651f4..6102182 100755
--- a/debian/network-preseed.postinst
+++ b/debian/network-preseed.postinst
@@ -14,4 +14,19 @@ if [ -n "$dhcp_url" ]; then
 	preseed_location "$dhcp_url"
 fi
 preseed preseed/url
+
+CURRENT_HOSTNAME=`/bin/hostname`
+if db_get netcfg/hostname && [ "$RET" ]; then
+if ! echo "$RET" | grep -q 'debian'; then
+		# default hostname is debian; if that's what we have in the
+		# netcfg/hostname template, then netcfg will already have
+		# done the right thing.
+		NETCFG_HOSTNAME="$RET"
+		/bin/sed -i "s/$CURRENT_HOSTNAME/$NETCFG_HOSTNAME/" /etc/hostname
+		/bin/sed -i "s/$CURRENT_HOSTNAME/$NETCFG_HOSTNAME/" /etc/hosts
+		/bin/hostname "$NETCFG_HOSTNAME"
+		/usr/bin/logger -t netcfg "d-i netcfg/hostname $NETCFG_HOSTNAME took precedence"
+	fi
+fi
+
 preseed_command preseed/early_command
-- 
2.7.4



Bug#755848: Patch

2016-09-20 Thread Eric Desrochers
This patch include a script under finish-install.d/56netcfg-hostname that 
detect if netcfg/hostname is set in preseed file and override the hostname at 
the end of the installation. If not set then it keeps the hostname as is.
>From 53522b8129f9542a1d7c9a21344d8b8b2732c9ce Mon Sep 17 00:00:00 2001
From: Eric Desrochers 
Date: Tue, 20 Sep 2016 20:02:16 -0400
Subject: [PATCH] Fix netcfg/hostname that does not set hostname

---
 finish-install.d/56netcfg-hostname | 17 +
 1 file changed, 17 insertions(+)
 create mode 100755 finish-install.d/56netcfg-hostname

diff --git a/finish-install.d/56netcfg-hostname b/finish-install.d/56netcfg-hostname
new file mode 100755
index 000..2256c5b
--- /dev/null
+++ b/finish-install.d/56netcfg-hostname
@@ -0,0 +1,17 @@
+#! /bin/sh
+set -e
+
+PROGNAME=$(basename $0)
+CURRENT_HOSTNAME=`/bin/hostname`
+NETCFG_HOSTNAME=`/bin/debconf-get netcfg/hostname`
+
+# Override hostname, if "netcfg/hostname" is set in preseed file. #
+if [ -n "$NETCFG_HOSTNAME" ]; then
+/bin/sed -i "s/$CURRENT_HOSTNAME/$NETCFG_HOSTNAME/" /target/etc/hostname
+/bin/sed -i "s/$CURRENT_HOSTNAME/$NETCFG_HOSTNAME/" /target/etc/hosts
+/usr/bin/logger "$PROGNAME: d-i netcfg/hostname $NETCFG_HOSTNAME took precedence"
+
+# Keep hostname as is, if "netcfg/hostname" is not set in preseed file. #
+else
+exit 0
+fi
-- 
2.5.0