veewee 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/Gemfile +4 -0
  2. data/README.md +1 -1
  3. data/doc/definition.md +18 -0
  4. data/doc/kvm.md +28 -1
  5. data/doc/template.md +53 -2
  6. data/lib/veewee/command/fusion.rb +37 -3
  7. data/lib/veewee/command/vagrant/basebox.rb +2 -0
  8. data/lib/veewee/command/vagrant/winrm.rb +39 -0
  9. data/lib/veewee/command/vbox.rb +18 -0
  10. data/lib/veewee/definition.rb +13 -3
  11. data/lib/veewee/error.rb +3 -0
  12. data/lib/veewee/provider/core/box.rb +7 -0
  13. data/lib/veewee/provider/core/box/build.rb +34 -14
  14. data/lib/veewee/provider/core/box/copy.rb +17 -0
  15. data/lib/veewee/provider/core/box/exec.rb +31 -12
  16. data/lib/veewee/provider/core/box/floppy.rb +1 -0
  17. data/lib/veewee/provider/core/box/halt.rb +7 -3
  18. data/lib/veewee/provider/core/box/validate_tags.rb +8 -2
  19. data/lib/veewee/provider/core/box/wincp.rb +120 -0
  20. data/lib/veewee/provider/core/box/winrm.rb +59 -0
  21. data/lib/veewee/provider/core/helper/comm.rb +47 -0
  22. data/lib/veewee/provider/core/helper/web.rb +20 -9
  23. data/lib/veewee/provider/core/helper/winrm.rb +167 -0
  24. data/lib/veewee/provider/kvm/box/create.rb +59 -3
  25. data/lib/veewee/provider/kvm/provider.rb +6 -6
  26. data/lib/veewee/provider/parallels/box/helper/buildinfo.rb +1 -1
  27. data/lib/veewee/provider/virtualbox/box.rb +1 -0
  28. data/lib/veewee/provider/virtualbox/box/build.rb +4 -2
  29. data/lib/veewee/provider/virtualbox/box/create.rb +32 -12
  30. data/lib/veewee/provider/virtualbox/box/helper/buildinfo.rb +6 -3
  31. data/lib/veewee/provider/virtualbox/box/helper/create.rb +20 -5
  32. data/lib/veewee/provider/virtualbox/box/helper/winrm_options.rb +31 -0
  33. data/lib/veewee/provider/virtualbox/box/up.rb +33 -12
  34. data/lib/veewee/provider/virtualbox/box/winrm.rb +13 -0
  35. data/lib/veewee/provider/vmfusion/box.rb +2 -0
  36. data/lib/veewee/provider/vmfusion/box/add_share.rb +18 -0
  37. data/lib/veewee/provider/vmfusion/box/build.rb +3 -1
  38. data/lib/veewee/provider/vmfusion/box/create.rb +7 -2
  39. data/lib/veewee/provider/vmfusion/box/helper/buildinfo.rb +9 -6
  40. data/lib/veewee/provider/vmfusion/box/helper/ip.rb +1 -1
  41. data/lib/veewee/provider/vmfusion/box/helper/winrm_options.rb +21 -0
  42. data/lib/veewee/provider/vmfusion/box/template.rb +7 -3
  43. data/lib/veewee/provider/vmfusion/box/template.vmx.erb +6 -0
  44. data/lib/veewee/provider/vmfusion/box/winrm.rb +12 -0
  45. data/lib/veewee/provider/vmfusion/provider.rb +7 -1
  46. data/lib/veewee/version.rb +1 -1
  47. data/templates/CentOS-5.6-x86_64-netboot-packages/definition.rb +16 -0
  48. data/templates/CentOS-5.6-x86_64-netboot-packages/ks.cfg +47 -0
  49. data/templates/CentOS-5.6-x86_64-netboot-packages/postinstall.sh +61 -0
  50. data/templates/Debian-7.0-b3-amd64-netboot/base.sh +27 -0
  51. data/templates/Debian-7.0-b3-amd64-netboot/chef.sh +2 -0
  52. data/templates/Debian-7.0-b3-amd64-netboot/cleanup-virtualbox.sh +4 -0
  53. data/templates/Debian-7.0-b3-amd64-netboot/cleanup.sh +17 -0
  54. data/templates/Debian-7.0-b3-amd64-netboot/definition.rb +51 -0
  55. data/templates/Debian-7.0-b3-amd64-netboot/preseed.cfg +313 -0
  56. data/templates/Debian-7.0-b3-amd64-netboot/puppet.sh +2 -0
  57. data/templates/Debian-7.0-b3-amd64-netboot/ruby.sh +10 -0
  58. data/templates/Debian-7.0-b3-amd64-netboot/vagrant.sh +25 -0
  59. data/templates/Debian-7.0-b3-amd64-netboot/virtualbox.sh +13 -0
  60. data/templates/Debian-7.0-b3-amd64-netboot/zerodisk.sh +3 -0
  61. data/templates/Fedora-18-i386/definition.rb +17 -0
  62. data/templates/Fedora-18-i386/ks.cfg +75 -0
  63. data/templates/Fedora-18-i386/postinstall.sh +38 -0
  64. data/templates/Fedora-18-x86_64/definition.rb +17 -0
  65. data/templates/Fedora-18-x86_64/ks.cfg +75 -0
  66. data/templates/Fedora-18-x86_64/postinstall.sh +38 -0
  67. data/templates/OracleLinux-6.3-x86_64-DVD/base.sh +30 -0
  68. data/templates/OracleLinux-6.3-x86_64-DVD/chef.sh +3 -0
  69. data/templates/OracleLinux-6.3-x86_64-DVD/cleanup.sh +5 -0
  70. data/templates/OracleLinux-6.3-x86_64-DVD/definition.rb +40 -0
  71. data/templates/OracleLinux-6.3-x86_64-DVD/ks.cfg +42 -0
  72. data/templates/OracleLinux-6.3-x86_64-DVD/puppet.sh +12 -0
  73. data/templates/OracleLinux-6.3-x86_64-DVD/ruby.sh +3 -0
  74. data/templates/OracleLinux-6.3-x86_64-DVD/vagrant.sh +18 -0
  75. data/templates/OracleLinux-6.3-x86_64-DVD/virtualbox.sh +8 -0
  76. data/templates/OracleLinux-6.3-x86_64-DVD/zerodisk.sh +3 -0
  77. data/templates/funtoo-latest-x86_64/definition.rb +37 -0
  78. data/templates/funtoo-latest-x86_64/postinstall.sh +401 -0
  79. data/templates/openbsd50_amd64/definition.rb +3 -2
  80. data/templates/openbsd50_amd64/postinstall.sh +4 -4
  81. data/templates/openbsd50_i386/definition.rb +4 -4
  82. data/templates/openbsd52_amd64/README +28 -0
  83. data/templates/openbsd52_amd64/definition.rb +85 -0
  84. data/templates/openbsd52_amd64/postinstall.sh +81 -0
  85. data/templates/openbsd52_i386/README +28 -0
  86. data/templates/openbsd52_i386/definition.rb +85 -0
  87. data/templates/openbsd52_i386/postinstall.sh +81 -0
  88. data/templates/windows-2008R1-serverstandard-amd64/Autounattend.xml +6 -6
  89. data/templates/windows-2008R1-serverweb-amd64/install-winrm.bat +1 -1
  90. data/templates/windows-2008R2-serverstandard-amd64-winrm/Autounattend.xml +224 -0
  91. data/templates/windows-2008R2-serverstandard-amd64-winrm/README.md +87 -0
  92. data/templates/windows-2008R2-serverstandard-amd64-winrm/definition.rb +33 -0
  93. data/templates/windows-2008R2-serverstandard-amd64-winrm/install-chef.bat +2 -0
  94. data/templates/windows-2008R2-serverstandard-amd64-winrm/install-vbox.bat +4 -0
  95. data/templates/windows-2008R2-serverstandard-amd64-winrm/oracle-cert.cer +0 -0
  96. data/templates/windows-2008R2-serverstandard-amd64-winrm/postinstall.sh +74 -0
  97. data/templates/windows-7-enterprise-amd64-winrm/Autounattend.xml +227 -0
  98. data/templates/windows-7-enterprise-amd64-winrm/README.md +52 -0
  99. data/templates/windows-7-enterprise-amd64-winrm/definition.rb +27 -0
  100. data/templates/windows-7-enterprise-amd64-winrm/install-chef.bat +2 -0
  101. data/templates/windows-7-enterprise-amd64-winrm/install-fusion.bat +18 -0
  102. data/templates/windows-7-enterprise-amd64-winrm/install-puppet.bat +4 -0
  103. data/templates/windows-7-enterprise-amd64-winrm/install-vbox.bat +4 -0
  104. data/templates/windows-7-enterprise-amd64-winrm/oracle-cert.cer +0 -0
  105. data/templates/windows-7-enterprise-amd64-winrm/postinstall.bat +74 -0
  106. data/validation/veewee-windows.feature +34 -0
  107. data/veewee.gemspec +1 -1
  108. metadata +73 -7
