#!/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="ruby:2.0" #"1.9.3-p286" ruby_pretty="$(echo $ruby_version | tr -d [:.])" # 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 # http://ftp.osuosl.org/pub/funtoo/ # http://ftp.heanet.ie/mirrors/funtoo/ stage3file="stage3-latest.tar.xz" stage3url="http://ftp.osuosl.org/pub/funtoo/funtoo-stable/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_dir}/etc/vagrant_box_build_time" #chroot "${chroot_dir}" env-update #" activate client side dhcp and ssh by default chroot "${chroot_dir}" /bin/bash < "${chroot_dir}/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_dir}/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" GENTOO_MIRRORS="http://distfiles ${GENTOO_MIRRORS}" # no reason to keep these hanging around DISTDIR="/tmp/distfiles" # english only LINGUAS="" # get us some ruby RUBY_TARGETS="${ruby_pretty}" USE="ruby" # for X support if needed INPUT_DEVICES="evdev" VIDEO_CARDS="virtualbox" DATAEOF # add package use flags cat <> "${chroot_dir}/etc/portage/package.use" sys-kernel/gentoo-sources symlink sys-kernel/genkernel -cryptsetup DATAEOF # add package keywords cat <> "${chroot_dir}/etc/portage/package.keywords" app-emulation/virtualbox-guest-additions DATAEOF # add package keywords cat <> "${chroot_dir}/etc/portage/package.accept_keywords" dev-util/kbuild ~amd64 DATAEOF # update portage tree to most current state git://github.com/funtoo/ports-2012.git remote_git='git://github.com/funtoo/ports-2012.git' # 'git://home/ports-2012.git' echo "cloning to /usr/portage" chroot "${chroot_dir}" git clone --depth 1 ${remote_git} /usr/portage chroot "${chroot_dir}" emerge --sync chroot "${chroot_dir}" env-update # set localtime chroot "${chroot_dir}" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime # get, configure, compile and install the kernel and modules chroot "${chroot_dir}" /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_dir}" /bin/bash < /dev/null cat /tmp/ssh-root.pub >> "${chroot_dir}/root/.ssh/authorized_keys" # PREREQUISITE: virtualbox-guest-additions - the groups created on installation have to exist chroot ${chroot_dir} /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_dir}/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 ruby, bundler, chef and puppet echo "Install ruby, bundler, chef and puppet" chroot "${chroot_dir}" /bin/bash < "/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_dir}" /bin/bash < grub.cfg cat grub.cfg DATAEOF ### patch to make lib/vagrant/guest/gentoo.rb happy # not needed for much longer chroot "${chroot_dir}" /bin/bash < /dev/null 2>&1 # cleanup time... chroot "${chroot_dir}" /bin/bash <