From baedd4684990db7d7cd699a3f6e71f9a820c167e Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Wed, 28 Dec 2011 20:32:40 -0600 Subject: [PATCH 1/6] add a funtoo machine --- .../definition.rb | 35 ++++ .../postinstall.sh | 195 ++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 templates/funtoo-latest-generic_64-stable/definition.rb create mode 100644 templates/funtoo-latest-generic_64-stable/postinstall.sh diff --git a/templates/funtoo-latest-generic_64-stable/definition.rb b/templates/funtoo-latest-generic_64-stable/definition.rb new file mode 100644 index 00000000..119bb451 --- /dev/null +++ b/templates/funtoo-latest-generic_64-stable/definition.rb @@ -0,0 +1,35 @@ +Veewee::Session.declare( { + :cpu_count => '4', :memory_size=> '1536', + :disk_size => '10140', :disk_format => 'VDI',:hostiocache => 'off', + :os_type_id => 'Gentoo', # Funtoo is a GIT based gentoo derivative + :iso_file => "install-amd64-minimal-20111013.iso", + :iso_src => "http://ftp.osuosl.org/pub/gentoo/releases/amd64/autobuilds/20111208/install-amd64-minimal-20111208.iso", + :iso_md5 => "8c4e10aaaa7cce35503c0d23b4e0a42a", + :iso_download_timeout => "1000", + :boot_wait => "1", + :boot_cmd_sequence => [ + ''*2, + 'gentoo-nofb', + ''*10, + '', + ''*10, + 'net-setup eth0', + '', + '2', + '1', + 'ifconfig -a ', + #'sleep 5 ;curl http://%IP%:%PORT%/stages.sh -o stages.sh &&', + #'bash stages.sh &', + 'passwd', + 'vagrant', + 'vagrant', + '/etc/init.d/sshd start' + ], + :kickstart_port => "7122", :kickstart_timeout => "10000",:kickstart_file => "", + :ssh_login_timeout => "10000",:ssh_user => "root", :ssh_password => "vagrant",:ssh_key => "", + :ssh_host_port => "7222", :ssh_guest_port => "22", + :sudo_cmd => "cat '%f'|su -", + :shutdown_cmd => "shutdown -p now", + :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000" + } +) diff --git a/templates/funtoo-latest-generic_64-stable/postinstall.sh b/templates/funtoo-latest-generic_64-stable/postinstall.sh new file mode 100644 index 00000000..d76b89bc --- /dev/null +++ b/templates/funtoo-latest-generic_64-stable/postinstall.sh @@ -0,0 +1,195 @@ +#!/bin/bash + +date > /etc/vagrant_box_build_time + +#Based on http://www.funtoo.org/wiki/Funtoo_Linux_Installation + +#Partition the disk +#This assumes a predefined layout - customize to your own liking + +#/boot -> /dev/sda1 200M +#swap -> /dev/sda2 1.5G +#root -> /dev/sda3 Rest of space and bootable + +sfdisk --force /dev/sda -uM< ./etc/fstab +# The root filesystem should have a pass number of either 0 or 1. +# All other filesystems should have a pass number of 0 or greater than 1. +# +# See the manpage fstab(5) for more information. +# +# + +/dev/sda1 /boot ext2 noauto,noatime 1 2 +/dev/sda2 none swap sw 0 0 +/dev/sda3 / ext4 noatime 0 1 +#/dev/cdrom /mnt/cdrom auto noauto,ro 0 0 +none /dev/shm tmpfs nodev,nosuid,noexec 0 0 +FSTABEOF + +# dhcp +echo "rc-update add dhcpcd default" | chroot /mnt/funtoo /bin/bash - + +# Get the kernel sources +echo "sys-kernel/sysrescue-std-sources binary" >> ./etc/portage/package.use +echo "emerge sysrescue-std-sources" | chroot /mnt/funtoo /bin/bash - + +# Make the disk bootable +echo "emerge boot-update" | chroot /mnt/funtoo /bin/bash - +echo 'MAKEOPTS="-j9"' >> /mnt/funtoo/etc/make.conf + +cat < ./etc/boot.conf +boot { + generate grub + default "Funtoo Linux genkernel" + timeout 3 +} + +"Funtoo Linux" { + kernel bzImage[-v] + # params += nomodeset +} + +"Funtoo Linux genkernel" { + kernel kernel[-v] + initrd initramfs[-v] + params += real_root=auto + # params += nomodeset +} +GRUBCONF + +echo "grub-install --no-floppy /dev/sda" | chroot /mnt/funtoo /bin/bash - +echo "boot-update" | chroot /mnt/funtoo /bin/bash - + + +#We need some things to do here + +#Root password +chroot /mnt/funtoo /bin/bash < /etc/hosts.allow" | chroot /mnt/funtoo /bin/bash - +echo "echo 'ALL:ALL' > /etc/hosts.deny" | chroot /mnt/funtoo /bin/bash - + +#Configure Sudo +chroot /mnt/funtoo emerge sudo +echo "echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" | chroot /mnt/funtoo /bin/bash - + +#Installing vagrant keys +chroot /mnt/funtoo emerge wget + +echo "creating vagrant ssh keys" +chroot /mnt/funtoo mkdir /home/vagrant/.ssh +chroot /mnt/funtoo chmod 700 /home/vagrant/.ssh +chroot /mnt/funtoo cd /home/vagrant/.ssh +chroot /mnt/funtoo wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub' -O /home/vagrant/.ssh/authorized_keys +chroot /mnt/funtoo chmod 600 /home/vagrant/.ssh/authorized_keys +chroot /mnt/funtoo chown -R vagrant /home/vagrant/.ssh + +#This could be done in postinstall +#reboot + +#get some ruby running +chroot /mnt/funtoo emerge git curl gcc automake m4 +chroot /mnt/funtoo emerge libiconv readline zlib openssl curl git libyaml sqlite libxslt +echo "bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)"| chroot /mnt/funtoo /bin/bash - +echo "/usr/local/rvm/bin/rvm install ruby-1.8.7 "| chroot /mnt/funtoo /bin/bash - +echo "/usr/local/rvm/bin/rvm use ruby-1.8.7 --default "| chroot /mnt/funtoo /bin/bash - + +#Installing chef & Puppet +echo ". /usr/local/rvm/scripts/rvm ; gem install chef --no-ri --no-rdoc"| chroot /mnt/funtoo /bin/bash - +echo ". /usr/local/rvm/scripts/rvm ; gem install puppet --no-ri --no-rdoc"| chroot /mnt/funtoo /bin/bash - + + +echo "adding rvm to global bash rc" +echo "echo '. /usr/local/rvm/scripts/rvm' >> /etc/bash/bash.rc" | chroot /mnt/funtoo /bin/bash - + +/bin/cp -f /root/.vbox_version /mnt/funtoo/home/vagrant/.vbox_version +VBOX_VERSION=$(cat /root/.vbox_version) + +#Kernel headers +echo "emerge =sys-kernel/linux-headers-2.6.39" | chroot /mnt/funtoo /bin/bash - + +#Installing the virtualbox guest additions +cat < /etc/portage/package.keywords +=app-emulation/virtualbox-guest-additions-4.1.6-r1 +KEYWORDSEOF +emerge =app-emulation/virtualbox-guest-additions-4.1.6-r1 +rc-update add virtualbox-guest-additions default +EOF + +rm -rf /mnt/funtoo/usr/portage/distfiles +mkdir /mnt/funtoo/usr/portage/distfiles +echo "chown portage:portage /usr/portage/distfiles" | chroot /mnt/funtoo /bin/bash - + +echo "sed -i 's:^DAEMONS\(.*\))$:DAEMONS\1 rc.vboxadd):' /etc/rc.conf" | chroot /mnt/funtoo /bin/bash - + +exit +cd / +umount /mnt/funtoo/{proc,sys,dev} +umount /mnt/funtoo + +reboot From 6d144c52162d313cb2605e2e16bbdd11bace0acc Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Thu, 29 Dec 2011 02:25:19 -0600 Subject: [PATCH 2/6] fix partition table for bigger GPT style disk instead of old MBR --- templates/funtoo-latest-generic_64-stable/definition.rb | 4 ++-- templates/funtoo-latest-generic_64-stable/postinstall.sh | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/funtoo-latest-generic_64-stable/definition.rb b/templates/funtoo-latest-generic_64-stable/definition.rb index 119bb451..6f76ec3f 100644 --- a/templates/funtoo-latest-generic_64-stable/definition.rb +++ b/templates/funtoo-latest-generic_64-stable/definition.rb @@ -1,5 +1,5 @@ Veewee::Session.declare( { - :cpu_count => '4', :memory_size=> '1536', + :cpu_count => 8'', :memory_size=> '1536', :disk_size => '10140', :disk_format => 'VDI',:hostiocache => 'off', :os_type_id => 'Gentoo', # Funtoo is a GIT based gentoo derivative :iso_file => "install-amd64-minimal-20111013.iso", @@ -30,6 +30,6 @@ :ssh_host_port => "7222", :ssh_guest_port => "22", :sudo_cmd => "cat '%f'|su -", :shutdown_cmd => "shutdown -p now", - :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "10000" + :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "15000" } ) diff --git a/templates/funtoo-latest-generic_64-stable/postinstall.sh b/templates/funtoo-latest-generic_64-stable/postinstall.sh index d76b89bc..23bcbdd3 100644 --- a/templates/funtoo-latest-generic_64-stable/postinstall.sh +++ b/templates/funtoo-latest-generic_64-stable/postinstall.sh @@ -7,12 +7,12 @@ date > /etc/vagrant_box_build_time #Partition the disk #This assumes a predefined layout - customize to your own liking -#/boot -> /dev/sda1 200M +#/boot -> /dev/sda1 200M, need to skip a few meg for new GPT instead of old MBR #swap -> /dev/sda2 1.5G #root -> /dev/sda3 Rest of space and bootable sfdisk --force /dev/sda -uM<> ./etc/portage/package.use echo "emerge sysrescue-std-sources" | chroot /mnt/funtoo /bin/bash - +# Fix a package blocker problem with the current stage3 tarball +#echo "emerge -u sysvinit" | chroot /mnt/funtoo /bin/bash - + # Make the disk bootable echo "emerge boot-update" | chroot /mnt/funtoo /bin/bash - echo 'MAKEOPTS="-j9"' >> /mnt/funtoo/etc/make.conf From 01d259949b1ccc6a39dc0db8e8b1f779d0446a06 Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Thu, 29 Dec 2011 02:27:53 -0600 Subject: [PATCH 3/6] fix typeo --- templates/funtoo-latest-generic_64-stable/definition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/funtoo-latest-generic_64-stable/definition.rb b/templates/funtoo-latest-generic_64-stable/definition.rb index 6f76ec3f..95fb6b69 100644 --- a/templates/funtoo-latest-generic_64-stable/definition.rb +++ b/templates/funtoo-latest-generic_64-stable/definition.rb @@ -1,5 +1,5 @@ Veewee::Session.declare( { - :cpu_count => 8'', :memory_size=> '1536', + :cpu_count => '8', :memory_size=> '1536', :disk_size => '10140', :disk_format => 'VDI',:hostiocache => 'off', :os_type_id => 'Gentoo', # Funtoo is a GIT based gentoo derivative :iso_file => "install-amd64-minimal-20111013.iso", From d2de94fb15307be31948f31aca57846e4372a98a Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Thu, 29 Dec 2011 16:15:30 -0600 Subject: [PATCH 4/6] get the sfdisk partitioning correct for grub-install --- .../postinstall.sh | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/templates/funtoo-latest-generic_64-stable/postinstall.sh b/templates/funtoo-latest-generic_64-stable/postinstall.sh index 23bcbdd3..38f07a99 100644 --- a/templates/funtoo-latest-generic_64-stable/postinstall.sh +++ b/templates/funtoo-latest-generic_64-stable/postinstall.sh @@ -5,16 +5,30 @@ date > /etc/vagrant_box_build_time #Based on http://www.funtoo.org/wiki/Funtoo_Linux_Installation #Partition the disk -#This assumes a predefined layout - customize to your own liking - -#/boot -> /dev/sda1 200M, need to skip a few meg for new GPT instead of old MBR +# Gentoo live CD were using doesn't have gdisk and it looks +# to be interactive like fdisk. sfdisk is scribable but has issues. +# +# If you adjust, best to read this +# http://www.spinics.net/lists/util-linux-ng/msg03406.html +# +# Basically, all partitioning programs are wonky, sfdisk is scriptable, but likes +# to keeps things too tight skipping post-MBR spacing and "grub-install" fails later. +# Take the advice of the email and partition your drive with fdisk and dump it with +# +# sfdisk -uS -d /dev/sda +# +# and plug those values into the script. The --force by sector will get +# you what fdisk layed out and gets something grub-install can deal with. fun... +# +# +#/boot -> /dev/sda1 200M, left 2Meg of space for grub-install #swap -> /dev/sda2 1.5G #root -> /dev/sda3 Rest of space and bootable -sfdisk --force /dev/sda -uM< Date: Thu, 29 Dec 2011 23:24:18 -0600 Subject: [PATCH 5/6] make sure sshd will start, fix editor and add vagrant to wheel group --- templates/funtoo-latest-generic_64-stable/postinstall.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/funtoo-latest-generic_64-stable/postinstall.sh b/templates/funtoo-latest-generic_64-stable/postinstall.sh index 38f07a99..f322e343 100644 --- a/templates/funtoo-latest-generic_64-stable/postinstall.sh +++ b/templates/funtoo-latest-generic_64-stable/postinstall.sh @@ -134,8 +134,9 @@ vagrant EOF ENDCHROOT -#create vagrant user / password vagrant -chroot /mnt/funtoo useradd -m -r vagrant -p '$1$MPmczGP9$1SeNO4bw5YgiEJuo/ZkWq1' +#create vagrant user with password set to vagrant +chroot /mnt/funtoo useradd -m -r vagrant -g vagrant -G wheel -p '$1$MPmczGP9$1SeNO4bw5YgiEJuo/ZkWq1' +chroot /mnt/funtoo rc-update add sshd default # Cron & Syslog chroot /mnt/funtoo emerge metalog vixie-cron @@ -144,6 +145,7 @@ chroot /mnt/funtoo rc-update add vixie-cron default #Get an editor going chroot /mnt/funtoo emerge vim +echo "EDITOR=/usr/bin/vim" > /mnt/funtoo/etc/env.d/99editor #Allow external ssh echo "echo 'sshd:ALL' > /etc/hosts.allow" | chroot /mnt/funtoo /bin/bash - @@ -204,6 +206,8 @@ echo "chown portage:portage /usr/portage/distfiles" | chroot /mnt/funtoo /bin/ba echo "sed -i 's:^DAEMONS\(.*\))$:DAEMONS\1 rc.vboxadd):' /etc/rc.conf" | chroot /mnt/funtoo /bin/bash - +chroot /mnt/funtoo env-update + exit cd / umount /mnt/funtoo/{proc,sys,dev} From 594153de3dbe5fd82a98fd2fefb16fcd4f7c8e32 Mon Sep 17 00:00:00 2001 From: Lee Thompson Date: Fri, 30 Dec 2011 16:51:51 -0600 Subject: [PATCH 6/6] fix a bunch of veewee validate issues --- .../postinstall.sh | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/templates/funtoo-latest-generic_64-stable/postinstall.sh b/templates/funtoo-latest-generic_64-stable/postinstall.sh index f322e343..fd6ea4e8 100644 --- a/templates/funtoo-latest-generic_64-stable/postinstall.sh +++ b/templates/funtoo-latest-generic_64-stable/postinstall.sh @@ -123,28 +123,26 @@ GRUBCONF echo "grub-install --no-floppy /dev/sda" | chroot /mnt/funtoo /bin/bash - echo "boot-update" | chroot /mnt/funtoo /bin/bash - - -#We need some things to do here - -#Root password -chroot /mnt/funtoo /bin/bash < /mnt/funtoo/etc/env.d/99editor #Allow external ssh @@ -152,11 +150,11 @@ echo "echo 'sshd:ALL' > /etc/hosts.allow" | chroot /mnt/funtoo /bin/bash - echo "echo 'ALL:ALL' > /etc/hosts.deny" | chroot /mnt/funtoo /bin/bash - #Configure Sudo -chroot /mnt/funtoo emerge sudo +chroot /mnt/funtoo emerge -u sudo echo "echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" | chroot /mnt/funtoo /bin/bash - #Installing vagrant keys -chroot /mnt/funtoo emerge wget +chroot /mnt/funtoo emerge -u wget echo "creating vagrant ssh keys" chroot /mnt/funtoo mkdir /home/vagrant/.ssh @@ -166,23 +164,22 @@ chroot /mnt/funtoo wget --no-check-certificate 'https://raw.github.com/mitchellh chroot /mnt/funtoo chmod 600 /home/vagrant/.ssh/authorized_keys chroot /mnt/funtoo chown -R vagrant /home/vagrant/.ssh -#This could be done in postinstall -#reboot - -#get some ruby running -chroot /mnt/funtoo emerge git curl gcc automake m4 -chroot /mnt/funtoo emerge libiconv readline zlib openssl curl git libyaml sqlite libxslt -echo "bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)"| chroot /mnt/funtoo /bin/bash - -echo "/usr/local/rvm/bin/rvm install ruby-1.8.7 "| chroot /mnt/funtoo /bin/bash - -echo "/usr/local/rvm/bin/rvm use ruby-1.8.7 --default "| chroot /mnt/funtoo /bin/bash - +#get some ruby running, needed for veewee validate step +chroot /mnt/funtoo emerge -u git curl gcc automake autoconf m4 +chroot /mnt/funtoo emerge -u libiconv readline zlib openssl libyaml sqlite libxslt +chroot /mnt/funtoo /bin/bash <> /etc/bash/bash.rc" | chroot /mnt/funtoo /bin/bash - +usermod -G rvm vagrant +ENDRUBY /bin/cp -f /root/.vbox_version /mnt/funtoo/home/vagrant/.vbox_version VBOX_VERSION=$(cat /root/.vbox_version) @@ -204,7 +201,8 @@ rm -rf /mnt/funtoo/usr/portage/distfiles mkdir /mnt/funtoo/usr/portage/distfiles echo "chown portage:portage /usr/portage/distfiles" | chroot /mnt/funtoo /bin/bash - -echo "sed -i 's:^DAEMONS\(.*\))$:DAEMONS\1 rc.vboxadd):' /etc/rc.conf" | chroot /mnt/funtoo /bin/bash - +# veewee validate uses password authentication +sed -i -e 's:PasswordAuthentication no:PasswordAuthentication yes:' /mnt/funtoo/etc/ssh/sshd_config chroot /mnt/funtoo env-update