diff --git a/templates/freebsd-9.1-RELEASE-amd64/postinstall.csh b/templates/freebsd-9.1-RELEASE-amd64/postinstall.csh deleted file mode 100644 index cdd6468d..00000000 --- a/templates/freebsd-9.1-RELEASE-amd64/postinstall.csh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/csh -x -# NB: at the point when this script is run, vagrant's shell is csh - -set echo - -#Set the time correctly -ntpdate -v -b in.pool.ntp.org - -date > /etc/vagrant_box_build_time - -# allow freebsd-update to run fetch without stdin attached to a terminal -sed 's/\[ ! -t 0 \]/false/' /usr/sbin/freebsd-update > /tmp/freebsd-update -chmod +x /tmp/freebsd-update - -# update FreeBSD -env PAGER=/bin/cat /tmp/freebsd-update fetch -env PAGER=/bin/cat /tmp/freebsd-update install - -# allow portsnap to run fetch without stdin attached to a terminal -sed 's/\[ ! -t 0 \]/false/' /usr/sbin/portsnap > /tmp/portsnap -chmod +x /tmp/portsnap - -# reduce the ports we extract to a minimum -cat >> /etc/portsnap.conf << EOT -REFUSE accessibility arabic archivers astro audio benchmarks biology cad -REFUSE chinese comms databases deskutils distfiles dns editors finance french -REFUSE ftp games german graphics hebrew hungarian irc japanese java korean -REFUSE mail math multimedia net net-im net-mgmt net-p2p news packages palm -REFUSE polish portuguese print russian science sysutils ukrainian -REFUSE vietnamese www x11 x11-clocks x11-drivers x11-fm x11-fonts x11-servers -REFUSE x11-themes x11-toolkits x11-wm -EOT - -# get new ports -/tmp/portsnap fetch extract - -# install sudo and bash -pkg_delete -af -cd /usr/ports/security/sudo -make -DBATCH install clean -cd /usr/ports/shells/bash-static -make -DBATCH install clean - -#Off to rubygems to get first ruby running -cd /usr/ports/devel/ruby-gems -make install -DBATCH - -#Need ruby iconv in order for chef to run -cd /usr/ports/converters/ruby-iconv -make install -DBATCH - -#Installing chef & Puppet -/usr/local/bin/gem install chef --no-ri --no-rdoc -/usr/local/bin/gem install puppet --no-ri --no-rdoc - -#Installing vagrant keys -mkdir /home/vagrant/.ssh -chmod 700 /home/vagrant/.ssh -cd /home/vagrant/.ssh -fetch -am -o authorized_keys 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -chown -R vagrant /home/vagrant/.ssh -chmod -R go-rwsx /home/vagrant/.ssh - -# Cleaning portstree to save space -# http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html -cd /usr/ports/ports-mgmt/portupgrade -make install -DBATCH clean - -/usr/local/sbin/portsclean -C - -# As sharedfolders are not in defaults ports tree -# We will use vagrant via NFS -# Enable NFS -echo 'rpcbind_enable="YES"' >> /etc/rc.conf -echo 'nfs_server_enable="YES"' >> /etc/rc.conf -echo 'mountd_flags="-r"' >> /etc/rc.conf - -# Enable passwordless sudo -echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /usr/local/etc/sudoers -# Restore correct su permissions -# I'll leave that up to the reader :) - -cd /usr/ports/devel/libtool -make clean -make install -DBATCH - -# disable X11 because vagrants are (usually) headless -cat >> /etc/make.conf << EOT -WITHOUT_X11="YES" -EOT - -cd /usr/ports/emulators/virtualbox-ose-additions -make -DBATCH install clean - -cd /usr/ports/emulators/virtio-kmod -make -DBATCH install - -# undo our customizations -sed -i '' -e '/^REFUSE /d' /etc/portsnap.conf -sed -i '' -e '/^PermitRootLogin /d' /etc/ssh/sshd_config -/usr/sbin/service sshd reload - -echo 'vboxdrv_load="YES"' >> /boot/loader.conf -echo 'vboxnet_enable="YES"' >> /etc/rc.conf -echo 'vboxguest_enable="YES"' >> /etc/rc.conf -echo 'vboxservice_enable="YES"' >> /etc/rc.conf - -cat >> /boot/loader.conf << EOT -virtio_load="YES" -virtio_pci_load="YES" -virtio_blk_load="YES" -if_vtnet_load="YES" -virtio_balloon_load="YES" -EOT - -echo 'ifconfig_vtnet0_name="em0"' >> /etc/rc.conf -echo 'ifconfig_vtnet1_name="em1"' >> /etc/rc.conf -echo 'ifconfig_vtnet2_name="em2"' >> /etc/rc.conf -echo 'ifconfig_vtnet3_name="em3"' >> /etc/rc.conf - -pw groupadd vboxusers -pw groupmod vboxusers -m vagrant - -#Bash needs to be the shell for tests to validate -pw usermod vagrant -s /usr/local/bin/bash - -echo "==============================================================================" -echo "NOTE: FreeBSD - Vagrant" -echo "When using this basebox you need to do some special stuff in your Vagrantfile" -echo "1) Enable HostOnly network" -echo " config.vm.network ...." -echo "2) Use nfs instead of shared folders" -echo ' config.vm.share_folder("v-root", "/vagrant", ".", :nfs => true)' -echo "=============================================================================" - -exit diff --git a/templates/freebsd-9.2-RELEASE-amd64/definition.rb b/templates/freebsd-9.2-RELEASE-amd64/definition.rb new file mode 100644 index 00000000..8ebed87a --- /dev/null +++ b/templates/freebsd-9.2-RELEASE-amd64/definition.rb @@ -0,0 +1,28 @@ +Veewee::Definition.declare({ + :cpu_count => '1', :memory_size=> '512', + :disk_size => '10140', :disk_format => 'VDI', :hostiocache => 'off', + :os_type_id => 'FreeBSD_64', + :iso_file => "FreeBSD-9.2-RELEASE-amd64-disc1.iso", + :iso_src => "ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/ISO-IMAGES/9.2/FreeBSD-9.2-RELEASE-amd64-disc1.iso", + :iso_md5 => "cde180e3c5e3e370c97598a4feccb5b4", + :iso_download_timeout => "1000", + :boot_wait => "10", :boot_cmd_sequence => [ + '', + 'boot -s', + '', + '', + '/bin/sh', + 'mdmfs -s 100m md1 /tmp', + 'dhclient -l /tmp/dhclient.lease.em0 em0', + '', + 'echo "Sleeping for 10 seconds, then running install script."', + 'sleep 10 ; fetch -o /tmp/install.sh http://%IP%:%PORT%/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh %NAME%' + ], + :kickstart_port => "7122", :kickstart_timeout => "10000", :kickstart_file => "install.sh", + :ssh_login_timeout => "10000", :ssh_user => "root", :ssh_password => "vagrant", :ssh_key => "", + :ssh_host_port => "7222", :ssh_guest_port => "22", + :sudo_cmd => "sh '%f'", + :shutdown_cmd => "shutdown -p now", + :postinstall_files => [ "postinstall.csh"], :postinstall_timeout => "10000" +}) +#'setkmap=us dodhcp=em0 dhcphostname=%NAME% ar_source=http://%IP%:%PORT%/ autoruns=0 rootpass=vagrant', diff --git a/templates/freebsd-9.2-RELEASE-amd64/install.sh b/templates/freebsd-9.2-RELEASE-amd64/install.sh new file mode 100644 index 00000000..a2a2fe71 --- /dev/null +++ b/templates/freebsd-9.2-RELEASE-amd64/install.sh @@ -0,0 +1,66 @@ +#!/bin/sh -x + +# Credit: http://www.aisecure.net/2011/05/01/root-on-zfs-freebsd-current/ + +NAME=$1 + +# create disks +gpart create -s gpt ada0 +gpart add -t freebsd-boot -l boot -b 40 -s 512K ada0 +gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 +gpart add -t freebsd-ufs -l root -b 1M -s 2G ada0 +gpart add -t freebsd-swap -l swap -s 512M ada0 +gpart add -t freebsd-ufs -l var -s 1G ada0 +gpart add -t freebsd-ufs -l tmp -s 512M ada0 +gpart add -t freebsd-ufs -l usr -a 1M ada0 + +# create filesystems +newfs -U /dev/gpt/root +newfs -U /dev/gpt/var +newfs -U /dev/gpt/tmp +newfs -U /dev/gpt/usr + +# mount the filesystems +mount /dev/gpt/root /mnt +mkdir /mnt/var && mount /dev/gpt/var /mnt/var +mkdir /mnt/tmp && mount /dev/gpt/tmp /mnt/tmp +mkdir /mnt/usr && mount /dev/gpt/usr /mnt/usr + +# correct permissions +chmod 1777 /mnt/tmp +mkdir /mnt/var/tmp && chmod 1777 /mnt/var/tmp +cd /mnt && mkdir usr/home && ln -s usr/home home + +# Install the OS +cd /usr/freebsd-dist +cat base.txz | tar --unlink -xpJf - -C /mnt +cat lib32.txz | tar --unlink -xpJf - -C /mnt +cat kernel.txz | tar --unlink -xpJf - -C /mnt +cat src.txz | tar --unlink -xpJf - -C /mnt + +# Enable required services +cat >> /mnt/etc/rc.conf << EOT +hostname="${NAME}" +ifconfig_em0="dhcp" +sshd_enable="YES" +EOT + +# Enable swap +cat >> /mnt/etc/fstab << EOT +/dev/gpt/swap none swap sw 0 0 +/dev/gpt/root / ufs rw 1 1 +/dev/gpt/var /var ufs rw 1 1 +/dev/gpt/tmp /tmp ufs rw 1 1 +/dev/gpt/usr /usr ufs rw 1 1 +EOT + +# Install a few requirements +touch /mnt/etc/resolv.conf +echo 'PermitRootLogin yes' >> /mnt/etc/ssh/sshd_config + +# Set up user accounts +mkdir /mnt/usr/home/vagrant && chown 1001:1001 /mnt/home/vagrant +echo "vagrant" | pw -V /mnt/etc useradd vagrant -h 0 -s csh -G wheel -d /home/vagrant -c "Vagrant User" +echo "vagrant" | pw -V /mnt/etc usermod root -h 0 + +reboot