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 ################################################################################
8 # http://www.debian.org/releases/stable/i386/index.html.en
10 set -e # exit on any error
15 MNTPOINT="/mnt/debootstrap.$$"
17 # inside the chroot system locales might not be available, so use minimum:
21 # make sure interactive mode is only executed when
22 # using an empty configuration file or option --interactive
26 # source core functions {{{
27 . /etc/grml/lsb-functions
28 . /etc/grml/script-functions
33 echo "$PN - wrapper around debootstrap for installing Debian
37 -h|--help Print this usage information and exit.
38 -v|--version Show summary of options and exit.
40 -c|--config <configfile> Use specified configuration file,
41 defaults to /etc/debootstrap/config
42 --hostname <hostname> Hostname of Debian system
43 -i|--iso <mnt> Mountpoint where a Debian ISO is mounted to,
44 for use instead of fetching packages from a mirror
45 -m|--mirror <URL> Mirror which should be used for apt-get/aptitude.
46 -p|--mntpoint <mnt> Mountpoint used for mounting the target system.
47 -r|--release <release> Release of new Debian system (default: stable)
48 -t|--target <target> Target partition (/dev/...) or directory.
50 --boot_append <appendline> Add specified appendline to kernel whilst booting
51 --groot <device> Root device for usage in grub, corresponds with
52 \$TARGET in grub syntax, like hd0,0 for /dev/sda1
53 --grub <device> Target for grub installation. Use grub syntax
54 for specifying, like hd0 for /dev/sda
55 --interactive Use interactive mode (frontend)
56 --password <pwd> Use specified password as password for user root.
58 Send bugreports to the grml-team: bugs@grml.org || http://grml.org/bugs/
62 if [ "$1" = '-h' ] || [ "$1" = '-help' ] ; then
64 echo 'Please notice that this script requires root permissions!'
69 # make sure we have what we need {{{
70 check4progs debootstrap dialog || exit 1
74 # source configuration file {{{
75 if [ -r /etc/debootstrap/config ] ; then
76 if [ -n "$CONFIGFILE" ] ; then
77 if ! . "$CONFIGFILE" ; then
78 eerror "Error reading config file $CONFIGFILE" ; eend 1 ; exit 1
81 . /etc/debootstrap/config
86 # cmdline handling {{{
88 while [ "$#" -gt "0" ] ; do
116 [ -n "$MIRROR" ] && unset MIRROR
141 einfo "$PN - version $VERSION"
142 einfo "Send bug reports to bugs@grml.org or http://grml.org/bugs/"
147 eerror "Syntax error."
159 dialog --title "$PN" --yesno "Welcome to the interactive configuration of ${PN}.
160 Do you want to continue installing Debian using this frontend?" 0 0
167 AVAILABLE_PARTITIONS=$(LANG=C fdisk -l 2>/dev/null | \
169 grep -v 'Extended$' | \
170 gawk -v num=0 -v ORS=' ' '/^\/dev\// {print $1}')
172 [ -n "$AVAILABLE_PARTITIONS" ] || echo "FIXME: no partitions available?"
173 PARTITION_LIST=$(for i in $(echo $AVAILABLE_PARTITIONS) ; do
174 echo "$i $(vol_id --type $i 2>/dev/null || echo [no_filesystem_yet])"
177 TARGET=$(dialog --title "$PN" --single-quoted --stdout \
178 --menu "Please select the target partition:" 0 0 0 \
183 # ask for bootmanager {{{
184 prompt_for_bootmanager()
187 for device in sda hda; do
188 if [ /dev/$device != ${TARGET%[0-9]} ]; then
189 grep -q $device /proc/partitions && \
190 ADDITIONAL_PARAMS=:$device:"install bootmanager grub into MBR of /dev/${device}"
193 ADDITIONAL_PARAMS=${ADDITIONAL_PARAMS#:}
197 if echo $TARGET | grep -q "/dev/md" ; then
198 MBRPART="all disks of Software RAID $TARGET"
200 MBRPART="MBR of ${TARGET%[0-9]}"
203 GETMBR=$(dialog --stdout --title "$PN" --default-item mbr \
204 --menu "Where do you want to install the bootmanager grub?" 0 0 0 \
205 mbr "install bootmanager into $MBRPART" \
206 partition "install bootmanager into partition $TARGET" \
207 nowhere "do not install bootmanager at all" \
208 ${ADDITIONAL_PARAMS})
209 [ $? -eq 0 ] || bailout 3
214 # /dev/md0: has to be installed in MBR of /dev/md0 and not in /dev/md:
215 if echo $TARGET | grep -q "*md*" ; then
216 BOOT_PARTITION="${TARGET}"
218 BOOT_PARTITION="${TARGET%[0-9]}"
222 BOOT_PARTITION="$TARGET"
225 BOOT_PARTITION="/dev/hda"
228 BOOT_PARTITION="/dev/sda"
237 # ask for Debian release {{{
240 RELEASE="$(dialog --stdout --title "${PN}" --default-item etch --menu \
241 "Please enter the Debian release you would like to use for installation:" \
244 lenny Debian/testing \
245 sid Debian/unstable)"
249 # ask for hostname {{{
250 prompt_for_hostname()
252 HOSTNAME="$(dialog --stdout --title "${PN}" --inputbox \
253 "Please enter the hostname you would like to use for installation:" \
258 # ask for Debian mirror {{{
261 MIRROR="$(dialog --stdout --title "${PN}" --inputbox \
262 "Please enter Debian mirror you would like to use for installing packages." \
263 0 0 http://ftp.de.debian.org/debian)"
267 # get grub's syntax for /dev/ice {{{
268 # usage example: 'grubdevice /dev/sda2' returns 'hd0,1'
270 if [ -z "$1" ] ; then
271 echo "Usage: grubdevice <device>">&2
276 device_map=/boot/grub/device.map
279 if ! [ -f "$device_map" ] ; then
280 echo 'quit' | grub --device-map="$device_map" 1>/dev/null 2>&1
283 # based on code from d-i's trunk/packages/arch/i386/grub-installer/grub-installer:
284 tmp_disk=`echo "$device" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
285 -e 's%\(fd[0-9]*\)$%\1%' \
286 -e 's%/part[0-9]*$%/disc%' \
287 -e 's%\(c[0-7]d[0-9]*\).*$%\1%'`
288 tmp_part=`echo "$device" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
289 -e 's%.*/fd[0-9]*$%%' \
290 -e 's%.*/floppy/[0-9]*$%%' \
291 -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
292 -e 's%.*c[0-7]d[0-9]*p*%%'`
293 tmp_drive=$(grep -v '^#' $device_map | grep "$tmp_disk *$" | sed 's%.*\([hf]d[0-9][a-g0-9,]*\).*%\1%')
296 /dev/[sh]d[a-z]) # we expect something like 'hd0'
299 *) # we expect something like 'hd0,0'
300 echo "$tmp_drive" | sed "s%$%,`expr $tmp_part - 1`%" # FIXME => md0
306 # software raid setup {{{
307 config_swraid_setup()
311 # Currently we support only raid1:
314 #RAIDLEVEL=$(dialog --stdout --title "$PN" --default-item raid1 \
315 # --menu "Which RAID level do you want to use?" 0 0 0 \
316 # raid1 "Software RAID level 1" \
317 # raid5 "Software RAID level 5")
318 #[ $? -eq 0 ] || bailout 20
320 MD_LIST=$(for i in $(seq 0 9) ; do
321 awk '{print $4}' /proc/partitions | grep -q md$i || \
322 echo "/dev/md$i /dev/md$i"
325 TARGET=$(dialog --stdout --title "$PN" --default-item /dev/md0 \
326 --menu "Which device do you want to use for ${RAIDLEVEL}?
328 Notice: activated devices will not be listed for security reasons. Anyway, please make sure the selected device is not in use already!" 0 0 0 \
330 [ $? -eq 0 ] || bailout 20
332 AVAILABLE_PARTITIONS=$(LANG=C fdisk -l 2>/dev/null | \
334 grep -v 'Extended$' | \
335 gawk -v num=0 -v ORS=' ' '/^\/dev\// {print $1}')
336 [ -n "$AVAILABLE_PARTITIONS" ] || echo "FIXME: no partitions available?"
337 PARTITION_LIST=$(for i in $(echo $AVAILABLE_PARTITIONS) ; do
338 echo "$i $(vol_id --type $i 2>/dev/null || echo [no_filesystem_yet]) off"
341 dialog --title "$PN" --separate-output \
342 --checklist "Please select the partitions you would like to use for your $RAIDLEVEL on ${TARGET}:" 0 0 0 \
343 $PARTITION_LIST 2>$TMPFILE
345 SELECTED_PARTITIONS="$(cat $TMPFILE)"
348 for i in $(cat $TMPFILE) ; do
349 NUM_PARTITIONS=$((${NUM_PARTITIONS}+1))
354 # TODO: better error handling?
355 yes | mdadm --create "${TARGET}" --level="${RAIDLEVEL}" \
356 --raid-devices="${NUM_PARTITIONS}" ${SELECTED_PARTITIONS} 1>/dev/null 2>$ERRORFILE
360 if [ "$RC" = 0 ] ; then
361 dialog --title "$PN" --msgbox \
362 "Creating $TARGET was successful." 0 0
363 rm -f "$TMPFILE" "$ERRORFILE"
365 dialog --title "$PN" --msgbox \
366 "There was an error setting up $TARGET:
371 rm -f "$TMPFILE" "$ERRORFILE"
379 if dialog --stdout --title "$PN" \
380 --defaultno --yesno "Do you want to configure Software RAID?
382 Please notice that only RAID level 1 is supported by ${PN} currently. Configuration will take place using mdadm." 0 0 ; then
388 # make sure the user is aware of the used configuration {{{
391 if [ -n "$AUTOINSTALL" ] ; then
392 if checkforrun ; then
393 eerror "Exiting as requested" ; eend 0
396 elif [ -n "$INTERACTIVE" ] ; then
398 INFOTEXT="Please recheck configuration before execution:
400 [ -n "$TARGET" ] && INFOTEXT="$INFOTEXT
402 [ -n "$GRUB" ] && INFOTEXT="$INFOTEXT
404 [ -n "$RELEASE" ] && INFOTEXT="$INFOTEXT
405 Using release: $RELEASE"
406 [ -n "$HOSTNAME" ] && INFOTEXT="$INFOTEXT
407 Using hostname $HOSTNAME"
408 [ -n "$MIRROR" ] && INFOTEXT="$INFOTEXT
409 Using mirror: $MIRROR"
413 Is this ok for you? Notice: selecting 'No' will exit ${PN}."
415 dialog --title "$PN" --no-collapse \
416 --yesno "$INFOTEXT" 0 0
418 else # if not running automatic installation display configuration and prompt for execution:
419 einfo "$PN - Please recheck configuration before execution:"
421 echo " Target: $TARGET"
422 case "$MNTPOINT" in "$TARGET") ;; *) echo " Mount point: $MNTPOINT" ;; esac
423 [ -n "$GRUB" ] && echo " Install grub: $GRUB" || echo " Install grub: no"
424 [ -n "$RELEASE" ] && echo " Using release: $RELEASE"
425 [ -n "$MIRROR" ] && echo " Using mirror: $MIRROR"
426 [ -n "$ISO" ] && echo " Using iso: $ISO"
427 case "$MNTPOINT" in "$TARGET") ;; *) echo " Important! Continuing will delete all data from ${TARGET}!" ;; esac
429 einfon "Is this ok for you? [y/N] "
431 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
432 eerror "Exiting as requested." ; eend 1
439 # interactive mode {{{
446 # do not prompt for partition dialog if swraid has been configured already
447 [ -n "$TARGET" ] || prompt_for_target
449 prompt_for_bootmanager
455 # use first disk of sw-raid for grub by default, install grub on
456 # all involved disks later on
457 if echo "$TARGET" | grep -q '/dev/md' ; then
458 if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
459 # use hdX and not hdX,Y for $GRUB
460 TMPDEVICE=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}') # use first disk only
461 GRUB="$(grubdevice ${TMPDEVICE%%[0-9]})" # like: hd0
462 GROOT="$(grubdevice ${TMPDEVICE})" # like: hd0,0
463 echo "debug: GRUB = $GRUB - GROOT = $GROOT" >/tmp/debug # FIXME
466 [ -n "$BOOT_PARTITION" ] && GRUB="$(grubdevice $BOOT_PARTITION)"
467 [ -n "$TARGET" ] && GROOT="$(grubdevice $TARGET)"
475 # run interactive mode if we didn't get the according configuration yet
476 if [ -z "$TARGET" -o -n "$INTERACTIVE" ] ; then
477 # only target might be unset, so make sure the INTERACTIVE flag is set as well
483 # finally make sure at least $TARGET is set [the partition for the new system] {{{
484 if [ -n "$TARGET" ] ; then
485 SHORT_TARGET="${TARGET##*/}"
487 eerror "Please adjust /etc/debootstrap/config or..."
488 eerror "... use the interactive version for configuration before running ${0}" ; eend 1
494 if [ -z "$STAGES" ] ; then
495 STAGES="/var/cache/grml-debootstrap/stages_${SHORT_TARGET}"
496 [ -d "$STAGES" ] || mkdir -p "$STAGES"
499 if [ -r "$STAGES"/grml-debootstrap ] ; then
500 if grep -q done $STAGES/grml-debootstrap ; then
501 eerror "Error: grml-debootstrap has been executed already, won't continue therefore."
502 eerror "If you want to re-execute grml-debootstrap just manually remove ${STAGES}" ; eend 1
507 # partition handling {{{
516 # assume we are installing into a directory, don't run mkfs and grub related stuff therefore
528 # architecture setup {{{
529 if [ -n "$ARCH" ] ; then
530 ARCHCMD="--arch $ARCH"
531 ARCHINFO=" (${ARCH})"
533 ARCH="$(dpkg --print-architecture)"
534 ARCHCMD="--arch $ARCH"
535 ARCHINFO=" (${ARCH})"
539 # make sure we have the right syntax when using an iso image {{{
540 if [ -n "$ISO" ] ; then
553 # provide variables to chroot system {{{
554 CHROOT_VARIABLES="/var/cache/grml-debootstrap/variables_${SHORT_TARGET}"
555 touch $CHROOT_VARIABLES
556 chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
557 [ -n "$ARCH" ] && echo "ARCH=$ARCH" > $CHROOT_VARIABLES
558 [ -n "$GRUB" ] && echo "GRUB=$GRUB" >> $CHROOT_VARIABLES
559 [ -n "$GROOT" ] && echo "GROOT=$GROOT" >> $CHROOT_VARIABLES
560 [ -n "$TARGET" ] && echo "TARGET=$TARGET" >> $CHROOT_VARIABLES
561 [ -n "$ISO" ] && echo "ISO=$ISO" >> $CHROOT_VARIABLES
562 [ -n "$ISODIR" ] && echo "ISODIR=$ISO" >> $CHROOT_VARIABLES
563 [ -n "$MIRROR" ] && echo "MIRROR=$MIRROR" >> $CHROOT_VARIABLES
564 [ -n "$MIRROR" ] && echo "CHROOTMIRROR=$MIRROR" >> $CHROOT_VARIABLES
565 [ -n "$ROOTPASSWORD" ] && echo "ROOTPASSWORD=$ROOTPASSWORD" >> $CHROOT_VARIABLES
568 # helper functions {{{
569 # we want to exit smoothly and clean:
571 # make sure $TARGET is not mounted when exiting grml-debootstrap
572 if [ -n "$MNTPOINT" ] ; then
573 if grep -q $MNTPOINT /proc/mounts ; then
574 # make sure nothing is left inside chroot so we can unmount it
575 [ -x "$MNTPOINT"/etc/init.d/ssh ] && "$MNTPOINT"/etc/init.d/ssh stop
576 [ -x "$MNTPOINT"/etc/init.d/mdadm ] && "$MNTPOINT"/etc/init.d/mdadm stop
577 # ugly, but make sure we really don't leav anything
578 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /sys 1>/dev/null 2>&1
579 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount -a 1>/dev/null 2>&1
580 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /proc 1>/dev/null 2>&1
581 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /proc 1>/dev/null 2>&1
582 [ -d "$MNTPOINT/$ISODIR" ] && umount "$MNTPOINT/$ISODIR" 1>/dev/null 2>&1
583 einfo "Unmounting $MNTPOINT" ; umount "$MNTPOINT" ; eend $?
585 if [ -n "$STAGES" ] ; then
586 echo -n "Removing stages directory ${STAGES}: "
587 rm -rf "$STAGES" && echo done
590 # remove directory only if we used the default with process id inside the name
591 if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
592 einfo "Removing directory ${MNTPOINT}" ; rmdir $MNTPOINT ; eend $?
597 [ -n "$1" ] && EXIT="$1" || EXIT="1"
598 [ -n "$3" ] && einfo "Notice: just remove $STAGES/$3 to reexecute the stage"
602 trap bailout HUP INT QUIT TERM
604 # we want to execute all the functions only once, simple check for it:
606 if [ -n "$2" ] ; then
607 echo "$2" > "${STAGES}/${1}"
609 elif grep -q done "${STAGES}/${1}" 2>/dev/null ; then
610 ewarn "Notice: stage $1 has been executed already, skipping execution therefore." ; eend 0
612 ewarn "To reexecute it clean up the according directory inside $STAGES" ; eend 0
619 # user should recheck his configuration {{{
620 # support full automatic installation:
622 dialog --timeout 10 --title "$PN" \
623 --yesno "Do you want to stop at this stage?
625 Notice: you are running ${PN} in non-interactive mode.
626 ${PN} will install Debian ${RELEASE} on ${TARGET}.
627 Last chance to quit. Timeout of 10 seconds running....
629 Do you want to stop now?" 0 0 2>/dev/null
632 # create filesystem {{{
634 if [ -n "$MKFS" ] ; then
635 einfo "Running $MKFS on $TARGET"
642 # modify filesystem settings {{{
644 if [ -n "$TUNE2FS" ] ; then
645 einfo "Disabling automatic filesystem check on $TARGET via tune2fs"
652 # mount the new partition or if it's a directory do nothing at all {{{
654 if [ -n "$DIRECTORY" ] ; then
655 einfo "Running grml-debootstrap on a directory, nothing to mount."
657 if grep -q $TARGET /proc/mounts ; then
658 eerror "$TARGET already mounted, exiting."
660 [ -d "$MNTPOINT" ] || mkdir -p "$MNTPOINT"
661 einfo "Mounting $TARGET to $MNTPOINT"
662 mount -o rw,suid,dev $TARGET $MNTPOINT
666 if [ -n "$ISODIR" ] ; then
667 einfo "Mounting Debian image loopback to $MNTPOINT/$ISODIR."
668 mkdir -p "$MNTPOINT/$ISODIR"
669 mount --bind "$ISODIR" "$MNTPOINT/$ISODIR"
675 # install main chroot {{{
676 debootstrap_system() {
677 if ! grep -q $MNTPOINT /proc/mounts ; then
680 if grep -q $MNTPOINT /proc/mounts ; then
681 einfo "Running $DEBOOTSTRAP for release ${RELEASE}${ARCHINFO} using ${MIRROR}${ISO}"
682 [ -n "$MIRROR" ] && $DEBOOTSTRAP $ARCHCMD $RELEASE $MNTPOINT $MIRROR || \
683 $DEBOOTSTRAP $ARCHCMD $RELEASE $MNTPOINT $ISO
686 eerror "Error: $MNTPOINT not mounted, can not continue."
692 # prepare chroot via chroot-script {{{
694 einfo "Preparing chroot system"
695 cp $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
696 chmod 755 $MNTPOINT/bin/chroot-script
697 mkdir $MNTPOINT/etc/debootstrap/
699 # make sure we have our files for later use via chroot-script
700 cp /etc/debootstrap/config $MNTPOINT/etc/debootstrap/
701 # make sure we adjust the configuration variables accordingly:
702 sed -i "s#RELEASE=.*#RELEASE=\"$RELEASE\"#" $MNTPOINT/etc/debootstrap/config
703 sed -i "s#TARGET=.*#TARGET=\"$TARGET\"#" $MNTPOINT/etc/debootstrap/config
704 sed -i "s#GRUB=.*#GRUB=\"$GRUB\"#" $MNTPOINT/etc/debootstrap/config
705 sed -i "s#GROOT=.*#GROOT=\"$GROOT\"#" $MNTPOINT/etc/debootstrap/config
707 cp /etc/debootstrap/packages $MNTPOINT/etc/debootstrap/packages
709 # notice: do NOT use $CHROOT_VARIABLES inside chroot but statically file instead!
710 cp $CHROOT_VARIABLES $MNTPOINT/etc/debootstrap/variables
712 cp -a /etc/debootstrap/extrapackages/ $MNTPOINT/etc/debootstrap/
714 # make sure we can access network [relevant for cdebootstrap]
715 [ -f "$MNTPOINT/etc/resolv.conf" ] || cp /etc/resolv.conf $MNTPOINT/etc/resolv.conf
717 # provide system's /etc/hosts to the target:
718 if ! [ -f "$MNTPOINT/etc/hosts" ] ; then
719 cp /etc/hosts $MNTPOINT/etc/hosts
720 sed -i "s#127.0.0.1 .*#127.0.0.1 localhost $HOSTNAME#" /etc/hosts
723 # setup default locales
724 [ -n "$LOCALES" ] && cp /etc/debootstrap/locale.gen $MNTPOINT/etc/locale.gen
726 # MAKEDEV is just a forking bomb crap, let's do it on our own instead :)
727 ( cd $MNTPOINT/dev && tar zxf /etc/debootstrap/devices.tar.gz )
729 # copy any existing existing files to chroot
730 [ -d /etc/debootstrap/boot ] && cp -a /etc/debootstrap/boot/* $MNTPOINT/boot/
731 [ -d /etc/debootstrap/etc ] && cp -a /etc/debootstrap/etc/* $MNTPOINT/etc/
732 [ -d /etc/debootstrap/share ] && cp -a /etc/debootstrap/share/* $MNTPOINT/share/
733 [ -d /etc/debootstrap/usr ] && cp -a /etc/debootstrap/usr/* $MNTPOINT/usr/
734 [ -d /etc/debootstrap/var ] && cp -a /etc/debootstrap/var/* $MNTPOINT/var/
736 # copy local network setup to chroot
737 if [ -r /etc/network/interfaces -a ! -r "${MNTPOINT}"/etc/network/interfaces ] ; then
738 [ -d $MNTPOINT/etc/network ] || mkdir $MNTPOINT/etc/network
739 cp /etc/network/interfaces $MNTPOINT/etc/network/interfaces
746 # execute chroot-script {{{
748 if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
751 if [ -x "$MNTPOINT/bin/chroot-script" ] ; then
752 einfo "Executing chroot-script now"
753 chroot "$MNTPOINT" /bin/chroot-script
756 eerror "Fatal: $MNTPOINT/bin/chroot-script could not be found."
762 # install booloader grub {{{
764 if [ -z "$GRUB" -o -z "$GROOT" ] ; then
765 echo "Notice: \$GRUB or \$GROOT not defined, will not install grub therefor."
766 elif [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
767 for device in $SELECTED_PARTITIONS ; do
768 # TMPDEVICE=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}')
769 # GRUB="$(grubdevice ${TMPDEVICE})"
770 # GRUB="$(grubdevice ${TMPDEVICE%%[0-9]})"
771 # GRUB=$(grubdevice $device)
772 GRUB="$(grubdevice ${device%%[0-9]})"
773 einfo "Installing grub on ${GRUB}:"
774 [ -x /usr/sbin/grub-install ] && GRUBINSTALL="/usr/sbin/grub-install --no-floppy" || GRUBINSTALL="/sbin/grub-install --no-floppy"
775 $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
779 einfo "Installing grub on ${GRUB}:"
780 [ -x /usr/sbin/grub-install ] && GRUBINSTALL="/usr/sbin/grub-install --no-floppy" || GRUBINSTALL="/sbin/grub-install --no-floppy"
781 $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
787 # unmount $MNTPOINRT {{{
789 if [ -n "$ISODIR" ] ; then
790 if grep -q "$ISODIR" /proc/mounts ; then
791 einfo "Unmount $MNTPOINT/$ISODIR"
792 umount "$MNTPOINT/$ISODIR"
796 if grep -q "$MNTPOINT" /proc/mounts ; then
797 if [ -n "$PARTITION" ] ; then
798 einfo "Unmount $MNTPOINT"
806 # execute filesystem check {{{
808 if [ "$FSCK" = 'yes' ] ; then
809 [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
810 einfo "Checking filesystem on $TARGET using $FSCKTOOL"
817 # now execute all the functions {{{
818 for i in mkfs tunefs mount_target debootstrap_system preparechroot \
819 chrootscript grub_install umount_chroot fscktool ; do
820 if stage "${i}" ; then
821 $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "i"
827 einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" ; eend $?
828 einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $?
830 # Remove temporary mountpoint again
831 if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
832 einfo "Removing directory ${MNTPOINT}" ; rmdir "$MNTPOINT" ; eend $?
836 # end dialog of autoinstallation {{{
837 if [ -n "$AUTOINSTALL" ] ; then
838 dialog --title "$PN" --msgbox \
839 "Finished execution of ${PN}. Enjoy your Debian system." 0 0
841 einfo "Finished execution of ${PN}. Enjoy your Debian system." ; eend 0
845 ## END OF FILE #################################################################
846 # vim: ai tw=100 expandtab foldmethod=marker shiftwidth=3