diff -Nru preseed-1.71ubuntu1.1/debian/changelog preseed-1.71ubuntu1.2/debian/changelog --- preseed-1.71ubuntu1.1/debian/changelog 2016-10-06 00:01:39.000000000 +0800 +++ preseed-1.71ubuntu1.2/debian/changelog 2018-01-16 16:50:43.000000000 +0800 @@ -1,3 +1,10 @@ +preseed (1.71ubuntu1.2) xenial; urgency=medium + + * Fix for netcfg/hostname, if set, to take precedence. (LP: #1452202) + - Modify debian/network-preseed.postinst to make it more robust + + -- Hua Zhang Tue, 16 Jan 2018 16:48:41 +0800 + preseed (1.71ubuntu1.1) xenial; urgency=medium * Fix for netcfg/hostname, if set, to take precedence. (LP: #1452202) diff -Nru preseed-1.71ubuntu1.1/debian/network-preseed.postinst preseed-1.71ubuntu1.2/debian/network-preseed.postinst --- preseed-1.71ubuntu1.1/debian/network-preseed.postinst 2016-10-06 00:01:39.000000000 +0800 +++ preseed-1.71ubuntu1.2/debian/network-preseed.postinst 2018-01-16 16:48:13.000000000 +0800 @@ -17,16 +17,14 @@ CURRENT_HOSTNAME=`/bin/hostname` if db_get netcfg/hostname && [ "$RET" ]; then - if ! echo "$RET" | grep -q 'ubuntu'; then - # default hostname is ubuntu; 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 + # default hostname is ubuntu; 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 "/^[127|localhost]/s/${CURRENT_HOSTNAME}/${NETCFG_HOSTNAME}/g" /etc/hosts + /bin/hostname "$NETCFG_HOSTNAME" + /usr/bin/logger -t netcfg "d-i netcfg/hostname $NETCFG_HOSTNAME took precedence" fi preseed_command preseed/early_command