#!/bin/bash # based on http://www.funtoo.org/wiki/Funtoo_Linux_Installation ### SETTINGS ### # user passwords for password based ssh logins password_root=vagrant password_vagrant=vagrant # static versions of programs we install ruby_version="1.9.3-p286" # ...these are for rbenv and its plugins ruby-builder and rbenv-bundler rbenv_version="v0.3.0" ruby_builder_version="v20121022" rbenv_bundler_version="0.94" # these two (configuring the compiler) and the stage3 url can be changed to build a 32 bit system accept_keywords="amd64" chost="x86_64-pc-linux-gnu" # stage 3 filename and full url stage3file="stage3-latest.tar.xz" stage3url="http://ftp.heanet.ie/mirrors/funtoo/funtoo-current/x86-64bit/generic_64/$stage3file" # the public key for vagrants ssh vagrant_ssh_key_url="https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub" # timezone (as a subdirectory of /usr/share/zoneinfo) timezone="UTC" # number of cpus in the host system (to speed up make andfor kernel config) nr_cpus=$( "$chroot/etc/vagrant_box_build_time" chroot "$chroot" env-update #" activate client side dhcp and ssh by default chroot "$chroot" /bin/bash < "$chroot/etc/fstab" # /dev/sda1 /boot ext2 noauto,noatime 1 2 /dev/sda3 none swap sw 0 0 /dev/sda4 / ext4 noatime 0 1 none /dev/shm tmpfs nodev,nosuid,noexec 0 0 DATAEOF # set make options cat < "$chroot/etc/portage/make.conf" CHOST="$chost" CFLAGS="-mtune=generic -O2 -pipe" CXXFLAGS="\${CFLAGS}" ACCEPT_KEYWORDS="$accept_keywords" MAKEOPTS="-j$((1 + $nr_cpus)) -l$nr_cpus.5" EMERGE_DEFAULT_OPTS="-j$nr_cpus --quiet-build=y" FEATURES="\${FEATURES} parallel-fetch" # english only LINGUAS="" # for X support if needed INPUT_DEVICES="evdev" VIDEO_CARDS="virtualbox" DATAEOF # add package use flags cat <> "$chroot/etc/portage/package.use" sys-kernel/gentoo-sources symlink sys-kernel/genkernel -cryptsetup DATAEOF # add package keywords cat <> "$chroot/etc/portage/package.keywords" app-emulation/virtualbox-guest-additions DATAEOF # update portage tree to most current state chroot "$chroot" emerge --sync # set localtime chroot "$chroot" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime # get, configure, compile and install the kernel and modules chroot "$chroot" /bin/bash <>/usr/src/linux/.config # dependencies CONFIG_EXT4_FS=y CONFIG_EXT4_USE_FOR_EXT23=y CONFIG_EXT4_FS_XATTR=y CONFIG_SMP=y CONFIG_MODULE_UNLOAD=y CONFIG_DMA_SHARED_BUFFER=y # for VirtualBox # see http://en.gentoo-wiki.com/wiki/Virtualbox_Guest CONFIG_HIGH_RES_TIMERS=n CONFIG_X86_MCE=n CONFIG_SUSPEND=n CONFIG_HIBERNATION=n CONFIG_IDE=n CONFIG_NO_HZ=y CONFIG_SMP=y CONFIG_ACPI=y CONFIG_PNP=y CONFIG_ATA=y CONFIG_SATA_AHCI=y CONFIG_ATA_SFF=y CONFIG_ATA_PIIX=y CONFIG_PCNET32=y CONFIG_E1000=y CONFIG_INPUT_MOUSE=y CONFIG_DRM=y CONFIG_SND_INTEL8X0=m # for net fs CONFIG_AUTOFS4_FS=m CONFIG_NFS_V2=m CONFIG_NFS_V3=m CONFIG_NFS_V4=m CONFIG_NFSD=m CONFIG_CIFS=m CONFIG_CIFS_UPCAL=y CONFIG_CIFS_XATTR=y CONFIG_CIFS_DFS_UPCALL=y # reduce size CONFIG_NR_CPUS=$nr_cpus CONFIG_COMPAT_VDSO=n # propbably nice but not in defaults CONFIG_MODVERSIONS=y CONFIG_IKCONFIG_PROC=y CONFIG_SQUASHFS=y CONFIG_SQUASHFS_XATTR=y CONFIG_SQUASHFS_XZ=y #CONFIG_EFI_STUB=y #CONFIG_DEFAULT_DEADLINE=y #CONFIG_DEFAULT_CFQ=n #CONFIG_PREEMPT_NONE=y #CONFIG_PREEMPT_VOLUNTARY=n #CONFIG_HZ=100=y #CONFIG_HZ=1000=n # IPSec (I want to run tests with IPSec andSamba 4) CONFIG_NET_IPVTI=y CONFIG_INET_AH=y CONFIG_INET_ESP=y CONFIG_INET_IPCOMP=y CONFIG_INET_XFRM_MODE_TRANSPORT=y CONFIG_INET_XFRM_MODE_TUNNEL=y CONFIG_INET_XFRM_MODE_BEET=y CONFIG_INET6_AH=y CONFIG_INET6_ESP=y CONFIG_INET6_IPCOMP=y CONFIG_INET6_XFRM_MODE_TRANSPORT=y CONFIG_INET6_XFRM_MODE_TUNNEL=y CONFIG_INET6_XFRM_MODE_BEET=y # and some more crypto support... CONFIG_CRYPTO_USER=m CONFIG_CRYPTO_CTS=y CONFIG_CRYPTO_CTR=y CONFIG_CRYPTO_RMD128=y CONFIG_CRYPTO_RMD160=y CONFIG_CRYPTO_RMD256=y CONFIG_CRYPTO_RMD320=y CONFIG_CRYPTO_SHA1_SSSE3=m CONFIG_CRYPTO_SHA256=y CONFIG_CRYPTO_SHA512=y CONFIG_CRYPTO_AES_X86_64=y CONFIG_CRYPTO_AES_NI_INTEL=m CONFIG_CRYPTO_BLOWFISH_X86_64=y CONFIG_CRYPTO_SALSA20_X86_64=y CONFIG_CRYPTO_TWOFISH_X86_64_3WAY=y CONFIG_CRYPTO_DEFLATE=y EOF # build and install kernel, using the config created above genkernel --install --symlink --oldconfig all DATAEOF # install the virtualbox guest additions, add vagrant and root to group vboxguest # PREREQUISITE: kernel - we install a module, so we use the kernel sources chroot "$chroot" /bin/bash < /dev/null cat /tmp/ssh-root.pub >> "$chroot/root/.ssh/authorized_keys" # PREREQUISITE: virtualbox-guest-additions - the groups created on installation have to exist chroot $chroot /bin/bash < /etc/hosts.allow echo 'ALL:ALL' > /etc/hosts.deny echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers DATAEOF # configure ssh daemon # veewee validate uses password authentication (according to the other Funtoo-template), so we have to enable it cat < "$chroot/etc/ssh/sshd_config" HostBasedAuthentication no IgnoreUserKnownHosts yes PasswordAuthentication yes PermitRootLogin yes #PermitRootLogin without-password PermitUserEnvironment no PrintLastLog no PrintMotd no PubKeyAuthentication yes Subsystem sftp internal-sftp UseDNS no UsePAM yes UsePrivilegeSeparation sandbox DATAEOF # install rbenv, ruby and bundler. Configure rbenv for global usage so it's usable without home directory chroot "$chroot" /bin/bash <> "$chroot/etc/profile.d/rbenv.sh" # add rbenv support rbenv_base=/usr/local/lib/rbenv export PATH=\$PATH:\$rbenv_base/bin [ -n \$RBENV_ROOT ] && export RBENV_ROOT=\$rbenv_base/env eval "\$(rbenv init -)" DATAEOF # install ruby, bundler, chef and puppet chroot "$chroot" /bin/bash < "/usr/local/lib/rbenv/env/versions/$ruby_version/etc/gemrc" # disable rdoc and ri install: --no-rdoc --no-ri update: --no-rdoc --no-ri EOF # install required and desired gems gem install bundler chef puppet DATAEOF # install logger and cron chroot "$chroot" /bin/bash <