Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed infinite reboot loop #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 18 additions & 78 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,25 @@
all:

clean: clean-lynx32 clean-lynxx32 clean-lynx64 clean-lynxx64 clean-meerkat32 clean-meerkat64 clean-narwhal32 clean-narwhal64
clean: clean-precise32 clean-precise64

lynx32:
NICKNAME=lynx VERSION=10.04 ARCH=i386 ./build-iso
NICKNAME=lynx VERSION=10.04 ARCH=i386 ./build-vbox
NICKNAME=lynx VERSION=10.04 ARCH=i386 ./build-vagrant
precise32:
NICKNAME=precise VERSION=12.04 ARCH=i386 ./build-iso
NICKNAME=precise VERSION=12.04 ARCH=i386 ./build-vbox
NICKNAME=precise VERSION=12.04 ARCH=i386 ./build-vagrant

clean-lynx32:
NICKNAME=lynx VERSION=10.04 ARCH=i386 ./clean-iso
NICKNAME=lynx VERSION=10.04 ARCH=i386 ./clean-vbox || true
NICKNAME=lynx VERSION=10.04 ARCH=i386 ./clean-vagrant
clean-precise32:
NICKNAME=precise VERSION=12.04 ARCH=i386 ./clean-iso
NICKNAME=precise VERSION=12.04 ARCH=i386 ./clean-vbox || true
NICKNAME=precise VERSION=12.04 ARCH=i386 ./clean-vagrant

lynxx32:
NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./build-iso
NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./build-vbox
NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./build-vagrant
precise64:
NICKNAME=precise VERSION=12.04 ARCH=amd64 ./build-iso
NICKNAME=precise VERSION=12.04 ARCH=amd64 ./build-vbox
NICKNAME=precise VERSION=12.04 ARCH=amd64 ./build-vagrant

clean-lynxx32:
NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./clean-iso
NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./clean-vbox || true
NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./clean-vagrant
clean-precise64:
NICKNAME=precise VERSION=12.04 ARCH=amd64 ./clean-iso
NICKNAME=precise VERSION=12.04 ARCH=amd64 ./clean-vbox || true
NICKNAME=precise VERSION=12.04 ARCH=amd64 ./clean-vagrant

lynx64:
NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./build-iso
NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./build-vbox
NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./build-vagrant

clean-lynx64:
NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./clean-iso
NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./clean-vbox || true
NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./clean-vagrant

lynxx64:
NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./build-iso
NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./build-vbox
NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./build-vagrant

clean-lynxx64:
NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./clean-iso
NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./clean-vbox || true
NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./clean-vagrant

meerkat32:
NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./build-iso
NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./build-vbox
NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./build-vagrant

clean-meerkat32:
NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./clean-iso
NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./clean-vbox || true
NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./clean-vagrant

meerkat64:
NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./build-iso
NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./build-vbox
NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./build-vagrant

clean-meerkat64:
NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./clean-iso
NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./clean-vbox || true
NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./clean-vagrant

narwhal32:
NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./build-iso
NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./build-vbox
NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./build-vagrant

clean-narwhal32:
NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./clean-iso
NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./clean-vbox || true
NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./clean-vagrant

narwhal64:
NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./build-iso
NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./build-vbox
NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./build-vagrant

clean-narwhal64:
NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./clean-iso
NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./clean-vbox || true
NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./clean-vagrant

.PHONY: all lynx32 clean-lynx32 lynx64 clean-lynx64 meerkat32 clean-meerkat32 meerkat64 clean-meerkat64 clean-narwhal32 clean-narwhal64
.PHONY: all clean-precise32 clean-precise64
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
Ubuntu for DevStructure
=======================
Ubuntu for Vagrant
==================

Build a custom Ubuntu ISO for Vagrant by downloading, extracting,
Build a custom Ubuntu base box for Vagrant by downloading, extracting,
tweaking, and packaging the stock Ubuntu ISO.

Build dependencies
------------------

* `curl`(1).
* `hdiutil`(1), and therefore Mac OS X. It may be possible to relax
this dependency but it has not been investigated.
* `m4`(1).
* `mkisofs`(1) from the `cdrtools` package available from MacPorts or
Homebrew.
Expand All @@ -36,10 +34,15 @@ Features in the ISO
are all configurable.
* OpenSSH server is installed.
* VirtualBox Guest Additions are installed.
* Chef is installed.

Building
--------

Edit configuration in

config.sh

Building ISO images:

./build-iso
Expand All @@ -52,7 +55,14 @@ Building Vagrant boxes:

./build-vagrant

There are matching `clean-{iso,vbox,vagrant}` programs that remove the
There are matching `clean-{iso,vbox,vagrant}` scripts that remove the
products of their build counterparts.

The `Makefile` contains targets for common build tasks.
The `Makefile` contains targets for common build tasks. For Ubuntu 12.04
(Precise Pangolin) 32-bit use

