Last active
August 29, 2015 14:07
-
-
Save takumin/a9ef7882225ecc778956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"builders": [ | |
{ | |
"type": "virtualbox-iso", | |
"vm_name": "freebsd64-101rc1", | |
"boot_wait": "15s", | |
"hard_drive_interface": "sata", | |
"disk_size": 4096, | |
"guest_os_type": "FreeBSD_64", | |
"iso_checksum": "694b7415a0ec11b34374f51682358fed", | |
"iso_checksum_type": "md5", | |
"iso_url": "http://ftp.jaist.ac.jp/pub/FreeBSD/ISO-IMAGES-amd64/10.1/FreeBSD-10.1-RC1-amd64-disc1.iso", | |
"ssh_username": "vagrant", | |
"ssh_password": "vagrant", | |
"shutdown_command": "echo 'shutdown -p now' | su -", | |
"vboxmanage": [ | |
[ "modifyvm", "{{.Name}}", "--memory", "512" ], | |
[ "modifyvm", "{{.Name}}", "--cpus", "1" ], | |
[ "modifyvm", "{{.Name}}", "--nictype1", "virtio" ], | |
[ "modifyvm", "{{.Name}}", "--audio", "none" ], | |
[ "modifyvm", "{{.Name}}", "--usb", "off" ] | |
], | |
"http_directory": ".", | |
"boot_command": [ | |
"<enter><wait10><wait5>", | |
"l<enter><wait>", | |
"root<enter><wait>", | |
"dhclient vtnet0<enter><wait5>", | |
"fetch -o /tmp/install.sh http://{{.HTTPIP}}:{{.HTTPPort}}/install.sh && sh /tmp/install.sh {{.Name}}<enter>", | |
"<wait10><wait10><wait10><wait10><wait10><wait10>" | |
] | |
} | |
], | |
"provisioners": [ | |
{ | |
"type": "shell", | |
"script": "postinstall.sh", | |
"override": { | |
"virtualbox-iso": { | |
"execute_command": "cat '{{.Path}}' | su -" | |
} | |
} | |
} | |
], | |
"post-processors": [ | |
{ | |
"type": "vagrant", | |
"only": ["virtualbox-iso"], | |
"output": "freebsd64-101rc1.box" | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME=$1 | |
# initial disk | |
gpart create -s gpt ada0 | |
gpart add -s 64k -t freebsd-boot -l boot ada0 | |
gpart add -s 1g -t freebsd-swap -l swap ada0 | |
gpart add -t freebsd-ufs -l disk ada0 | |
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 | |
newfs -Ujl /dev/gpt/disk | |
tunefs -a enable /dev/gpt/disk | |
tunefs -N enable /dev/gpt/disk | |
mount /dev/gpt/disk /mnt | |
# install world | |
tar -xUpf /usr/freebsd-dist/base.txz -C /mnt | |
tar -xUpf /usr/freebsd-dist/kernel.txz -C /mnt | |
tar -xUpf /usr/freebsd-dist/src.txz -C /mnt | |
# cofigure fstab | |
cat > /mnt/etc/fstab << __EOF__ | |
# Device Mountpoint FStype Options Dump Pass # | |
/dev/gpt/swap none swap sw 0 0 | |
/dev/gpt/disk / ufs rw 1 1 | |
procfs /proc procfs rw 0 0 | |
__EOF__ | |
# initial configure | |
sysrc -R /mnt hostname=${NAME} | |
sysrc -R /mnt ifconfig_DEFAULT=DHCP | |
sysrc -R /mnt sshd_enable=YES | |
# root password | |
echo -n "vagrant" | pw -V /mnt/etc usermod -n root -h 0 | |
# create vagrant password | |
echo -n "vagrant" | pw -V /mnt/etc useradd -n vagrant -c "Vagrant User" -G wheel,operator -m -s /bin/csh -h 0 | |
# configure ssh vagrant | |
mkdir /mnt/home/vagrant/.ssh | |
echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > /mnt/home/vagrant/.ssh/authorized_keys | |
chmod 0700 /mnt/home/vagrant/.ssh | |
chown -R 1001:1001 /mnt/home/vagrant/.ssh | |
# reboot | |
shutdown -r now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo Remove Virtualbox Guest Addtions. | |
rm /home/vagrant/*.iso | |
echo Install pkgng. | |
env ASSUME_ALWAYS_YES=yes pkg update -q | |
echo Install virtualbox-ose-additions. | |
pkg install -qy emulators/virtualbox-ose-additions | |
echo Install bash. | |
pkg install -qy shells/bash | |
echo Install sudo. | |
pkg install -qy security/sudo | |
echo Install ansible. | |
pkg install -qy sysutils/ansible | |
echo Install puppet. | |
pkg install -qy sysutils/puppet | |
echo Install chef. | |
pkg install -qy sysutils/rubygem-chef | |
echo Enable virtualbox-ose-additions. | |
sysrc vboxguest_enable=YES | |
sysrc vboxservice_enable=YES | |
sysrc vboxservice_flags=--disable-timesync | |
echo Configure vagrant sudo. | |
echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /usr/local/etc/sudoers | |
echo Configure vagrant shell. | |
pw usermod vagrant -s /usr/local/bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment