--- /dev/null
+#!/bin/bash
+
+# copyright 2012 Holger Levsen <holger@layer-acht.org>
+# GPL2 licenced
+
+set -e
+set -x
+export
+
+#
+# Define default settings
+#
+#export DIST=squeeze
+#export PB_SUITE=production-proposed-updates
+export TARGET_DIR=/srv/storage-kernels
+SCRIPTSDIR=$(dirname $0)
+BUILD_SCRIPT=$(mktemp)
+cat > $BUILD_SCRIPT <<-EOF
+#/bin/bash
+set -e
+set -x
+apt-get update
+# grub is needed in the postinst...
+apt-get install -y grub2
+apt-get -y install profitbricks-andbd-modules-storage profitbricks-linux-image-storage || true
+mkdir $TARGET_DIR/$BUILD_NUMBER
+cp -v /boot/vmlinu* $TARGET_DIR/$BUILD_NUMBER/
+cp -v /boot/config* $TARGET_DIR/$BUILD_NUMBER/
+cd /lib/modules/*storage/
+/bin/tar -cJvf $TARGET_DIR/$BUILD_NUMBER/modules.tar.xz .
+EOF
+chmod +x $BUILD_SCRIPT
+
+#
+# build liveboot
+#
+sudo pbuilder --execute --bindmounts $TARGET_DIR -- $BUILD_SCRIPT
+rm $BUILD_SCRIPT
+
+
+# TODO: implement better garbage collection, allow to keep images
+#
+# cleanup $TARGET_DIR, keep MAX number of images
+#
+MAX=15
+cd $TARGET_DIR
+COUNT=0
+for i in $(ls -atd1) ; do
+ if [ "$i" != "." ] ; then
+ let COUNT=COUNT+1
+ if [ $COUNT -gt $MAX ] ; then
+ echo sudo rm -rfv ./$i
+ else
+ echo "keeping $i"
+ fi
+ fi
+ if [ $COUNT -gt 0 ] ; then
+ figlet "Warning:"
+ echo "Garbage collection disabled."
+ fi
+done
+
+figlet "OK"
+
+