Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Big rewrite to deal with installing RVM via the vagrant user, not root

  • Loading branch information...
commit ba9d9373e04f207de15c9698d531e583e2381626 1 parent 39ad8a7
Lee Thompson authored
2  templates/funtoo-latest-generic_64-stable/definition.rb
@@ -30,6 +30,6 @@
30 30 :ssh_host_port => "7222", :ssh_guest_port => "22",
31 31 :sudo_cmd => "cat '%f'|su -",
32 32 :shutdown_cmd => "shutdown -p now",
33   - :postinstall_files => [ "postinstall.sh"],:postinstall_timeout => "15000"
  33 + :postinstall_files => [ "postinstall.sh", "postinstall2.sh" ], :postinstall_timeout => "15000"
34 34 }
35 35 )
78 templates/funtoo-latest-generic_64-stable/postinstall.sh
@@ -65,13 +65,13 @@ chroot /mnt/funtoo env-update
65 65 chroot /mnt/funtoo emerge --sync
66 66
67 67 # California dreamin
68   -cd etc
  68 +cd /mnt/funtoo/etc
69 69 rm -f localtime
70 70 ln -s ../usr/share/zoneinfo/America/Los_Angeles localtime
71 71 cd /mnt/funtoo
72 72
73 73 # get fstab defined
74   -cat <<FSTABEOF > ./etc/fstab
  74 +cat <<FSTABEOF > /mnt/funtoo/etc/fstab
75 75 # The root filesystem should have a pass number of either 0 or 1.
76 76 # All other filesystems should have a pass number of 0 or greater than 1.
77 77 #
@@ -93,6 +93,7 @@ chroot /mnt/funtoo rc-update add dhcpcd default
93 93 echo 'MAKEOPTS="-j9"' >> /mnt/funtoo/etc/make.conf
94 94 #echo 'MAKEOPTS="-j9"' >> /mnt/funtoo/etc/genkernel.conf
95 95 echo "sys-kernel/sysrescue-std-sources binary" >> /mnt/funtoo/etc/portage/package.use
  96 +echo "app-emulation/virtualbox-guest-additions" >> /mnt/funtoo/etc/portage/package.keywords
96 97 echo 'MAKEOPTS="-j9" emerge sysrescue-std-sources' | chroot /mnt/funtoo /bin/bash -
97 98
98 99 # Make the disk bootable
@@ -121,28 +122,20 @@ GRUBCONF
121 122 chroot /mnt/funtoo grub-install --no-floppy /dev/sda
122 123 chroot /mnt/funtoo boot-update
123 124
124   -#Root password, decided vagrant sudo was better, commented out
125   -###chroot /mnt/funtoo /bin/bash <<ENDCHROOT
126   -###passwd<<EOF
127   -###vagrant
128   -###vagrant
129   -###EOF
130   -###ENDCHROOT
  125 +#Root password, needed since we're a two step installation
  126 +chroot /mnt/funtoo /bin/bash <<ENDCHROOT
  127 +passwd<<EOF
  128 +vagrant
  129 +vagrant
  130 +EOF
  131 +ENDCHROOT
131 132
132 133 #create vagrant user with password set to vagrant
133 134 chroot /mnt/funtoo groupadd -r vagrant
134   -chroot /mnt/funtoo useradd -m -r vagrant -g vagrant -G wheel -p '$1$MPmczGP9$1SeNO4bw5YgiEJuo/ZkWq1' -c "Added by vagrant, veewee basebox creation"
  135 +chroot /mnt/funtoo groupadd rvm
  136 +chroot /mnt/funtoo useradd -m -r vagrant -g vagrant -G wheel,rvm -p '$1$MPmczGP9$1SeNO4bw5YgiEJuo/ZkWq1' -c "Added by vagrant, veewee basebox creation"
135 137 chroot /mnt/funtoo rc-update add sshd default
136 138
137   -# Cron & Syslog
138   -chroot /mnt/funtoo emerge -u metalog vixie-cron
139   -chroot /mnt/funtoo rc-update add metalog default
140   -chroot /mnt/funtoo rc-update add vixie-cron default
141   -
142   -#Get an editor going
143   -chroot /mnt/funtoo emerge -u vim
144   -echo "EDITOR=/usr/bin/vim" > /mnt/funtoo/etc/env.d/99editor
145   -
146 139 #Allow external ssh
147 140 echo 'sshd:ALL' > /mnt/funtoo/etc/hosts.allow
148 141 echo 'ALL:ALL' > /mnt/funtoo/etc/hosts.deny
@@ -151,6 +144,7 @@ echo 'ALL:ALL' > /mnt/funtoo/etc/hosts.deny
151 144 chroot /mnt/funtoo emerge -u sudo
152 145 echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /mnt/funtoo/etc/sudoers
153 146
  147 +
154 148 #Installing vagrant keys
155 149 chroot /mnt/funtoo emerge -u wget
156 150
@@ -162,56 +156,22 @@ wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/key
162 156 chmod 600 /mnt/funtoo/home/vagrant/.ssh/authorized_keys
163 157 chown -R ${VAGRANTID} /mnt/funtoo/home/vagrant/.ssh
164 158
165   -# Get ruby and rvm all setup...
166   -chroot /mnt/funtoo emerge -u git curl gcc automake autoconf m4
167   -chroot /mnt/funtoo emerge -u libiconv readline zlib openssl libyaml sqlite libxslt
168   -
169   -# Lots of problems if you install as root so we'll use sudo like to docs describe
170   -chroot --userspec=${VAGRANTID} /mnt/funtoo /bin/bash <<ENDRVM
171   -sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
172   -sudo usermod -G rvm vagrant
173   -ENDRVM
174   -
175   -chroot /mnt/funtoo env-update
176   -# Log back in which picks new group membership and /etc/profile.d/rvm.sh
177   -chroot --userspec=${VAGRANTID} /mnt/funtoo /bin/bash <<ENDRUBY
178   -source /etc/profile
179   -rvm install 1.8.7
180   -rvm use 1.8.7 --default
181   -rvm gemset create global
182   -rvm use @global
183   -
184   -#Installing chef & puppet
185   -gem install chef
186   -gem install puppet
187   -ENDRUBY
188   -
189   -
190   -echo "$(date '+%Y-%m-%d')" > /mnt/funtoo/etc/veewee_bld_date
191 159 /bin/cp -f /root/.vbox_version /mnt/funtoo/home/vagrant/.vbox_version
  160 +/bin/cp -f /etc/vagrant_box_build_time /mnt/funtoo/etc/vagrant_box_build_time
