3 # Copyright (C) 2007 Google Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # Customize this if you need another mirror, or set to empty to get the
24 MIRROR="http://ftp.debian.org/debian"
26 TEMP=`getopt -o i:b:s: -n '$0' -- "$@"`
28 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
30 # Note the quotes around `$TEMP': they are essential!
35 -i) instance=$2; shift 2;;
37 -b) blockdev=$2; shift 2;;
39 -s) swapdev=$2; shift 2;;
43 *) echo "Internal error!"; exit 1;;
46 if [ -z "$instance" -o -z "$blockdev" -o -z "$swapdev" ]; then
47 echo "Missing -i or -b or -s argument!"
53 TMPDIR=`mktemp -d` || exit 1
54 trap "umount $TMPDIR; rmdir $TMPDIR" EXIT
55 mount $blockdev $TMPDIR
57 # On i386, we need the xen-specific library
58 DPKG_ARCH="`dpkg --print-architecture`"
59 if [ "$DPKG_ARCH" = "i386" ]; then
60 EXTRAPKG="linux-image-xen-686 libc6-xen"
61 elif [ "$DPKG_ARCH" = "amd64" ]; then
62 EXTRAPKG="linux-image-xen-amd64"
65 debootstrap --include="$EXTRAPKG" etch $TMPDIR $MIRROR
67 # remove the persistent-net rules, otherwise it will remember the node's
68 # interfaces as eth0, eth1, ...
70 rm -f "$TMPDIR/etc/udev/rules.d/z25_persistent-net.rules"
72 cp -p /etc/hosts $TMPDIR/etc/hosts
73 cp -p /etc/resolv.conf $TMPDIR/etc/resolv.conf
74 echo $instance > $TMPDIR/etc/hostname
75 echo $instance > $TMPDIR/etc/mailname
77 cat > $TMPDIR/etc/fstab <<EOF
78 # /etc/fstab: static file system information.
80 # <file system> <mount point> <type> <options> <dump> <pass>
81 /dev/sda / ext3 defaults 0 1
82 /dev/sdb swap swap defaults 0 0
83 proc /proc proc defaults 0 0
86 cat > $TMPDIR/etc/network/interfaces <<EOF
88 iface lo inet loopback