From 5abeee543b843c25e31a88b7838585aedd70fc92 Mon Sep 17 00:00:00 2001 From: Jeffrey Paul Date: Thu, 30 Jan 2014 07:26:22 +0100 Subject: [PATCH] moved ubuntu image builder to its own repo --- build.ubuntu.vmimg/.gitignore | 3 - build.ubuntu.vmimg/Makefile | 18 -- build.ubuntu.vmimg/Vagrantfile | 65 ------- build.ubuntu.vmimg/buildimage.sh | 299 ------------------------------- build.ubuntu.vmimg/cleanup.sh | 15 -- 5 files changed, 400 deletions(-) delete mode 100644 build.ubuntu.vmimg/.gitignore delete mode 100644 build.ubuntu.vmimg/Makefile delete mode 100644 build.ubuntu.vmimg/Vagrantfile delete mode 100755 build.ubuntu.vmimg/buildimage.sh delete mode 100755 build.ubuntu.vmimg/cleanup.sh diff --git a/build.ubuntu.vmimg/.gitignore b/build.ubuntu.vmimg/.gitignore deleted file mode 100644 index 5a15171..0000000 --- a/build.ubuntu.vmimg/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.vagrant -*.bz2 -*.qcow2 diff --git a/build.ubuntu.vmimg/Makefile b/build.ubuntu.vmimg/Makefile deleted file mode 100644 index 3b59fab..0000000 --- a/build.ubuntu.vmimg/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -YYYYMMDD := $(shell date +%Y%m%d) - -default: gen - -clean: - rm -f *.bz2 *.qcow2 - -gen: clean - vagrant destroy -f - vagrant up - vagrant ssh -- cat saucy64.qcow2 | pv > .tmp.qcow2 - mv .tmp.qcow2 saucy64-$(YYYYMMDD).qcow2 - rsync -azvP saucy64-$(YYYYMMDD).qcow2 \ - root@nue1d0.datavibe.net:/storage/images/ - -sync: - rsync -avP ./*.sh \ - root@nue1d0.datavibe.net:/storage/buildimage/ diff --git a/build.ubuntu.vmimg/Vagrantfile b/build.ubuntu.vmimg/Vagrantfile deleted file mode 100644 index 815108f..0000000 --- a/build.ubuntu.vmimg/Vagrantfile +++ /dev/null @@ -1,65 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -SETUP_BASE = <<-EOF - -echo "UseDNS no" >> /etc/ssh/sshd_config -service ssh restart - -function detect_local_mirror () { - AL="$(avahi-browse -p -t -r _ubuntumirror._tcp | grep '^=' | head -1)" - if [ -n "$AL" ]; then - NAME="$(echo \"$AL\" | cut -d';' -f 8)" - PORT="$(echo \"$AL\" | cut -d';' -f 9)" - UM="http://${NAME}:${PORT}/ubuntu/" - MOK="$(curl --head \"${UM}ls-lR.gz\" 2>&1 | grep '200 OK' | wc -l)" - if [ $MOK -gt 0 ]; then - echo "$UM" - fi - fi -} - -function set_apt_mirror () { - CN="$(lsb_release -c -s)" - RPS="main restricted multiverse universe" - echo "deb $1 $CN $RPS" > /etc/apt/sources.list.new - for P in updates backports security ; do - echo "deb $1 $CN-$P $RPS" >> /etc/apt/sources.list.new - done - mv /etc/apt/sources.list.new /etc/apt/sources.list -} - - -set_apt_mirror "mirror://mirrors.ubuntu.com/mirrors.txt" -apt-get update -apt-get -y install avahi-utils jq curl - -UM="$(detect_local_mirror)" -if [ -n "$UM" ]; then - echo "Detected LAN ubuntu mirror at $UM - configuring!" - set_apt_mirror "$UM" -fi -echo "**********************************************************" -echo "**********************************************************" -cat /etc/apt/sources.list -echo "**********************************************************" -echo "**********************************************************" -apt-get update -apt-get -y install kpartx debootstrap lvm2 qemu-utils -EOF - - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "ubuntu-12.04" - config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/" + \ - "current/precise-server-cloudimg-amd64-vagrant-disk1.box" - config.vm.network "public_network", :bridge => "en4: Display Ethernet" - config.vm.provision "shell", inline: SETUP_BASE - config.vm.provision "shell", path: "buildimage.sh" - config.vm.provider :virtualbox do |vb| - vb.customize ["modifyvm", :id, "--memory", "2048"] - end -end diff --git a/build.ubuntu.vmimg/buildimage.sh b/build.ubuntu.vmimg/buildimage.sh deleted file mode 100755 index a3ae675..0000000 --- a/build.ubuntu.vmimg/buildimage.sh +++ /dev/null @@ -1,299 +0,0 @@ -#!/bin/bash - -set -e -set -v -set -x - -R="saucy" # release -MR="./roottemp" # mounted root -RI="./raw.img" # raw image -VGN="vmvg0" # volume group name -DSIZE="25G" # disk size - -DATE="$(date +%Y%m%d)" -LOOPDEV="/dev/loop5" -LDBASE="$(basename $LOOPDEV)" -ROOTPW="7c493cc530734f4c11e00bcecadb7b73" - -function detect_local_mirror () { - AL="$(avahi-browse -p -t -r _ubuntumirror._tcp | grep '^=' | head -1)" - UM="" - if [ -n "$AL" ]; then - NAME="$(echo \"$AL\" | cut -d\; -f 8)" - PORT="$(echo \"$AL\" | cut -d\; -f 9)" - UM="http://${NAME}:${PORT}/ubuntu/" - fi - if [ -z "$UM" ]; then - # maybe try hetzner mirror? - UM="http://mirror.hetzner.de/ubuntu/packages/" - TF="${UM}/dists/${R}/Release" - MOK="$(curl --head ${TF} 2>&1 | grep '200 OK' | wc -l)" - if [ $MOK -gt 0 ]; then - echo "$UM" - else - echo "http://archive.ubuntu.com/ubuntu/" - fi - else - echo "$UM" - fi -} - -UM="$(detect_local_mirror)" - -dd if=/dev/zero of=$RI bs=1 count=0 seek=$DSIZE -parted -s $RI mklabel msdos -parted -a optimal $RI mkpart primary 0% 200MiB -parted -a optimal $RI mkpart primary 200MiB 100% -parted $RI set 1 boot on -losetup $LOOPDEV $RI -kpartx -av $LOOPDEV -mkfs.ext4 -L BOOT /dev/mapper/${LDBASE}p1 -tune2fs -c -1 /dev/mapper/${LDBASE}p1 -pvcreate /dev/mapper/${LDBASE}p2 -vgcreate $VGN /dev/mapper/${LDBASE}p2 -lvcreate -l 100%FREE -n root $VGN -mkfs.ext4 -L ROOT /dev/$VGN/root -mkdir -p $MR -MR="$(readlink -f $MR)" -mount /dev/$VGN/root $MR -mkdir $MR/boot -mount /dev/mapper/${LDBASE}p1 $MR/boot - -echo "*** installing base $R system from $UM..." -# install base: -debootstrap --arch amd64 $R $MR $UM - -# temporary config for install: -RPS="main restricted multiverse universe" -echo "deb $UM $R $RPS" > $MR/etc/apt/sources.list -for P in updates backports security ; do - echo "deb $UM $R-$P $RPS" >> $MR/etc/apt/sources.list -done - -cat > $MR/etc/apt/apt.conf.d/99-vm-no-extras-please < $MR/etc/environment </dev/null' | chroot $MR - -BUUID="$(blkid -s UUID -o value /dev/mapper/${LDBASE}p1)" -RUUID="$(blkid -s UUID -o value /dev/${VGN}/root)" - -# this has to come before packages: -cat > $MR/etc/fstab < $MR/etc/network/interfaces < $MR/etc/hostname - -cat > $MR/etc/hosts < $MR/usr/sbin/policy-rc.d <> $MR/etc/default/grub -echo "GRUB_SERIAL_COMMAND=\"serial --unit=0 --speed=9600 --stop=1\"" \ - >> $MR/etc/default/grub -echo "GRUB_TERMINAL=\"serial\"" >> $MR/etc/default/grub -echo "GRUB_GFXPAYLOAD=\"text\"" >> $MR/etc/default/grub - -chroot $MR /bin/bash -c "echo \"root:$ROOTPW\" | chpasswd" - -chroot $MR update-grub 2> /dev/null -chroot $MR grub-mkconfig -o /boot/grub/grub.cfg 2> /dev/null -cat > $MR/boot/grub/device.map < /dev/null - -# get rid of device.map after grub is installed... -rm $MR/boot/grub/device.map - -chroot $MR update-initramfs -d -k all -# for some stupid reason, -k all doesn't work after removing: -KERN="$(cd $MR/boot && ls vmlinuz*)" -VER="${KERN#vmlinuz-}" -chroot $MR update-initramfs -c -k $VER - -cat > $MR/etc/init/ttyS0.conf < $MR/etc/dhcp/dhclient-exit-hooks.d/hostname <> $MR/etc/ssh/sshd_config -echo "UseDNS no" >> $MR/etc/ssh/sshd_config - -# clean apt cache -rm $MR/var/cache/apt/archives/*.deb - -# set dist apt source: -RPS="main restricted multiverse universe" -MURL="mirror://mirrors.ubuntu.com/mirrors.txt" -echo "deb $MURL $R $RPS" > $MR/etc/apt/sources.list -for P in updates backports security ; do - echo "deb $MURL $R-$P $RPS" >> $MR/etc/apt/sources.list -done - -# clear issue -echo "clear > /etc/issue" | chroot $MR - -# remove instance ssh host keys -rm $MR/etc/ssh/*key* - -# regenerate them on first boot -cat > $MR/etc/rc.local <