+vagrant_setup() {
+ if ! mountpoint "${TARGET}" &>/dev/null ; then
+ echo "* Mounting target system"
+ mount "${INSTALL_TARGET}" "${TARGET}"
+ fi
+
+ echo "* Setting password for user root to 'vagrant'"
+ echo root:vagrant | chroot ${TARGET} chpasswd
+
+ echo "* Installing sudo package"
+ chroot ${TARGET} apt-get -y install sudo
+
+ echo "* Adding Vagrant user"
+ chroot ${TARGET} useradd -d /home/vagrant -m -u 1000 vagrant -s /bin/bash
+
+ echo "* Installing Vagrant ssh key"
+ mkdir -m 0700 -p ${TARGET}/home/vagrant/.ssh
+ echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" >> ${TARGET}/home/vagrant/.ssh/authorized_keys
+ chmod 0600 ${TARGET}/home/vagrant/.ssh/authorized_keys
+ chroot ${TARGET} chown vagrant:vagrant /home/vagrant/.ssh /home/vagrant/.ssh/authorized_keys
+
+ echo "* Setting up sudo configuration for user vagrant"
+ if ! [ -d "${TARGET}/etc/sudoers.d" ] ; then # lenny:
+ echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> "${TARGET}/etc/sudoers"
+ else # wheezy and newer:
+ echo "vagrant ALL=(ALL) NOPASSWD: ALL" > "${TARGET}/etc/sudoers.d/vagrant"
+ chmod 0440 "${TARGET}/etc/sudoers.d/vagrant"
+ fi
+
+ 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
+
+ if mountpoint "${TARGET}" &>/dev/null ; then
+ echo "* Unmounting target system"
+ umount "${TARGET}"
+ fi
+}
+
+partition_setup() {
+ echo "* Executing automated partition setup"
+ cat > /tmp/partition_setup.txt << EOF