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 17:59:33 CET 2006 [mika]
8 ################################################################################
9 # http://www.debian.org/releases/stable/i386/apcs04.html.en
11 set -e # exit on any error
13 . /etc/grml/lsb-functions
14 . /etc/grml/script-functions
20 einfo "$0 - wrapper around debootstrap for installing plain Debian via grml"
21 einfo "Configure via /etc/debootstrap/config and invoke $0 afterwards."
26 einfo "$0 version $VERSION"
27 einfo "Send bug reports to Michael Prokop <mika@grml.org>."
33 check4progs debootstrap || exit 1
36 if [ -r /etc/debootstrap/config ] ; then
37 . /etc/debootstrap/config
39 echo "/etc/debootstrap/config could not be read, exiting."
43 if [ -z "$TARGET" ] ; then
44 eerror "Please adjust /etc/debootstrap/config before running ${0}" ; eend 1
48 einfo "$0 - Please recheck configuration before execution:"
50 target partition: $TARGET
51 mount-point: $MNTPOINT
52 install grub to: $MBR / $GROOT [if empty it will not be installed]
54 Notice: continuing will delete all data from $TARGET
56 einfo "Is this ok? [y/N]"
59 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
60 eerror "Exiting as requested." ; eend 1
64 if [ -n "$MKFS" ] ; then
65 einfo "Running $MKFS on $TARGET"
70 if [ -n "$TUNE2FS" ] ; then
71 einfo "Disabling automatic filesystem check on $TARGET via tune2fs"
76 # now mount the new partition
77 if grep -q $TARGET /proc/mounts ; then
78 eerror "$TARGET already mounted, exiting."
80 [ -n "$MNTPOINT" ] || MNTPOINT='/mnt/test'
81 einfo "Mounting $TARGET to $MNTPOINT"
82 [ -d "$MNTPOINT" ] || mkdir -p "$MNTPOINT"
83 mount -o rw,suid,dev $TARGET $MNTPOINT
87 # get main packages from a debian-mirror
88 einfo "Running $DEBOOTSTRAP for release $RELEASE using mirror $MIRROR"
89 $DEBOOTSTRAP $RELEASE $MNTPOINT $MIRROR
92 einfo "Preparing chroot system"
93 cp $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
94 chmod 755 $MNTPOINT/bin/chroot-script
95 mkdir $MNTPOINT/etc/debootstrap/
97 # make sure we have our files for later use via chroot-script
98 cp /etc/debootstrap/config $MNTPOINT/etc/debootstrap/
99 cp /etc/debootstrap/packages $MNTPOINT/etc/debootstrap/packages
101 # copy any existing existing files to chroot
102 [ -d /etc/debootstrap/boot ] && cp -a /etc/debootstrap/boot/* $MNTPOINT/boot/
103 [ -d /etc/debootstrap/etc ] && cp -a /etc/debootstrap/etc/* $MNTPOINT/etc/
104 [ -d /etc/debootstrap/share ] && cp -a /etc/debootstrap/share/* $MNTPOINT/share/
105 [ -d /etc/debootstrap/usr ] && cp -a /etc/debootstrap/usr/* $MNTPOINT/usr/
106 [ -d /etc/debootstrap/var ] && cp -a /etc/debootstrap/var/* $MNTPOINT/var/
109 einfo "Executing chroot-script now"
110 chroot $MNTPOINT /bin/chroot-script
113 einfo "Unmount $MNTPOINT"
117 if [ "$FSCK" = 'yes' ] ; then
118 [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
119 einfo "Checking filesystem on $TARGET using $FSCKTOOL"
124 einfo "Finished execution of $0 - enjoy your Debian system." ; eend 0
126 ## END OF FILE #################################################################