make precise32

For Ubuntu 12.04 (Precise Pangolin) 64-bit use

make precise64
15 changes: 8 additions & 7 deletions build-vagrant
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ VBOX="$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH"

# Start the virtual machine. Spin slowly until SSH is usable.
VBoxManage startvm "$VBOX" --type gui
#VBoxHeadless --startvm "$VBOX" --vrdp config
until eval "$SSH exit"
do
sleep 1
done

# Install Ruby, RubyGems, and Chef as Vagrant requires.
# eval "$SSH \"
# set -e
# sudo apt-get -y install build-essential ruby-dev rubygems
# sudo gem install --no-rdoc --no-ri chef
# echo 'PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/gems/1.8/bin\"' | sudo tee /etc/environment >/dev/null
# \""
eval "$SSH \"
set -e
sudo apt-get -y install build-essential ruby-dev rubygems
sudo gem install --no-rdoc --no-ri chef
echo 'PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/gems/1.8/bin\"' | sudo tee /etc/environment >/dev/null
\""

# Shutdown the virtual machine.
eval "$SSH \"sudo shutdown -h now\""
Expand All @@ -34,5 +33,7 @@ vagrant package --base "$VBOX"
mv "package.box" \
"$NICKNAME$([ "$ARCH" = "i386" ] && echo 32 || echo 64).box"

echo "Successfully built vagrant box!"

# Creating Vagrant boxes ruins the normal VM setup so get rid of them.
eval "$(dirname $0)/clean-vbox"
25 changes: 16 additions & 9 deletions build-vbox
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,26 @@ VBoxManage storageattach "$VBOX" \


# Start the virtual machine and the OS installation. This will take
# a while so this time it gets a GUI. Spin slowly until SSH is usable.
# a while so this time it gets a GUI. Wait until installation finished
# and vm is powered off.
VBoxManage startvm "$VBOX" --type gui
echo "Waiting for installion to finish.."
until eval "$SSH exit"
until VBoxManage showvminfo "$VBOX" | grep "^State: *powered off"
do
sleep 60
sleep 10
done

# Attach the VBoxGuestAdditions ISO, implicitly detaching the custom
# installation ISO in the process. Install the additions and empty
# the drive.
# installation ISO in the process.
VBoxManage storageattach "$VBOX" \
--storagectl SATA \
--port 1 --device 0 \
--type dvddrive --medium "$VBOX_GUEST_ADDITIONS"

# Power up vm again.
VBoxManage startvm "$VBOX" --

# Install guest additions.
eval "$SSH \"
set -e
sudo apt-get -y install linux-headers-\\\$(uname -r) build-essential
Expand All @@ -79,14 +84,16 @@ eval "$SSH \"
sudo /media/cdrom/VBoxLinuxAdditions.run
sudo umount /media/cdrom
\""
VBoxManage storageattach "$VBOX" \
--storagectl SATA \
--port 1 --device 0 \
--type dvddrive --medium emptydrive

# Shutdown the virtual machine.
eval "$SSH \"sudo shutdown -h now\""
until VBoxManage showvminfo "$VBOX" | grep "^State: *powered off"
do
sleep 1
done

# Remove guest additions cd.
VBoxManage storageattach "$VBOX" \
--storagectl SATA \
--port 1 --device 0 \
--type dvddrive --medium emptydrive
7 changes: 7 additions & 0 deletions clean-iso
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ set -e
. "$(dirname $0)/config.sh"

rm -f "$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH.iso"
{
sudo diskutil unmount "mount"
sudo /usr/libexec/vndevice detach /dev/vn0
} || {
sudo umount "mount"
rm -rf "mount"
}
3 changes: 0 additions & 3 deletions clean-vbox
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/sh

# set -e # Try our best to finish here.

. "$(dirname $0)/config.sh"

ISO="$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH.iso"
VBOX="$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH"

VBoxManage controlvm "$VBOX" poweroff
VBoxManage storagectl "$VBOX" --name IDE --remove
VBoxManage storagectl "$VBOX" --name SATA --remove
VBoxManage unregistervm "$VBOX"
VBoxManage closemedium dvd "$PWD/$ISO"
Expand Down
2 changes: 1 addition & 1 deletion config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
: ${NICKNAME:="vagrant"}

# Arguments given to the download router.
: ${VERSION:="10.10"}
: ${VERSION:="12.04"}
: ${DISTRO:="server"}
: ${RELEASE:="latest"}

Expand Down
1 change: 1 addition & 0 deletions unattended.seed.m4
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ d-i grub-installer/with_other_os boolean true
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true
d-i debian-installer/splash boolean false
d-i debian-installer/exit/poweroff boolean true

# Everything else.
d-i preseed/late_command string sh /cdrom/late_command.sh