Permalink
Browse files

Use late_command for ssh key and final setup

  • Loading branch information...
1 parent 543f537 commit 5c11cc965ef47121d340ee2d80eb222b85df452f @cal cal committed Apr 21, 2012
Showing with 57 additions and 2 deletions.
  1. +5 −0 .gitignore
  2. +27 −2 build.sh
  3. +22 −0 late_command.sh
  4. +3 −0 preseed.cfg
View
@@ -1 +1,6 @@
build/
+test/
+
+.DS_Store
+
+package.box
View
@@ -61,6 +61,10 @@ if [ ! -e "${FOLDER_ISO}/custom.iso" ]; then
cp isolinux.cfg "${FOLDER_ISO_CUSTOM}/isolinux/isolinux.cfg"
chmod u+w "${FOLDER_ISO_CUSTOM}/isolinux/isolinux.bin"
+ # add late_command script
+ chmod u+w "${FOLDER_ISO_CUSTOM}"
+ cp "${FOLDER_BASE}/late_command.sh" "${FOLDER_ISO_CUSTOM}"
+
mkisofs -r -V "Custom Ubuntu Install CD" \
-cache-inodes -quiet \
-J -l -b isolinux/isolinux.bin \
@@ -123,7 +127,7 @@ if ! VBoxManage showvminfo "${BOX}" >/dev/null 2>/dev/null; then
echo -n "Waiting for installer to finish "
while VBoxManage list runningvms | grep "${BOX}" >/dev/null; do
- sleep 10
+ sleep 20
echo -n "."
done
echo ""
@@ -140,12 +144,33 @@ if ! VBoxManage showvminfo "${BOX}" >/dev/null 2>/dev/null; then
--type dvddrive \
--medium "${ISO_GUESTADDITIONS}"
+ VBoxManage startvm "${BOX}"
+ # get private key
+ wget -O "${FOLDER_BUILD}/id_rsa" --no-check-certificate "https://raw.github.com/mitchellh/vagrant/master/keys/vagrant"
+ chmod 600 "${FOLDER_BUILD}/id_rsa"
+ # install virtualbox guest additions
+ ssh -i "${FOLDER_BUILD}/id_rsa" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 2222 vagrant@127.0.0.1 "sudo mount /dev/cdrom /media/cdrom; sudo sh /media/cdrom/VBoxLinuxAdditions.run; sudo umount /media/cdrom; sudo shutdown -h now"
+ echo -n "Waiting for machine to shut off "
+ while VBoxManage list runningvms | grep "${BOX}" >/dev/null; do
+ sleep 20
+ echo -n "."
+ done
+ echo ""
+ VBoxManage modifyvm "${BOX}" --natpf1 delete "guestssh"
+ # Detach guest additions iso
+ VBoxManage storageattach "${BOX}" \
+ --storagectl "IDE Controller" \
+ --port 1 \
+ --device 0 \
+ --type dvddrive \
+ --medium emptydrive
+fi
-#vagrant package --base "$name"
+vagrant package --base "${BOX}"
# references:
# http://blog.ericwhite.ca/articles/2009/11/unattended-debian-lenny-install/
View
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# passwordless sudo
+echo "%sudo ALL=NOPASSWD: ALL" >> /etc/sudoers
+
+# public ssh key for vagrant user
+mkdir /home/vagrant/.ssh
+wget -O /home/vagrant/.ssh/authorized_keys "https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub"
+chmod 755 /home/vagrant/.ssh
+chmod 644 /home/vagrant/.ssh/authorized_keys
+chown -R vagrant:vagrant /home/vagrant/.ssh
+
+# speed up ssh
+echo "UseDNS no" >> /etc/ssh/sshd_config
+
+# get chef
+gem install chef
+
+# display login promt after boot
+sed "s/quiet splash//" /etc/default/grub > /tmp/grub
+mv /tmp/grub /etc/default/grub
+update-grub
View
@@ -62,6 +62,9 @@ d-i pkgsel/include string build-essential ruby-dev rubygems puppet ssh
# Go grub, go!
d-i grub-installer/only_debian boolean true
+# Wrapping things up
+d-i preseed/late_command string cp /cdrom/late_command.sh /target/tmp/late_command.sh && in-target chmod +x /tmp/late_command.sh && in-target /tmp/late_command.sh
+
# Shut down, already
d-i finish-install/reboot_in_progress note
#d-i debian-installer/exit/halt boolean true

0 comments on commit 5c11cc9

Please sign in to comment.