+# execute chroot-script {{{
+chrootscript() {
+ if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
+ mount_target
+ fi
+ if [ -x "$MNTPOINT/bin/chroot-script" ] ; then
+ einfo "Executing chroot-script now"
+ chroot "$MNTPOINT" /bin/chroot-script
+ eend $?
+ else
+ eerror "Fatal: $MNTPOINT/bin/chroot-script could not be found."
+ eend 1
+ fi
+}
+# }}}
+
+# install booloader grub {{{
+grub_install() {
+ if [ -z "$GRUB" -o -z "$GROOT" ] ; then
+ echo "Notice: \$GRUB or \$GROOT not defined, will not install grub therefor."
+ else
+ einfo "Installing grub on ${GRUB}:"
+ [ -x /usr/sbin/grub-install ] && GRUBINSTALL=/usr/sbin/grub-install || GRUBINSTALL=/sbin/grub-install
+ $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
+ eend $?
+ fi
+}
+# }}}
+
+# unmount $MNTPOINRT {{{
+umount_chroot() {
+ if [ -n "$ISODIR" ] ; then
+ if grep -q "$ISODIR" /proc/mounts ; then
+ einfo "Unmount $MNTPOINT/$ISODIR"
+ umount "$MNTPOINT/$ISODIR"
+ eend $?
+ fi
+ fi
+ if grep -q "$MNTPOINT" /proc/mounts ; then
+ if [ -n "$PARTITION" ] ; then
+ einfo "Unmount $MNTPOINT"
+ umount $MNTPOINT
+ eend $?
+ fi
+ fi
+}
+# }}}
+
+# execute filesystem check {{{
+fscktool() {
+ if [ "$FSCK" = 'yes' ] ; then
+ [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
+ einfo "Checking filesystem on $TARGET using $FSCKTOOL"
+ $FSCKTOOL $TARGET
+ eend $?
+ fi
+}
+# }}}
+
+# now execute all the functions {{{
+for i in mkfs tunefs mount_target debootstrap_system preparechroot \
+ chrootscript grub_install umount_chroot fscktool ; do
+ if stage "${i}" ; then
+ $i && stage "${i}" done || bailout 2 "i"
+ fi
+done
+# }}}
+
+# stages {{{
+ echo done > $STAGES/grml-debootstrap
+# }}}
+
+# end dialog of autoinstallation {{{
+if [ -n "$AUTOINSTALL" ] ; then
+ dialog --title "$PN" --msgbox \
+ "Finished execution of ${0}.
+Enjoy your Debian system." 6 60
+else
+ einfo "Finished execution of $PN - enjoy your Debian system." ; eend 0
+fi
+# }}}