forked from jasherai/ubuntu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-vagrant
executable file
·47 lines (37 loc) · 1.35 KB
/
build-vagrant
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
set -e
. "$(dirname $0)/config.sh"
for ARCH in $ARCHS
do
VBOX="${LABEL}-ubuntu-$VERSION-$DISTRO-$ARCH"
# Reset to snapshot at time of initial build
VBoxManage snapshot "${VBOX}" restore "AUTO_${LABEL}_base_build #000001"
# 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 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\""
until VBoxManage showvminfo "$VBOX" | grep "^State: *powered off"
do
sleep 1
done
# Now build the Vagrant box file.
vagrant package --base "$VBOX"
mv "package.box" \
"${LABEL}$([ "$ARCH" = "i386" ] && echo 32 || echo 64).box"
# Snapshot after vagrant dep install....
VBoxManage snapshot "${VBOX}" take "AUTO_${LABEL}_vagrant_base #000002" --description "Snapshot taken after installing vagrant dependencies"
done
# Creating Vagrant boxes ruins the normal VM setup so get rid of them.
#eval "$(dirname $0)/clean-vbox"