From 21b01603eadd966f485c86cebd35f9bfbd7fd0aa Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 15 May 2014 17:25:04 +0200 Subject: [PATCH] Improve packer deployment for usage in Vagrant * work around "stdin: is not a tty" issue via /root/.profile * set up loopback entry in /etc/hosts to make sudo happy ("sudo: unable to resolve host") * store build information to /etc/grml_debootstrap.info --- packer/debian64_provision.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packer/debian64_provision.sh b/packer/debian64_provision.sh index 7830ad4..d0a49d3 100644 --- a/packer/debian64_provision.sh +++ b/packer/debian64_provision.sh @@ -95,11 +95,27 @@ chroot ${TARGET} chown vagrant:vagrant /home/vagrant/.ssh /home/vagrant/.ssh/aut echo "* Setting up sudo configuration for user vagrant" echo "vagrant ALL=(ALL) NOPASSWD: ALL" > ${TARGET}/etc/sudoers.d/vagrant +host="$(cat ${TARGET}/etc/hostname)" +if ! grep -q "${host}$" "${TARGET}"/etc/hosts ; then + echo "* Setting up localhost entry for hostname $host in /etc/hosts" + cat >> "${TARGET}"/etc/hosts << EOF +# Added by grml-debootstrap/provision to make sure host is resolvable for sudo: +127.0.0.2 ${host}.local $host + +EOF +fi + +echo "* Setting up stdin/tty workaround in /root/.profile" +sed -i "s;^mesg n$;# modified via grml-debootstrap/provision script to work around stdin/tty issue:\ntty -s \&\& mesg n;g" "${TARGET}"/root/.profile + if [ -f ${TARGET}/etc/ssh/sshd_config ] && ! grep -q '^UseDNS' ${TARGET}/etc/ssh/sshd_config ; then echo "* Disabling UseDNS in sshd config" echo "UseDNS no" >> ${TARGET}/etc/ssh/sshd_config fi +echo "* Logging build information to /etc/grml_debootstrap.info" +echo "System generated by grml-debootstrap/provision on $(date)" > ${TARGET}/etc/grml_debootstrap.info + echo "* Cleaning up apt stuff" chroot ${TARGET} apt-get clean rm -f ${TARGET}/var/lib/apt/lists/*Packages \ -- 2.1.4