@@ -0,0 +1,8 @@
1
+ # Installing the virtualbox guest additions
2
+ VBOX_VERSION=$(cat /home/veewee/.vbox_version)
3
+ cd /tmp
4
+ mount -o loop /home/veewee/VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
5
+ sh /mnt/VBoxLinuxAdditions.run
6
+ umount /mnt
7
+ rm -rf /home/veewee/VBoxGuestAdditions_*.iso
8
+
@@ -0,0 +1,3 @@
1
+ # Zero out the free space to save space in the final image:
2
+ dd if=/dev/zero of=/EMPTY bs=1M
3
+ rm -f /EMPTY
@@ -0,0 +1,37 @@
1
+ password = 'vagrant'
2
+
3
+ Veewee::Session.declare({
4
+ :hostiocache => 'off',
5
+ :cpu_count => '1',
6
+ :memory_size=> '384',
7
+ :disk_size => '10140',
8
+ :disk_format => 'VDI',
9
+ :os_type_id => 'Gentoo_64', # for 32bit, change to 'Gentoo'
10
+ :iso_file => "systemrescuecd-x86-3.0.0.iso",
11
+ :iso_src => "http://freefr.dl.sourceforge.net/project/systemrescuecd/sysresccd-x86/3.0.0/systemrescuecd-x86-3.0.0.iso",
12
+ :iso_md5 => "6bb6241af752b1d6dab6ae9e6e3e770e",
13
+ :iso_download_timeout => "1000",
14
+ :boot_wait => "4",
15
+ :boot_cmd_sequence => [
16
+ '<Wait>'*1,
17
+ '<Enter>',
18
+ '<Wait>'*9,
19
+ '<Enter>',
20
+ '<Wait>'*12,
21
+ '<Enter><Wait>', # just in case we are out of sync
22
+ 'net-setup eth0<Enter><Wait><Enter>2<Enter>1<Enter><Wait><Wait>',
23
+ 'passwd<Enter><Wait><Wait>',
24
+ password + '<Enter><Wait>',
25
+ password + '<Enter><Wait><Wait>'
26
+ ],
27
+ :ssh_login_timeout => "10000",
28
+ :ssh_user => "root",
29
+ :ssh_password => password,
30
+ :ssh_key => "",
31
+ :ssh_host_port => "7222",
32
+ :ssh_guest_port => "22",
33
+ :sudo_cmd => "cat '%f'|su -",
34
+ :shutdown_cmd => "shutdown -p now",
35
+ :postinstall_files => ["postinstall.sh"],
36
+ :postinstall_timeout => "15000"
37
+ })
@@ -0,0 +1,401 @@
1
+ #!/bin/bash
2
+ # based on http://www.funtoo.org/wiki/Funtoo_Linux_Installation
3
+
4
+ ### SETTINGS ###
5
+
6
+ # user passwords for password based ssh logins
7
+ password_root=vagrant
8
+ password_vagrant=vagrant
9
+
10
+ # static versions of programs we install
11
+ ruby_version="1.9.3-p286"
12
+ # ...these are for rbenv and its plugins ruby-builder and rbenv-bundler
13
+ rbenv_version="v0.3.0"
14
+ ruby_builder_version="v20121022"
15
+ rbenv_bundler_version="0.94"
16
+
17
+ # these two (configuring the compiler) and the stage3 url can be changed to build a 32 bit system
18
+ accept_keywords="amd64"
19
+ chost="x86_64-pc-linux-gnu"
20
+
21
+ # stage 3 filename and full url
22
+ stage3file="stage3-latest.tar.xz"
23
+ stage3url="http://ftp.heanet.ie/mirrors/funtoo/funtoo-current/x86-64bit/generic_64/$stage3file"
24
+
25
+ # the public key for vagrants ssh
26
+ vagrant_ssh_key_url="https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub"
27
+
28
+ # timezone (as a subdirectory of /usr/share/zoneinfo)
29
+ timezone="UTC"
30
+
31
+ # number of cpus in the host system (to speed up make andfor kernel config)
32
+ nr_cpus=$(</proc/cpuinfo grep processor|wc -l)
33
+
34
+
35
+ ### PARTITIONING AND FORMATTING ###
36
+
37
+ # for sgdisk (scripted gdisk) see: http://www.rodsbooks.com/gdisk/sgdisk.html
38
+ sgdisk -n 1:0:+128M -t 1:8300 -c 1:"linux-boot" \
39
+ -n 2:0:+32M -t 2:ef02 -c 2:"bios-boot" \
40
+ -n 3:0:+1G -t 3:8200 -c 3:"swap" \
41
+ -n 4:0:0 -t 4:8300 -c 4:"linux-root" \
42
+ -p /dev/sda
43
+
44
+ sleep 1
45
+
46
+ # format partitions, mount swap
47
+ mkswap /dev/sda3
48
+ swapon /dev/sda3
49
+ mkfs.ext2 /dev/sda1
50
+ mkfs.ext4 /dev/sda4
51
+
52
+ # this is our chroot directory for the installation
53
+ chroot=/mnt/gentoo
54
+
55
+ # mount other partitions
56
+ mount /dev/sda4 "$chroot" && cd "$chroot" && mkdir boot && mount /dev/sda1 boot
57
+
58
+
59
+ ### BASE-INSTALLATION ###
60
+
61
+ # load stage 3, unpack it, delete the stage3 archive file
62
+ wget -nv --tries=5 "$stage3url"
63
+ tar xpf "$stage3file" && rm "$stage3file"
64
+
65
+ # prepeare chroot, update env
66
+ mount --bind /proc "$chroot/proc"
67
+ mount --bind /dev "$chroot/dev"
68
+
69
+
70
+ ### INITIAL CONFIGURATION ###
71
+
72
+ # copy nameserver information, save build timestamp
73
+ cp /etc/resolv.conf "$chroot/etc/"
74
+ date -u > "$chroot/etc/vagrant_box_build_time"
75
+ chroot "$chroot" env-update
76
+
77
+ #" activate client side dhcp and ssh by default
78
+ chroot "$chroot" /bin/bash <<DATAEOF
79
+ rc-update add dhcpcd default
80
+ rc-update add sshd default
81
+ DATAEOF
82
+
83
+ # set fstab
84
+ cat <<DATAEOF > "$chroot/etc/fstab"
85
+ # <fs> <mountpoint> <type> <opts> <dump/pass>
86
+ /dev/sda1 /boot ext2 noauto,noatime 1 2
87
+ /dev/sda3 none swap sw 0 0
88
+ /dev/sda4 / ext4 noatime 0 1
89
+ none /dev/shm tmpfs nodev,nosuid,noexec 0 0
90
+ DATAEOF
91
+
92
+ # set make options
93
+ cat <<DATAEOF > "$chroot/etc/portage/make.conf"
94
+ CHOST="$chost"
95
+
96
+ CFLAGS="-mtune=generic -O2 -pipe"
97
+ CXXFLAGS="\${CFLAGS}"
98
+
99
+ ACCEPT_KEYWORDS="$accept_keywords"
100
+ MAKEOPTS="-j$((1 + $nr_cpus)) -l$nr_cpus.5"
101
+ EMERGE_DEFAULT_OPTS="-j$nr_cpus --quiet-build=y"
102
+ FEATURES="\${FEATURES} parallel-fetch"
103
+
104
+ # english only
105
+ LINGUAS=""
106
+
107
+ # for X support if needed
108
+ INPUT_DEVICES="evdev"
109
+ VIDEO_CARDS="virtualbox"
110
+ DATAEOF
111
+
112
+ # add package use flags
113
+ cat <<DATAEOF >> "$chroot/etc/portage/package.use"
114
+ sys-kernel/gentoo-sources symlink
115
+ sys-kernel/genkernel -cryptsetup
116
+ DATAEOF
117
+
118
+ # add package keywords
119
+ cat <<DATAEOF >> "$chroot/etc/portage/package.keywords"
120
+ app-emulation/virtualbox-guest-additions
121
+ DATAEOF
122
+
123
+ # update portage tree to most current state
124
+ chroot "$chroot" emerge --sync
125
+
126
+ # set localtime
127
+ chroot "$chroot" ln -sf "/usr/share/zoneinfo/$timezone" /etc/localtime
128
+
129
+ # get, configure, compile and install the kernel and modules
130
+ chroot "$chroot" /bin/bash <<DATAEOF
131
+ emerge sys-kernel/gentoo-sources sys-kernel/genkernel sys-boot/boot-update
132
+
133
+ # specialize for VirtualBox - use loaded modules in livecd
134
+ cd /usr/src/linux
135
+ # use a default configuration as a starting point, then disable all currently unused modules
136
+ make defconfig
137
+ #make localyesconfig
138
+
139
+ # add settings for VirtualBox kernels to end of .config
140
+ cat <<EOF >>/usr/src/linux/.config
141
+ # dependencies
142
+ CONFIG_EXT4_FS=y
143
+ CONFIG_EXT4_USE_FOR_EXT23=y
144
+ CONFIG_EXT4_FS_XATTR=y
145
+ CONFIG_SMP=y
146
+ CONFIG_MODULE_UNLOAD=y
147
+ CONFIG_DMA_SHARED_BUFFER=y
148
+ # for VirtualBox
149
+ # see http://en.gentoo-wiki.com/wiki/Virtualbox_Guest
150
+ CONFIG_HIGH_RES_TIMERS=n
151
+ CONFIG_X86_MCE=n
152
+ CONFIG_SUSPEND=n
153
+ CONFIG_HIBERNATION=n
154
+ CONFIG_IDE=n
155
+ CONFIG_NO_HZ=y
156
+ CONFIG_SMP=y
157
+ CONFIG_ACPI=y
158
+ CONFIG_PNP=y
159
+ CONFIG_ATA=y
160
+ CONFIG_SATA_AHCI=y
161
+ CONFIG_ATA_SFF=y
162
+ CONFIG_ATA_PIIX=y
163
+ CONFIG_PCNET32=y
164
+ CONFIG_E1000=y
165
+ CONFIG_INPUT_MOUSE=y
166
+ CONFIG_DRM=y
167
+ CONFIG_SND_INTEL8X0=m
168
+ # for net fs
169
+ CONFIG_AUTOFS4_FS=m
170
+ CONFIG_NFS_V2=m
171
+ CONFIG_NFS_V3=m
172
+ CONFIG_NFS_V4=m
173
+ CONFIG_NFSD=m
174
+ CONFIG_CIFS=m
175
+ CONFIG_CIFS_UPCAL=y
176
+ CONFIG_CIFS_XATTR=y
177
+ CONFIG_CIFS_DFS_UPCALL=y
178
+ # reduce size
179
+ CONFIG_NR_CPUS=$nr_cpus
180
+ CONFIG_COMPAT_VDSO=n
181
+ # propbably nice but not in defaults
182
+ CONFIG_MODVERSIONS=y
183
+ CONFIG_IKCONFIG_PROC=y
184
+ CONFIG_SQUASHFS=y
185
+ CONFIG_SQUASHFS_XATTR=y
186
+ CONFIG_SQUASHFS_XZ=y
187
+ #CONFIG_EFI_STUB=y
188
+ #CONFIG_DEFAULT_DEADLINE=y
189
+ #CONFIG_DEFAULT_CFQ=n
190
+ #CONFIG_PREEMPT_NONE=y
191
+ #CONFIG_PREEMPT_VOLUNTARY=n
192
+ #CONFIG_HZ=100=y
193
+ #CONFIG_HZ=1000=n
194
+ # IPSec (I want to run tests with IPSec andSamba 4)
195
+ CONFIG_NET_IPVTI=y
196
+ CONFIG_INET_AH=y
197
+ CONFIG_INET_ESP=y
198
+ CONFIG_INET_IPCOMP=y
199
+ CONFIG_INET_XFRM_MODE_TRANSPORT=y
200
+ CONFIG_INET_XFRM_MODE_TUNNEL=y
201
+ CONFIG_INET_XFRM_MODE_BEET=y
202
+ CONFIG_INET6_AH=y
203
+ CONFIG_INET6_ESP=y
204
+ CONFIG_INET6_IPCOMP=y
205
+ CONFIG_INET6_XFRM_MODE_TRANSPORT=y
206
+ CONFIG_INET6_XFRM_MODE_TUNNEL=y
207
+ CONFIG_INET6_XFRM_MODE_BEET=y
208
+ # and some more crypto support...
209
+ CONFIG_CRYPTO_USER=m
210
+ CONFIG_CRYPTO_CTS=y
211
+ CONFIG_CRYPTO_CTR=y
212
+ CONFIG_CRYPTO_RMD128=y
213
+ CONFIG_CRYPTO_RMD160=y
214
+ CONFIG_CRYPTO_RMD256=y
215
+ CONFIG_CRYPTO_RMD320=y
216
+ CONFIG_CRYPTO_SHA1_SSSE3=m
217
+ CONFIG_CRYPTO_SHA256=y
218
+ CONFIG_CRYPTO_SHA512=y
219
+ CONFIG_CRYPTO_AES_X86_64=y
220
+ CONFIG_CRYPTO_AES_NI_INTEL=m
221
+ CONFIG_CRYPTO_BLOWFISH_X86_64=y
222
+ CONFIG_CRYPTO_SALSA20_X86_64=y
223
+ CONFIG_CRYPTO_TWOFISH_X86_64_3WAY=y
224
+ CONFIG_CRYPTO_DEFLATE=y
225
+ EOF
226
+ # build and install kernel, using the config created above
227
+ genkernel --install --symlink --oldconfig all
228
+ DATAEOF
229
+
230
+ # install the virtualbox guest additions, add vagrant and root to group vboxguest
231
+ # PREREQUISITE: kernel - we install a module, so we use the kernel sources
232
+ chroot "$chroot" /bin/bash <<DATAEOF
233
+ emerge app-emulation/virtualbox-guest-additions
234
+ # we need this as gentoo doesn't do it on its own
235
+ groupadd -r vboxsf
236
+ mkdir /media && chgrp vboxsf /media
237
+ rc-update add virtualbox-guest-additions default
238
+ DATAEOF
239
+
240
+ # add default users and groups, setpasswords, configure privileges and install sudo
241
+ mkdir -p "$chroot/home/vagrant/.ssh"
242
+ chmod 700 "$chroot/home/vagrant/.ssh"
243
+ wget --no-check-certificate "$vagrant_ssh_key_url" -O "$chroot/home/vagrant/.ssh/authorized_keys"
244
+ chmod 600 "$chroot/home/vagrant/.ssh/authorized_keys"
245
+ cp -f /root/.vbox_version "$chroot/home/vagrant/.vbox_version"
246
+
247
+ # for passwordless logins
248
+ mkdir -p "$chroot/root/.ssh" 2> /dev/null
249
+ cat /tmp/ssh-root.pub >> "$chroot/root/.ssh/authorized_keys"
250
+
251
+ # PREREQUISITE: virtualbox-guest-additions - the groups created on installation have to exist
252
+ chroot $chroot /bin/bash <<DATAEOF
253
+ groupadd -r vagrant
254
+ groupadd -r rbenv
255
+ useradd -m -r vagrant -g vagrant -G wheel,rbenv,vboxsf,vboxguest -c 'added by vagrant, veewee basebox creation'
256
+
257
+ # set passwords (for after reboot)
258
+ passwd<<EOF
259
+ $password_root
260
+ $password_root
261
+ EOF
262
+
263
+ passwd vagrant<<EOF
264
+ $password_vagrant
265
+ $password_vagrant
266
+ EOF
267
+
268
+ # to each its own... home
269
+ chown -R vagrant /home/vagrant
270
+
271
+ emerge app-admin/sudo
272
+
273
+ echo 'sshd:ALL' > /etc/hosts.allow
274
+ echo 'ALL:ALL' > /etc/hosts.deny
275
+ echo 'vagrant ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
276
+ DATAEOF
277
+
278
+ # configure ssh daemon
279
+ # veewee validate uses password authentication (according to the other Funtoo-template), so we have to enable it
280
+ cat <<DATAEOF > "$chroot/etc/ssh/sshd_config"
281
+ HostBasedAuthentication no
282
+ IgnoreUserKnownHosts yes
283
+ PasswordAuthentication yes
284
+ PermitRootLogin yes
285
+ #PermitRootLogin without-password
286
+ PermitUserEnvironment no
287
+ PrintLastLog no
288
+ PrintMotd no
289
+ PubKeyAuthentication yes
290
+ Subsystem sftp internal-sftp
291
+ UseDNS no
292
+ UsePAM yes
293
+ UsePrivilegeSeparation sandbox
294
+ DATAEOF
295
+
296
+ # install rbenv, ruby and bundler. Configure rbenv for global usage so it's usable without home directory
297
+ chroot "$chroot" /bin/bash <<DATAEOF
298
+ cd /usr/local/lib
299
+ git clone git://github.com/sstephenson/rbenv.git
300
+ cd rbenv
301
+ git checkout -b "$rbenv_version" "$rbenv_version"
302
+ mkdir -p env/plugins
303
+ cd env/plugins
304
+ git clone git://github.com/sstephenson/ruby-build.git
305
+ cd ruby-build
306
+ git checkout -b "$ruby_builder_version" "$ruby_builder_version"
307
+ cd ..
308
+ git clone git://github.com/carsomyr/rbenv-bundler.git
309
+ cd rbenv-bundler
310
+ git checkout -b "$rbenv_bundler_version" "$rbenv_bundler_version"
311
+ chgrp -R rbenv /usr/local/lib/rbenv
312
+ DATAEOF
313
+ libtool --finish /usr/lib64
314
+
315
+ # add rbenv to profile
316
+ cat <<DATAEOF >> "$chroot/etc/profile.d/rbenv.sh"
317
+ # add rbenv support
318
+ rbenv_base=/usr/local/lib/rbenv
319
+ export PATH=\$PATH:\$rbenv_base/bin
320
+ [ -n \$RBENV_ROOT ] && export RBENV_ROOT=\$rbenv_base/env
321
+ eval "\$(rbenv init -)"
322
+ DATAEOF
323
+
324
+ # install ruby, bundler, chef and puppet
325
+ chroot "$chroot" /bin/bash <<DATAEOF
326
+ env-update && source /etc/profile
327
+
328
+ # install ruby, use it as global version
329
+ emerge dev-libs/libyaml
330
+ rbenv install "$ruby_version"
331
+ rbenv global "$ruby_version"
332
+
333
+ # disable rdoc and ri
334
+ mkdir -p "/usr/local/lib/rbenv/env/versions/$ruby_version/etc"
335
+ cat <<EOF > "/usr/local/lib/rbenv/env/versions/$ruby_version/etc/gemrc"
336
+ # disable rdoc and ri
337
+ install: --no-rdoc --no-ri
338
+ update: --no-rdoc --no-ri
339
+ EOF
340
+
341
+ # install required and desired gems
342
+ gem install bundler chef puppet
343
+ DATAEOF
344
+
345
+ # install logger and cron
346
+ chroot "$chroot" /bin/bash <<DATAEOF
347
+ emerge app-admin/rsyslog sys-process/vixie-cron
348
+ rc-update add rsyslog default
349
+ rc-update add vixie-cron default
350
+ DATAEOF
351
+
352
+ # install nfs and automount support
353
+ # chroot "$chroot" emerge net-fs/nfs-utils net-fs/autofs
354
+
355
+ # make the disk bootable
356
+ chroot "$chroot" /bin/bash <<DATAEOF
357
+ source /etc/profile && \
358
+ env-update && \
359
+ grub-install --no-floppy /dev/sda && \
360
+ boot-update
361
+ DATAEOF
362
+
363
+ ### CLEANUP TO SHRINK THE BOX ###
364
+
365
+ # a fresh install probably shouldn't nag about news
366
+ chroot "$chroot" /usr/bin/eselect news read all
367
+
368
+ # cleanup time...
369
+ chroot "$chroot" /bin/bash <<DATAEOF
370
+ # delete temp, cached and build artifact data - some low hanging fruit...
371
+ eclean -d distfiles
372
+ rm /tmp/*
373
+ rm -rf /var/log/*
374
+ rm -rf /var/tmp/*
375
+
376
+ # there's some leftover junk by gem installation in the root folder
377
+ # don't know where this is from (/root/.gem/specs/rubygems.org%80/...), but it should go...
378
+ # we use a global ruby by default
379
+ # ...probably hard coded path by mistake, report to upstream? Which upstream?!?
380
+ rm -rf /root/.gem
381
+
382
+ # here's some savings crippling the usage of this box (sorted descending by damage)
383
+ #rm -rf /usr/local/lib/rbenv/.git
384
+ #rm -rf /usr/local/lib/rbenv/env/plugins/*/.git
385
+ #rm -rf /usr/src/linux*
386
+ #rm -rf /usr/portage/.git
387
+ DATAEOF
388
+
389
+ # fill all free hdd space with zeros
390
+ dd if=/dev/zero of="$chroot/boot/EMPTY" bs=1M
391
+ rm "$chroot/boot/EMPTY"
392
+
393
+ dd if=/dev/zero of="$chroot/EMPTY" bs=1M
394
+ rm "$chroot/EMPTY"
395
+
396
+ # fill all swap space with zeros and recreate swap
397
+ swapoff /dev/sda3
398
+ shred -n 0 -z /dev/sda3
399
+ mkswap /dev/sda3
400
+
401
+ exit