192 161 chown -R ${VAGRANTID} /mnt/funtoo/home/vagrant/.vbox_version
193   -VBOX_VERSION=$(cat /root/.vbox_version)
194   -
195   -#Kernel headers
196   -chroot /mnt/funtoo "emerge -u sys-kernel/linux-headers"
197   -
198   -#Installing the virtualbox guest additions
199   -echo "app-emulation/virtualbox-guest-additions" >> /mnt/funtoo/etc/portage/package.keywords
200   -chroot /mnt/funtoo emerge app-emulation/virtualbox-guest-additions
201   -chroot /mnt/funtoo rc-update add virtualbox-guest-additions default
202   -
203   -rm -rf /mnt/funtoo/usr/portage/distfiles/*
204 162
205 163 # veewee validate uses password authentication
206 164 sed -i -e 's:PasswordAuthentication no:PasswordAuthentication yes:' /mnt/funtoo/etc/ssh/sshd_config
207 165
  166 +#Get an editor going
  167 +chroot /mnt/funtoo emerge -u vim
  168 +echo "EDITOR=/usr/bin/vim" > /mnt/funtoo/etc/env.d/99editor
208 169 chroot /mnt/funtoo env-update
209 170
210   -rm /mnt/funtoo/stage3*.tar.xz
211 171
212   -exit
213 172 cd /
214   -umount /mnt/funtoo/{proc,sys,dev}
  173 +/etc/rc.d/network stop
  174 +umount /mnt/funtoo/{boot,proc,dev}
215 175 umount /mnt/funtoo
216 176
217 177 reboot
75 templates/funtoo-latest-generic_64-stable/postinstall2.sh
... ... @@ -0,0 +1,75 @@
  1 +#!/bin/bash
  2 +
  3 +# Wanted multi-user RVM (ruby version manager) setup. It got really hacky.
  4 +# Couldn't get the su command to work in the chroot so split the install into two
  5 +# phases, one in chroot, and the second phase in the installed kernel.
  6 +# Ruby's RVM needs to be installed by a user not root for multi-user use.
  7 +# All this would go away in single user install of RVM
  8 +
  9 +# A bit better security, but still your root and vagrant accounts are wide open!
  10 +echo -e "PermitRootLogin no\nAllowUsers vagrant" >> /etc/ssh/sshd_config
  11 +
  12 +# Cron & Syslog
  13 +emerge -u metalog vixie-cron
  14 +rc-update add metalog default
  15 +rc-update add vixie-cron default
  16 +
  17 +# Get ruby and rvm all setup...
  18 +emerge -u git curl gcc automake autoconf m4
  19 +emerge -u libiconv readline zlib openssl libyaml sqlite libxslt
  20 +
  21 +# What a PITA, wanted to get a shared RVM setup, but that can't be installed by root
  22 +# Starting to feel like a matryoshka doll...
  23 +# Setup so you can SSH into the vagrant account
  24 +wget --no-check-certificate 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant' -O /tmp/sshkey
  25 +chmod 600 /tmp/sshkey
  26 +
  27 +cat <<SSHCONF > /tmp/sshvagrant
  28 +Host me
  29 + HostName 127.0.0.1
  30 + User vagrant
  31 + Port 22
  32 + UserKnownHostsFile /dev/null
  33 + StrictHostKeyChecking no
  34 + PasswordAuthentication no
  35 + IdentityFile /tmp/sshkey
  36 + IdentitiesOnly yes
  37 +SSHCONF
  38 +
  39 +cat <<GEMINST > /tmp/sshgems
  40 +echo -e "\n***\n*** My id is yuck ***\n***\n"
  41 +
  42 +# Lots of problems if you install as root so we'll use sudo like to docs describe
  43 +sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
  44 +sudo env-update
  45 +source /etc/profile
  46 +
  47 +# Install ruby and gems into rvm
  48 +rvm install 1.8.7
  49 +rvm use 1.8.7 --default
  50 +rvm gemset create global
  51 +rvm use @global
  52 +
  53 +#Installing chef & puppet
  54 +gem install chef
  55 +gem install puppet
  56 +GEMINST
  57 +
  58 +chmod 755 /tmp/sshgems
  59 +sed -i -e "s,yuck,$(id)," /tmp/sshgems
  60 +ssh -F /tmp/sshvagrant me /tmp/sshgems
  61 +
  62 +#Kernel headers
  63 +emerge -u sys-kernel/linux-headers
  64 +
  65 +#Installing the virtualbox guest additions
  66 +emerge app-emulation/virtualbox-guest-additions
  67 +rc-update add virtualbox-guest-additions default
  68 +
  69 +env-update
  70 +
  71 +rm -rf /usr/portage/distfiles/*
  72 +chmod 655 /tmp/sshkey
  73 +rm /tmp/ssh*
  74 +rm /stage3*.tar.xz
  75 +

0 comments on commit ba9d937

Please sign in to comment.
Something went wrong with that request. Please try again.