forked from 2creatives/vagrant-centos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·83 lines (68 loc) · 2.42 KB
/
setup
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh -e
. ./vars.sh
VBoxManage createvm --name ${NAME} --ostype ${TYPE} --register
VBoxManage modifyvm ${NAME} \
--vram 12 \
--accelerate3d off \
--memory 613 \
--usb off \
--audio none \
--boot1 disk --boot2 dvd --boot3 none --boot4 none \
--nictype1 virtio --nic1 nat --natnet1 "${NATNET}" \
--nictype2 virtio \
--nictype3 virtio \
--nictype4 virtio \
--acpi on --ioapic off \
--chipset piix3 \
--rtcuseutc on \
--hpet on \
--bioslogofadein off \
--bioslogofadeout off \
--bioslogodisplaytime 0 \
--biosbootmenu disabled
VBoxManage createhd --filename "${HDD}" --size 8192
# Swap is recommended to be double the size of RAM.
VBoxManage createhd --filename "${HDD_SWAP}" --size 1226
VBoxManage storagectl ${NAME} \
--name SATA --add sata --portcount 2 --bootable on
VBoxManage storageattach ${NAME} \
--storagectl SATA --port 0 --type hdd --medium "${HDD}"
VBoxManage storageattach ${NAME} \
--storagectl SATA --port 1 --type hdd --medium "${HDD_SWAP}"
VBoxManage storageattach ${NAME} \
--storagectl SATA --port 2 --type dvddrive --medium "${INSTALLER}"
VBoxManage storageattach ${NAME} \
--storagectl SATA --port 3 --type dvddrive --medium "${GUESTADDITIONS}"
VBoxManage startvm ${NAME} --type gui
setup_ruby() {
# handle errors in here
set +e
SOURCE=$(which vagrant)
if [ $? -eq 0 ]; then
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
EMBEDDED_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )/../embedded"
unset RUBYOPT
RUBY_EXECUTABLE="${EMBEDDED_DIR}/bin/ruby"
else
RUBY_EXECUTABLE=$(which ruby)
if [ ! $? -eq 0 ]; then
echo "Cannot find Ruby (needed for kickstart file)"
exit 1
fi
fi
set -e
}
# This only really caters for the common case. If you have problems, please
# discover your host's IP address and adjust accordingly.
IP=`echo ${NATNET} | sed -nE 's/^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}).*/\1/p'`
setup_ruby
echo 'At the boot prompt, hit <TAB> and then type:'
/bin/echo -n " ks=http://${IP}.3:"
${RUBY_EXECUTABLE} httpd.rb ks.cfg
echo "The box has accepted the kickstart file. It will now go through"
echo "a lengthy install. When it is finished it will shutdown and you"
echo "can run:"
echo
echo " ./cleanup && vagrant package --base ${NAME} --output boxes/${NAME}-`date +%Y%m%d`.box"
echo
echo "to create a Vagrant box."