Setup babelbox partitioning and cleanup

This commit is contained in:
Jan Dittberner 2016-02-26 23:56:38 +01:00
parent e5b1594023
commit 787fecd81c
9 changed files with 228 additions and 79 deletions

View 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
View 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
View 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
View 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
View 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