initial checkin
[grml-debootstrap.git] / grml-debootstrap
1 #!/bin/sh
2 # Filename:      grml-bootstrap
3 # Purpose:       wrapper around debootstrap for installing plain Debian via grml
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Fre Nov 03 00:54:39 CET 2006 [mika]
8 ################################################################################
9 # http://www.debian.org/releases/stable/i386/apcs04.html.en
10
11 set -eu # exit on any error
12
13 . /etc/grml/lsb-functions
14 . /etc/grml/script-functions
15
16 check4progs debootstrap || exit 1
17
18 if [ -r /etc/debootstrap/config ] ; then
19    . /etc/debootstrap/config
20 else
21    echo "/etc/debootstrap/config could not be read, exiting."
22    exit 1
23 fi
24
25 if [ -z "$TARGET" ] ; then
26    eerror "Please adjust /etc/debootstrap/config before running ${0}" ; eend 1
27    exit 1
28 fi
29
30 # make an ext3 filesystem on /dev/sda1
31 einfo "Running $MKFS on $TARGET"
32 $MKFS $TARGET
33 eend $?
34
35 # now mount the new partition
36 einfo "Mounting $TARGET to $MNTPOINT"
37 mount -o rw,suid,dev $TARGET $MNTPOINT
38 eend $?
39
40 # get main packages from a debian-mirror
41 einfo "Running $DEBOOTSTRAP for release $RELEASE using mirror $MIRROR"
42 $DEBOOTSTRAP $RELEASE $MNTPOINT $MIRROR
43 eend $?
44
45 einfo "Preparing chroot system"
46   cp $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
47   chmod 755 $MNTPOINT/bin/chroot-script
48   mkdir $MNTPOINT/etc/deboostrap/
49
50   # make sure we have our config file for later use via chroot-script
51   cp /etc/debootstrap/config $MNTPOINT/etc/debootstrap/
52
53   # copy any existing existing files to chroot
54   [ -d /etc/debootstrap/boot  ] && cp -a /etc/debootstrap/boot/*  $MNTPOINT/boot/
55   [ -d /etc/debootstrap/etc   ] && cp -a /etc/debootstrap/etc/*   $MNTPOINT/etc/
56   [ -d /etc/debootstrap/share ] && cp -a /etc/debootstrap/share/* $MNTPOINT/share/
57   [ -d /etc/debootstrap/usr   ] && cp -a /etc/debootstrap/usr/*   $MNTPOINT/usr/
58   [ -d /etc/debootstrap/var   ] && cp -a /etc/debootstrap/var/*   $MNTPOINT/var/
59 eend $?
60
61 einfo "Executing chroot-script now"
62 chroot $MNTPOINT /bin/chroot-script
63 eend $?
64
65 einfo "Unmount $MNTPOINT"
66 umount $MNTPOINT
67 eend $?
68
69 einfo "Finished execution of $0 - enjoy your Debian system." ; eend 0
70
71 ## END OF FILE #################################################################