| 1 |
#!/bin/sh
|
| 2 |
PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
|
| 3 |
|
| 4 |
DISTRIBUTION="ubuntu_breezy"
|
| 5 |
|
| 6 |
if [ `id -u` -ne 0 ]; then
|
| 7 |
echo "Run this program as root."
|
| 8 |
exit 9
|
| 9 |
fi
|
| 10 |
|
| 11 |
# option e currently does nothing
|
| 12 |
while getopts vc:f: opt ; do
|
| 13 |
case "$opt" in
|
| 14 |
c) cfdir=$OPTARG ;;
|
| 15 |
v) verbose=1 ; v=-v ;;
|
| 16 |
f) cfg=$OPTARG ;;
|
| 17 |
?) exit 5 ;; # error in option parsing
|
| 18 |
esac
|
| 19 |
done
|
| 20 |
|
| 21 |
set -e
|
| 22 |
|
| 23 |
# source fai.conf and make-fai-nfsroot.conf
|
| 24 |
[ -z "$cfdir" ] && cfdir=/etc/fai
|
| 25 |
if [ ! -d "$cfdir" ]; then
|
| 26 |
echo "$cfdir is not a directory"
|
| 27 |
exit 6
|
| 28 |
fi
|
| 29 |
|
| 30 |
[ "$verbose" ] && echo "Using configuration files from directory $cfdir"
|
| 31 |
if [ -n "$cfg" ]; then
|
| 32 |
. $cfdir/$cfg
|
| 33 |
else
|
| 34 |
. $cfdir/fai.conf
|
| 35 |
fi
|
| 36 |
|
| 37 |
|
| 38 |
. /etc/fai-distributions/${DISTRIBUTION}.conf
|
| 39 |
|
| 40 |
if [ -z "$NFSROOT" ]; then
|
| 41 |
echo "\$NFSROOT is not set. Please check your settings in $cfdir/fai.conf."
|
| 42 |
exit 4
|
| 43 |
fi
|
| 44 |
|
| 45 |
# call debootstrap as necesary - (how can this be done without having the
|
| 46 |
# ubuntu debootstrap installed?)
|
| 47 |
|
| 48 |
BOOTSTRAP_DIR=/var/fai/bootstrappers/$DISTRIBUTION
|
| 49 |
mkdir -p $BOOTSTRAP_DIR
|
| 50 |
cd $BOOTSTRAP_DIR
|
| 51 |
wget $BOOTSTRAP_ARCHIVE/ubuntu_breezy/$BOOTSTRAP_PACKAGE
|
| 52 |
|
| 53 |
|
| 54 |
# extact debootstrap archive
|
| 55 |
dpkg-deb -x $BOOTSTRAP_PACKAGE .
|
| 56 |
|
| 57 |
cd -
|
| 58 |
|
| 59 |
# FIXME: can/should probably be defined somewhere in /etc/fai?
|
| 60 |
TMP_CHROOT_DIR=`mktemp -d /tmp/fai/${DISTRIBUTION}_debootstrap.XXXXXX`
|
| 61 |
echo "TMPDIT is $TMP_CHROOT_DIR"
|
| 62 |
|
| 63 |
FAI_DEBOOTSTRAP_OPTIONS="--arch i386 \
|
| 64 |
--exclude=pcmcia-cs,pppoe,dhcp-client,exim4,exim4-base,exim4-config,exim4-daemon-light,modconf,libident,exim \
|
| 65 |
--include=lilo \
|
| 66 |
breezy \
|
| 67 |
$TMP_CHROOT_DIR \
|
| 68 |
$MIRROR_LOCATION"
|
| 69 |
|
| 70 |
cd `dirname $0`
|
| 71 |
|
| 72 |
export DEBOOTSTRAP_DIR=$BOOTSTRAP_DIR/usr/lib/debootstrap/
|
| 73 |
|
| 74 |
echo run $BOOTSTRAP_DIR/usr/sbin/debootstrap $FAI_DEBOOTSTRAP_OPTIONS
|
| 75 |
$BOOTSTRAP_DIR/usr/sbin/debootstrap $FAI_DEBOOTSTRAP_OPTIONS
|
| 76 |
|
| 77 |
chroot $TMP_CHROOT_DIR apt-get clean
|
| 78 |
|
| 79 |
echo "Creating base-$DISTRIBUTION.tgz"
|
| 80 |
|
| 81 |
cd $TMP_CHROOT_DIR
|
| 82 |
tar cfz $NFSROOT/var/tmp/base-$DISTRIBUTION.tgz *
|
| 83 |
|
| 84 |
chroot $TMP_CHROOT_DIR umount /dev
|
| 85 |
chroot $TMP_CHROOT_DIR umount /.dev
|
| 86 |
|
| 87 |
# cleanup
|
| 88 |
echo "cleaning up TMP_CHROOT_DIR $TMP_CHROOT_DIR"
|
| 89 |
rm -rf $TMP_CHROOT_DIR
|
| 90 |
|
| 91 |
|