#!/bin/bash # Author: Daniel Kahn Gillmor # Date: 2009-10-08 # License: GPL v3+ set -e # depends on grub2 # specify the first argument as the new installer image: output="$1" SUITE=${SUITE:-stable} ARCH=${ARCH:-amd64} DISTRO=${DISTRO:-debian} if [ -z "$output" ] ; then printf "you must specify a file name for the image to be built" >&2 exit 1 fi if [ -e "$output" ] ; then printf "file '%s' already exists" "$output" >&2 exit 1 fi WORKDIR=$(mktemp -d) cleanup() { rm -rf "$WORKDIR" } trap cleanup EXIT case "$DISTRO" in debian) BASEPATH="http://ftp.nl.debian.org/debian/dists/$SUITE/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH" ;; ubuntu) BASEPATH="http://archive.ubuntu.com/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH" ;; esac ( cd "$WORKDIR" && wget "$BASEPATH"/{linux,initrd.gz} ) mkdir -p "$WORKDIR/boot/grub" cat > "$WORKDIR/boot/grub/grub.cfg" <