From 03b262319f7750b0df190c8e4371f4245af48b25 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 30 Aug 2013 18:22:07 -0300 Subject: [PATCH] boxes/ubuntu: Configure vagrant user This commit applies @smaftoul patch from https://gist.github.com/smaftoul/2d6fcf43b7c6545aa588/revisions --- boxes/templates/ubuntu | 12 ++++++++++++ tasks/boxes.rake | 5 ----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/boxes/templates/ubuntu b/boxes/templates/ubuntu index e962166..59e7841 100755 --- a/boxes/templates/ubuntu +++ b/boxes/templates/ubuntu @@ -117,6 +117,8 @@ finalize_user() { user=$1 + chroot $rootfs getent passwd $user || chroot $rootfs adduser --disabled-password --gecos "" $user + sudo_version=$(chroot $rootfs dpkg-query -W -f='${Version}' sudo) if chroot $rootfs dpkg --compare-versions $sudo_version gt "1.8.3p1-1"; then @@ -513,6 +515,9 @@ EOF # remove pointless services in a container chroot $rootfs /usr/sbin/update-rc.d -f ondemand remove + chroot $rootfs /usr/sbin/update-rc.d -f checkroot-bootclean.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f mountall-bootclean.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f mountnfs-bootclean.sh remove chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls u*.conf); do mv $f $f.orig; done' chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls tty[2-9].conf); do mv $f $f.orig; done' @@ -787,6 +792,13 @@ else finalize_user ubuntu fi +vagrant_key_file="/tmp/vagrant.pub" +echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /tmp/vagrant.pub +orig_auth_key="$auth_key" +auth_key="/tmp/vagrant.pub" +finalize_user vagrant +auth_key="$orig_auth_key" + echo "" echo "##" if [ -n "$bindhome" ]; then diff --git a/tasks/boxes.rake b/tasks/boxes.rake index 84fd25e..3897e71 100644 --- a/tasks/boxes.rake +++ b/tasks/boxes.rake @@ -41,7 +41,6 @@ class BuildGenericBoxTask < ::Rake::TaskLib import_template do |template| create_base_container(template) do |rootfs| - configure_vagrant_user(rootfs) install_cfg_engines(rootfs) cleanup(rootfs) prepare_package_contents(rootfs) @@ -74,10 +73,6 @@ class BuildGenericBoxTask < ::Rake::TaskLib sh "sudo lxc-destroy -n #{container_name}" end - def configure_vagrant_user(rootfs) - puts "TODO: Configure vagrant user under #{rootfs}" - end - def install_cfg_engines(rootfs) puts "TODO: Install cfg engines under #{rootfs}" end