Setup babelbox partitioning and cleanup
This commit is contained in:
parent
e5b1594023
commit
787fecd81c
9 changed files with 228 additions and 79 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
||||||
/packer_cache/
|
/packer_cache/
|
||||||
|
/babelbox/
|
||||||
/build/
|
/build/
|
||||||
/http/*.iso
|
*.iso
|
||||||
.*.swp
|
.*.swp
|
||||||
|
|
|
@ -1,37 +1,53 @@
|
||||||
{
|
{
|
||||||
|
"description": "Debian Babelbox",
|
||||||
"builders": [{
|
"builders": [{
|
||||||
"type": "virtualbox-iso",
|
|
||||||
"guest_os_type": "Debian",
|
|
||||||
"iso_url": "http://cdimage.debian.org/debian-cd/current/i386/iso-cd/debian-8.3.0-i386-netinst.iso",
|
|
||||||
"iso_checksum": "f270d1ffa0f9472464bfc0fffa7ac3ddc89abb5786eb02454f26e49f143b01d6",
|
|
||||||
"iso_checksum_type": "sha256",
|
|
||||||
"ssh_username": "demo",
|
|
||||||
"ssh_password": "babelbox",
|
|
||||||
"ssh_wait_timeout": "1800s",
|
|
||||||
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now",
|
|
||||||
"disk_size": 10240,
|
|
||||||
"headless": false,
|
|
||||||
"http_directory": "http",
|
|
||||||
"boot_command": [
|
"boot_command": [
|
||||||
"<esc><wait>",
|
"<esc><wait>",
|
||||||
"install <wait>",
|
"install <wait>",
|
||||||
|
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
|
||||||
"debian-installer=en_US <wait>",
|
"debian-installer=en_US <wait>",
|
||||||
"auto <wait>",
|
"auto <wait>",
|
||||||
"locale=en_US <wait>",
|
"locale=en_US <wait>",
|
||||||
"kbd-chooser/method=us <wait>",
|
"kbd-chooser/method=de <wait>",
|
||||||
"netcfg/get_hostname={{ .Name }} <wait>",
|
"netcfg/get_hostname={{ .Name }} <wait>",
|
||||||
"netcfg/get_domain=demo.local <wait>",
|
"netcfg/get_domain=demo.local <wait>",
|
||||||
"fb=false <wait>",
|
"fb=false <wait>",
|
||||||
|
"debconf/frontend=noninteractive <wait>",
|
||||||
"console-setup/ask_detect=false <wait>",
|
"console-setup/ask_detect=false <wait>",
|
||||||
"console-keymaps-at/keymap=us <wait>",
|
"console-keymaps-at/keymap=de <wait>",
|
||||||
"keyboard-configuration/xkb-keymap=us <wait>",
|
"keyboard-configuration/xkb-keymap=de <wait>",
|
||||||
"<enter><wait>"
|
"<enter><wait>"
|
||||||
],
|
],
|
||||||
"boot_wait": "5s",
|
"disk_size": 10240,
|
||||||
|
"guest_os_type": "Debian",
|
||||||
|
"hard_drive_interface": "sata",
|
||||||
|
"headless": false,
|
||||||
|
"http_directory": "http",
|
||||||
|
"iso_checksum": "f270d1ffa0f9472464bfc0fffa7ac3ddc89abb5786eb02454f26e49f143b01d6",
|
||||||
|
"iso_checksum_type": "sha256",
|
||||||
|
"iso_url": "http://cdimage.debian.org/debian-cd/current/i386/iso-cd/debian-8.3.0-i386-netinst.iso",
|
||||||
|
"shutdown_command": "sudo /sbin/halt -p",
|
||||||
|
"ssh_username": "demo",
|
||||||
|
"ssh_password": "babelbox",
|
||||||
|
"ssh_port": "22",
|
||||||
|
"ssh_wait_timeout": "1800s",
|
||||||
|
"type": "virtualbox-iso",
|
||||||
"vm_name": "babelbox-jessie",
|
"vm_name": "babelbox-jessie",
|
||||||
"vboxmanage": [
|
"vboxmanage": [
|
||||||
["modifyvm", "{{.Name}}", "--memory", "512"],
|
["modifyvm", "{{.Name}}", "--memory", "512"],
|
||||||
["modifyvm", "{{.Name}}", "--cpus", "1"]
|
["modifyvm", "{{.Name}}", "--cpus", "1"]
|
||||||
|
],
|
||||||
|
"output_directory": "babelbox"
|
||||||
|
}],
|
||||||
|
"provisioners": [{
|
||||||
|
"type": "shell",
|
||||||
|
"execute_command": "{{ .Vars }} sudo -E /bin/sh '{{ .Path }}'",
|
||||||
|
"scripts": [
|
||||||
|
"scripts/babelbox-partitions.sh",
|
||||||
|
"scripts/setup-babelbox.sh",
|
||||||
|
"scripts/virtualbox.sh",
|
||||||
|
"scripts/cleanup.sh",
|
||||||
|
"scripts/minimize.sh"
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,59 +1,95 @@
|
||||||
|
### Localization
|
||||||
|
d-i debian-installer/locale string en_US
|
||||||
|
d-i debian-installer/language string en
|
||||||
|
d-i debian-installer/country string US
|
||||||
d-i debian-installer/locale string en_US.UTF-8
|
d-i debian-installer/locale string en_US.UTF-8
|
||||||
d-i localechooser/supported-locales multiselect en_US.UTF-8, de_DE.UTF-8
|
d-i localechooser/supported-locales multiselect en_US.UTF-8, de_DE.UTF-8
|
||||||
d-i keyboard-configuration/xkb-keymap select us
|
|
||||||
|
# Keyboard selection.
|
||||||
|
d-i console-tools/archs select at
|
||||||
|
d-i console-keymaps-at/keymap select de
|
||||||
|
|
||||||
|
d-i keyboard-configuration/xkb-keymap select de
|
||||||
|
|
||||||
|
### Network configuration
|
||||||
d-i netcfg/choose_interface select auto
|
d-i netcfg/choose_interface select auto
|
||||||
|
|
||||||
|
### Mirror settings
|
||||||
d-i mirror/country string manual
|
d-i mirror/country string manual
|
||||||
d-i mirror/http/hostname string http.debian.net
|
d-i mirror/http/hostname string httpredir.debian.org
|
||||||
d-i mirror/http/directory string /debian
|
d-i mirror/http/directory string /debian
|
||||||
d-i mirror/http/proxy string
|
d-i mirror/http/proxy string
|
||||||
|
|
||||||
|
### Account setup
|
||||||
d-i passwd/root-login boolean false
|
d-i passwd/root-login boolean false
|
||||||
d-i passwd/user-fullname string Babelbox Demo User
|
d-i passwd/user-fullname string Babelbox Demo User
|
||||||
d-i passwd/username string demo
|
d-i passwd/username string demo
|
||||||
d-i passwd/user-password-crypted password $6$M0jXQ0qT0W$4aZR9JeivSUot1WpUv5elFOEz2lZ6D4a67NMu40OR3ocHeDQIN.bkBV/JAGINgZ9tp.yLQL7wGGhLM2ZJZ9Mp/
|
d-i passwd/user-password-crypted password $6$M0jXQ0qT0W$4aZR9JeivSUot1WpUv5elFOEz2lZ6D4a67NMu40OR3ocHeDQIN.bkBV/JAGINgZ9tp.yLQL7wGGhLM2ZJZ9Mp/
|
||||||
d-i clock-setup/utc boolean true
|
|
||||||
d-i clock-setup/ntp boolean false
|
|
||||||
d-i time/zone string Europe/Berlin
|
|
||||||
debconf debconf/frontend string Noninteractive
|
|
||||||
|
|
||||||
d-i partman-auto/disk string /dev/sda
|
### Clock and time zone setup
|
||||||
|
d-i clock-setup/utc boolean true
|
||||||
|
d-i time/zone string GMT+0
|
||||||
|
d-i clock-setup/ntp boolean false
|
||||||
|
|
||||||
|
### Partitioning
|
||||||
|
#d-i partman-auto/disk string /dev/sda
|
||||||
d-i partman-lvm/purge_lvm_from_device boolean true
|
d-i partman-lvm/purge_lvm_from_device boolean true
|
||||||
d-i partman-lvm/device_remove_lvm boolean true
|
d-i partman-lvm/device_remove_lvm boolean true
|
||||||
d-i partman-md/device_remove_md boolean true
|
|
||||||
d-i partman-lvm/confirm boolean true
|
d-i partman-lvm/confirm boolean true
|
||||||
d-i partman-partitioning/confirm_write_new_label boolean true
|
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||||
#d-i partman-auto/method string regular
|
|
||||||
|
d-i partman-md/device_remove_md boolean true
|
||||||
|
|
||||||
|
d-i partman-auto/disk string /dev/sda
|
||||||
|
d-i partman-auto/method string regular
|
||||||
d-i partman-auto/expert_recipe string \
|
d-i partman-auto/expert_recipe string \
|
||||||
root :: \
|
root :: \
|
||||||
5000 50 5000 ext4 \
|
4608 50 4608 ext4 \
|
||||||
$primary{ } \
|
$primary{ } $bootable{ } \
|
||||||
$bootable{ } \
|
method{ format } format{ } \
|
||||||
method{ format } \
|
use_filesystem{ } filesystem{ ext4 } \
|
||||||
format{ } \
|
mountpoint{ / } \
|
||||||
use_filesystem{ } \
|
|
||||||
filesystem{ ext4 } \
|
|
||||||
mountpoint { / } \
|
|
||||||
label { root } \
|
|
||||||
. \
|
. \
|
||||||
250 50 100% linux-swap \
|
512 90 512 linux-swap \
|
||||||
$primary{ } \
|
$primary{ } \
|
||||||
method{ swap } \
|
method{ swap } \
|
||||||
format{ } \
|
format{ } \
|
||||||
|
. \
|
||||||
|
1 1000 -1 ext4 \
|
||||||
|
$primary{ } \
|
||||||
|
method{ keep } \
|
||||||
.
|
.
|
||||||
|
d-i partman-auto/choose_recipe select root
|
||||||
|
d-i partman-basicmethods/method_only boolean false
|
||||||
|
d-i partman-partitioning/confirm_write_new_label boolean true
|
||||||
d-i partman/choose_partition select finish
|
d-i partman/choose_partition select finish
|
||||||
d-i partman/confirm boolean true
|
d-i partman/confirm boolean true
|
||||||
d-i partman/confirm_nooverwrite boolean true
|
d-i partman/confirm_nooverwrite boolean true
|
||||||
|
|
||||||
|
### Apt setup
|
||||||
|
d-i apt-setup/non-free boolean false
|
||||||
|
d-i apt-setup/contrib boolean false
|
||||||
d-i base-installer/install-recommends boolean false
|
d-i base-installer/install-recommends boolean false
|
||||||
d-i apt-setup/use_mirror boolean true
|
|
||||||
d-i apt-setup/services-select multiselect security, updates
|
d-i apt-setup/services-select multiselect security, updates
|
||||||
d-i apt-setup/security_host string security.debian.org
|
d-i apt-setup/security_host string security.debian.org
|
||||||
d-i pkgsel/include string parted openssh-server acpid sudo
|
|
||||||
d-i pkgsel/upgrade select none
|
### Package selection
|
||||||
popularity-contest popularity-contest/participate boolean false
|
|
||||||
tasksel tasksel/first multiselect standard
|
tasksel tasksel/first multiselect standard
|
||||||
grub-pc grub-pc/install_devices multiselect /dev/sda
|
|
||||||
grub-installer grub-installer/choose_bootdev select /dev/sda
|
d-i pkgsel/include string parted openssh-server acpid sudo ca-certificates curl
|
||||||
|
d-i pkgsel/upgrade select safe-upgrade
|
||||||
|
|
||||||
|
popularity-contest popularity-contest/participate boolean false
|
||||||
|
|
||||||
|
### GRUB
|
||||||
|
d-i grub-installer/only_debian boolean true
|
||||||
|
d-i grub-installer/bootdev string default
|
||||||
|
|
||||||
|
### Finishing up the installation
|
||||||
|
d-i finish-install/keep-consoles boolean true
|
||||||
d-i finish-install/reboot_in_progress note
|
d-i finish-install/reboot_in_progress note
|
||||||
|
|
||||||
d-i preseed/early_command string sed -i \
|
# Setup passwordless sudo for demo
|
||||||
'/in-target/idiscover(){/sbin/discover|grep -v VirtualBox;}' \
|
d-i preseed/late_command string \
|
||||||
/usr/lib/pre-pkgsel.d/20install-hwpackages
|
echo "demo ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/demo ; \
|
||||||
|
in-target chmod 0440 /etc/sudoers.d/demo
|
||||||
|
|
18
scripts/babelbox-partitions.sh
Normal file
18
scripts/babelbox-partitions.sh
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "
|
||||||
|
d
|
||||||
|
3
|
||||||
|
n
|
||||||
|
e
|
||||||
|
3
|
||||||
|
|
||||||
|
+4G
|
||||||
|
n
|
||||||
|
p
|
||||||
|
|
||||||
|
|
||||||
|
w" | /sbin/fdisk /dev/sda || true
|
||||||
|
/sbin/partprobe
|
10
scripts/cleanup.sh
Executable file
10
scripts/cleanup.sh
Executable file
|
@ -0,0 +1,10 @@
|
||||||
|
# Clean up
|
||||||
|
apt-get --yes autoremove
|
||||||
|
apt-get --yes clean
|
||||||
|
|
||||||
|
# Removing leftover leases and persistent rules
|
||||||
|
echo "cleaning up dhcp leases"
|
||||||
|
rm /var/lib/dhcp/*
|
||||||
|
|
||||||
|
echo "Adding a 2 sec delay to the interface up, to make the dhclient happy"
|
||||||
|
echo "pre-up sleep 2" >> /etc/network/interfaces
|
29
scripts/minimize.sh
Normal file
29
scripts/minimize.sh
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/sh -eux
|
||||||
|
#Copyright 2012-2014, Chef Software, Inc. (<legal@chef.io>)
|
||||||
|
#Copyright 2011-2012, Tim Dysinger (<tim@dysinger.net>)
|
||||||
|
|
||||||
|
#Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
#you may not use this file except in compliance with the License.
|
||||||
|
#You may obtain a copy of the License at
|
||||||
|
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
#Unless required by applicable law or agreed to in writing, software
|
||||||
|
#distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
#See the License for the specific language governing permissions and
|
||||||
|
#limitations under the License.
|
||||||
|
|
||||||
|
echo "Fill with 0 the swap partition to reduce box size"
|
||||||
|
readonly swapuuid=$(/sbin/blkid -o value -l -s UUID -t TYPE=swap)
|
||||||
|
readonly swappart=$(readlink -f /dev/disk/by-uuid/"$swapuuid")
|
||||||
|
/sbin/swapoff "$swappart"
|
||||||
|
dd if=/dev/zero of="$swappart" bs=1M || echo "dd exit code $? is suppressed"
|
||||||
|
/sbin/mkswap -U "$swapuuid" "$swappart"
|
||||||
|
|
||||||
|
echo "Fill filesystem with 0 to reduce box size"
|
||||||
|
dd if=/dev/zero of=/EMPTY bs=1M
|
||||||
|
rm -f /EMPTY
|
||||||
|
# Block until the empty file has been removed, otherwise, Packer
|
||||||
|
# will try to kill the box while the disk is still full and that's bad
|
||||||
|
sync
|
14
scripts/setup-babelbox.sh
Normal file
14
scripts/setup-babelbox.sh
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
apt-get install -y git wget
|
||||||
|
cd /srv
|
||||||
|
wget http://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/gtk/initrd.gz http://ftp.debian.org/debian/dists/stable/main/installer-i386/current/images/hd-media/gtk/vmlinuz
|
||||||
|
git clone https://anonscm.debian.org/git/d-i/babelbox.git
|
||||||
|
cd babelbox
|
||||||
|
cat babelbox-grub >> /etc/grub.d/40_custom
|
||||||
|
update-grub
|
||||||
|
./cronscript
|
||||||
|
|
||||||
|
echo "You need to download a Debian i386 DVD ISO into /srv"
|
33
scripts/virtualbox.sh
Executable file
33
scripts/virtualbox.sh
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
echo "installing virtualbox guest additions"
|
||||||
|
|
||||||
|
# install virtualbox additions build dependancies
|
||||||
|
apt-get --yes install linux-headers-$(uname -r) build-essential dkms
|
||||||
|
|
||||||
|
|
||||||
|
# If libdbus is not installed, virtualbox will not autostart
|
||||||
|
apt-get -y install --no-install-recommends libdbus-1-3
|
||||||
|
|
||||||
|
# deprecated: this remove virtualbox additions installed
|
||||||
|
# from the debian installer pre-wheezy release
|
||||||
|
|
||||||
|
#if test -f .vbox_version ; then
|
||||||
|
# The netboot installs the VirtualBox support (old) so we have to remove it
|
||||||
|
# if test -f /etc/init.d/virtualbox-ose-guest-utils ; then
|
||||||
|
# /etc/init.d/virtualbox-ose-guest-utils stop
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# rmmod vboxguest
|
||||||
|
# aptitude -y purge virtualbox-ose-guest-x11 virtualbox-ose-guest-dkms virtualbox-ose-guest-utils
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# Install the VirtualBox guest additions
|
||||||
|
mount -o loop VBoxGuestAdditions.iso /mnt
|
||||||
|
yes|sh /mnt/VBoxLinuxAdditions.run
|
||||||
|
umount /mnt
|
||||||
|
rm -f VBoxGuestAdditions.iso
|
||||||
|
|
||||||
|
# Start the newly build driver
|
||||||
|
service vboxadd start
|
||||||
|
|
||||||
|
# cleanup virtualbox stuff
|
||||||
|
apt-get --yes remove linux-headers-$(uname -r) build-essential dkms
|
|
@ -1,8 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
cd http
|
|
||||||
wget -c -N http://cdimage.debian.org/debian-cd/current/i386/iso-dvd/debian-8.3.0-i386-DVD-1.iso
|
|
||||||
cd ..
|
|
||||||
|
|
||||||
packer build debian-babelbox.json
|
|
Loading…
Reference in a new issue