221f8d3516b49cfc37a1827b82a70c1c7e8e8841
[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: Wed Aug 27 01:46:13 CEST 2008 [mika]
8 ################################################################################
9 # http://www.debian.org/releases/stable/i386/index.html.en
10
11 set -e # exit on any error
12
13 # variables {{{
14 PN="$(basename $0)"
15 VERSION='0.18'
16 MNTPOINT="/mnt/debootstrap.$$"
17
18 # inside the chroot system locales might not be available, so use minimum:
19 export LANG=C
20 export LC_ALL=C
21
22 # make sure interactive mode is only executed when
23 # using an empty configuration file or option --interactive
24 INTERACTIVE=''
25 # }}}
26
27 # source core functions {{{
28 . /etc/grml/lsb-functions
29 . /etc/grml/script-functions
30 # }}}
31
32 # help text {{{
33 usage() {
34   echo "$PN - wrapper around debootstrap for installing Debian
35
36 Usage: $PN [options]
37
38   -h|--help                   Print this usage information and exit.
39   -v|--version                Show summary of options and exit.
40
41   -c|--config <configfile>    Use specified configuration file,
42                               defaults to /etc/debootstrap/config
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.
49
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.
57
58 Send bugreports to the grml-team: bugs@grml.org || http://grml.org/bugs/
59 "
60 }
61
62 if [ "$1" = '-h' ] || [ "$1" = '-help' ] ; then
63    usage
64    echo 'Please notice that this script requires root permissions!'
65    exit 0
66 fi
67 # }}}
68
69 # make sure we have what we need {{{
70 check4progs debootstrap dialog || exit 1
71 check4root || exit 1
72 # }}}
73
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
79       fi
80    else
81       . /etc/debootstrap/config
82    fi
83 fi
84 # }}}
85
86 # cmdline handling {{{
87
88 while [ "$#" -gt "0" ] ; do
89     case $1 in
90         -c|--config)
91             shift
92             CONFIGFILE=$1
93             ;;
94         --grub)
95             shift
96             GRUB=$1
97             ;;
98         --groot)
99             shift
100             GROOT=$1
101             ;;
102         -h|--help)
103             usage ; eend 0
104             eend 0
105             exit 0
106             ;;
107         --interactive)
108             INTERACTIVE=1
109             ;;
110         -i|--iso)
111             shift
112             [ -n "$MIRROR" ] && unset MIRROR
113             ISO=$1
114             ;;
115         -m|--mirror)
116             shift
117             MIRROR=$1
118             CHROOTMIRROR=$1
119             ;;
120         -p|--mntpoint)
121             shift
122             MNTPOINT=$1
123             ;;
124         --password)
125             shift
126             ROOTPASSWORD=$1
127             ;;
128         -r|--release)
129             shift
130             RELEASE=$1
131             ;;
132         -t|--target)
133             shift
134             TARGET=$1
135             ;;
136         -v|--version)
137             einfo "$PN - version $VERSION"
138             einfo "Send bug reports to bugs@grml.org or http://grml.org/bugs/"
139             eend 0
140             exit 0
141             ;;
142         *)
143             eerror "Syntax error."
144             usage ; eend 1
145             exit 1
146             ;;
147     esac
148     shift
149 done
150 # }}}
151
152 # ask for target {{{
153 prompt_for_target()
154 {
155   AVAILABLE_PARTITIONS=$(LANG=C fdisk -l 2>/dev/null | \
156                sed 's/*//' | \
157                grep -v 'Extended$' | \
158                gawk -v num=0 -v ORS=' ' '/^\/dev\// {print $1}')
159
160   [ -n "$AVAILABLE_PARTITIONS" ] || echo "FIXME: no partitions available?"
161   PARTITION_LIST=$(for i in $(echo $AVAILABLE_PARTITIONS) ; do
162                        echo "$i $(vol_id --type $i 2>/dev/null || echo [no_filesystem_yet])"
163                    done)
164
165   TARGET=$(dialog --title "$PN" --single-quoted --stdout \
166          --menu "Please select the target partition:" 0 0 0 \
167          $PARTITION_LIST)
168 }
169 # }}}
170
171 # ask for bootmanager {{{
172 prompt_for_bootmanager()
173 {
174   ADDITIONAL_PARAMS=""
175   for device in sda hda; do
176     if [ /dev/$device != ${TARGET%[0-9]} ]; then
177       grep -q $device /proc/partitions && \
178       ADDITIONAL_PARAMS=:$device:"install bootmanager grub into MBR of /dev/${device}"
179     fi
180   done
181   ADDITIONAL_PARAMS=${ADDITIONAL_PARAMS#:}
182
183   OIFS="$IFS"; IFS=:
184
185   if echo $TARGET | grep -q "*md*" ; then
186      MBRPART=$TARGET
187   else
188      MBRPART="${TARGET%[0-9]}"
189   fi
190
191   GETMBR=$(dialog --stdout --title "$PN" --default-item mbr \
192           --menu "Where do you want to install the bootmanager grub?" 0 0 0 \
193             mbr       "install bootmanager into MBR of $MBRPART" \
194             partition "install bootmanager into partition $TARGET" \
195             nowhere   "do not install bootmanager at all" \
196           ${ADDITIONAL_PARAMS})
197   [ $? -eq 0 ] || bailout 3
198   IFS="$OIFS"
199
200   case "$GETMBR" in
201     mbr)
202       USE_MBR=1
203       # /dev/md0: has to be installed in MBR of /dev/md0 and not in /dev/md:
204       if echo $TARGET | grep -q "*md*" ; then
205          BOOT_PARTITION="${TARGET}"
206       else
207          BOOT_PARTITION="${TARGET%[0-9]}"
208       fi
209       ;;
210     partition)
211       BOOT_PARTITION="$TARGET"
212       ;;
213     hda)
214       USE_MBR=1
215       BOOT_PARTITION="/dev/hda"
216       ;;
217     sda)
218       USE_MBR=1
219       BOOT_PARTITION="/dev/sda"
220       ;;
221     nowhere)
222       BOOT_PARTITION=''
223       ;;
224   esac
225 }
226 # }}}
227
228 # ask for Debian mirror {{{
229 prompt_for_mirror()
230 {
231   MIRROR="$(dialog --stdout --title "${PN}" --inputbox \
232             "Please enter Debian mirror you would like to use for installing packages." \
233             0 0 http://ftp.de.debian.org/debian)"
234 }
235 # }}}
236
237 # get grub's syntax for /dev/ice {{{
238 # usage example: 'grubdevice /dev/sda2' returns 'hd0,1'
239 grubdevice() {
240   if [ -z "$1" ] ; then
241      echo "Usage: grubdevice <device>">&2
242      return 1
243   fi
244
245   device="$1"
246   device_map=/boot/grub/device.map
247
248   # create device.map
249   if ! [ -f "$device_map" ] ; then
250      echo 'quit' | grub --device-map="$device_map" 1>/dev/null 2>&1
251   fi
252
253   # taken from d-i's trunk/packages/arch/i386/grub-installer/grub-installer:
254   tmp_disk=`echo "$device" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
255                     -e 's%\(fd[0-9]*\)$%\1%' \
256                     -e 's%/part[0-9]*$%/disc%' \
257                     -e 's%\(c[0-7]d[0-9]*\).*$%\1%'`
258   tmp_part=`echo "$device" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
259                     -e 's%.*/fd[0-9]*$%%' \
260                     -e 's%.*/floppy/[0-9]*$%%' \
261                     -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
262                     -e 's%.*c[0-7]d[0-9]*p*%%'`
263   tmp_drive=$(grep -v '^#' $device_map | grep "$tmp_disk *$" | sed 's%.*\([hf]d[0-9][a-g0-9,]*\).*%\1%')
264
265   case $1 in
266      /dev/[sh]d[a-z]) # we expect something like 'hd0'
267         echo "$tmp_drive"
268         ;;
269       *) # we expect something like 'hd0,0'
270         # make sure we don't install into MBR if $USE_MBR is not set
271         if [ -z "$USE_MBR" ] ; then
272            echo "$tmp_drive" | sed "s%$%,`expr $tmp_part - 1`%"
273         else
274            echo "$tmp_drive" | sed "s%,[0-9]%%"
275         fi
276         ;;
277   esac
278 }
279 # }}}
280
281 # interactive mode {{{
282 interactive_mode()
283 {
284   prompt_for_target
285   prompt_for_bootmanager
286   prompt_for_mirror
287
288   [ -n "$BOOT_PARTITION" ] && GRUB="$(grubdevice $BOOT_PARTITION)"
289   [ -n "$TARGET" ]         && GROOT="$(grubdevice $TARGET)"
290
291   # FIXME
292   echo "debug: BOOT_PARTITION=$BOOT_PARTITION"
293   echo "debug: TARGET=$TARGET"
294   echo "debug: MIRROR=$MIRROR"
295   echo "debug: GROOT=$GROOT"
296   echo "debug: GRUB=$GRUB"
297
298   # TODO
299   # ask for raid
300   # ask for lvm
301 }
302
303 # run interactive mode if we didn't get the according configuration yet
304 if [ -z "$TARGET" -o -n "$INTERACTIVE" ] ; then
305    interactive_mode
306 fi
307 # }}}
308
309 # finally make sure at least $TARGET is set [the partition for the new system] {{{
310 if [ -n "$TARGET" ] ; then
311    SHORT_TARGET="${TARGET##*/}"
312 else
313    eerror "Please adjust /etc/debootstrap/config or..."
314    eerror "... use the interactive version for configuration before running ${0}" ; eend 1
315    exit 1
316 fi
317 # }}}
318
319 # stages setup {{{
320 if [ -z "$STAGES" ] ; then
321    STAGES="/etc/debootstrap/stages_${SHORT_TARGET}"
322    [ -d "$STAGES" ] || mkdir -p "$STAGES"
323 fi
324
325 if [ -r "$STAGES"/grml-debootstrap ] ; then
326    if grep -q done $STAGES/grml-debootstrap ; then
327       eerror "Error: grml-debootstrap has been executed already, won't continue therefore."
328       eerror "If you want to re-execute grml-debootstrap just manually remove ${STAGES}" ; eend 1
329    fi
330 fi
331 # }}}
332
333 # partition handling {{{
334 PARTITION=''
335 DIRECTORY=''
336
337 case $TARGET in
338   /dev/*)
339     PARTITION=1
340     ;;
341   *)
342     # assume we are installing into a directory, don't run mkfs and grub related stuff therefore
343     DIRECTORY=1
344     MNTPOINT="$TARGET"
345     MKFS=''
346     TUNE2FS=''
347     FSCK=''
348     GRUB=''
349     GROOT=''
350     ;;
351 esac
352 # }}}
353
354 # architecture setup {{{
355 if [ -n "$ARCH" ] ; then
356    ARCHCMD="--arch $ARCH"
357    ARCHINFO=" (${ARCH})"
358 else
359    ARCH="$(dpkg --print-architecture)"
360    ARCHCMD="--arch $ARCH"
361    ARCHINFO=" (${ARCH})"
362 fi
363 # }}}
364
365 # make sure we have the right syntax when using an iso image {{{
366 if [ -n "$ISO" ] ; then
367    case $ISO in
368       file*) # do nothing
369       ;;
370       *)
371       ISO=file:$1
372       ;;
373    esac
374 fi
375 ISODIR=${ISO##file:}
376 ISODIR=${ISODIR%%/}
377 # }}}
378
379 # provide variables to chroot system {{{
380 CHROOT_VARIABLES="/etc/debootstrap/variables_${SHORT_TARGET}"
381 touch $CHROOT_VARIABLES
382 chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
383 [ -n "$ARCH" ]   && echo "ARCH=$ARCH"     >  $CHROOT_VARIABLES
384 [ -n "$GRUB" ]   && echo "GRUB=$GRUB"     >> $CHROOT_VARIABLES
385 [ -n "$GROOT" ]  && echo "GROOT=$GROOT"   >> $CHROOT_VARIABLES
386 [ -n "$TARGET" ] && echo "TARGET=$TARGET" >> $CHROOT_VARIABLES
387 [ -n "$ISO" ]    && echo "ISO=$ISO"       >> $CHROOT_VARIABLES
388 [ -n "$ISODIR" ] && echo "ISODIR=$ISO"    >> $CHROOT_VARIABLES
389 [ -n "$MIRROR" ] && echo "MIRROR=$MIRROR" >> $CHROOT_VARIABLES
390 [ -n "$MIRROR" ] && echo "CHROOTMIRROR=$MIRROR" >> $CHROOT_VARIABLES
391 [ -n "$ROOTPASSWORD" ] && echo "ROOTPASSWORD=$ROOTPASSWORD" >> $CHROOT_VARIABLES
392 # }}}
393
394 # helper functions {{{
395 # we want to exit smoothly and clean:
396 bailout(){
397   # make sure $TARGET is not mounted when exiting grml-debootstrap
398   if [ -n "$MNTPOINT" ] ; then
399      if grep -q $MNTPOINT /proc/mounts ; then
400         # make sure nothing is left inside chroot so we can unmount it
401         [ -x "$MNTPOINT"/etc/init.d/ssh   ] && "$MNTPOINT"/etc/init.d/ssh stop
402         [ -x "$MNTPOINT"/etc/init.d/mdadm ] && "$MNTPOINT"/etc/init.d/mdadm stop
403         # ugly, but make sure we really don't leav anything
404         [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /sys  1>/dev/null 2>&1
405         [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount -a    1>/dev/null 2>&1
406         [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /proc 1>/dev/null 2>&1
407         [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /proc 1>/dev/null 2>&1
408         [ -d "$MNTPOINT/$ISODIR" ]    && umount "$MNTPOINT/$ISODIR" 1>/dev/null 2>&1
409         einfo "Unmounting $MNTPOINT"   ; umount "$MNTPOINT" ; eend $?
410
411         # remove directory only if we used the default with process id inside the name
412         if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
413            einfo "Removing directory ${MNTPOINT}" ; rmdir $MNTPOINT ; eend $?
414         fi
415      fi
416   fi
417
418   [ -n "$1" ] && EXIT="$1" || EXIT="1"
419   [ -n "$3" ] && einfo "Notice: just remove $STAGES/$3 to reexecute the stage"
420
421   exit "$EXIT"
422 }
423 trap bailout HUP INT QUIT TERM
424
425 # we want to execute all the functions only once, simple check for it:
426 stage() {
427   if [ -n "$2" ] ; then
428      echo "$2" > "${STAGES}/${1}"
429      return 0
430   elif grep -q done "${STAGES}/${1}" 2>/dev/null ; then
431      ewarn "Notice: stage $1 has been executed already, skipping execution therefore." ; eend 0
432      eindent
433        ewarn "To reexecute it clean up the according directory inside $STAGES" ; eend 0
434      eoutdent
435      return 1
436   fi
437 }
438 # }}}
439
440 # user should recheck his configuration {{{
441 # support full automatic installation:
442 checkforrun() {
443    dialog --timeout 10 --title "$PN" \
444           --yesno "Do you want to stop at this stage?
445
446 Notice: you are running grml-debootstrap in non-interactive mode.
447 grml-debootstrap will install Debian ${RELEASE} on ${TARGET}.
448 Last chance to quit. Timeout of 10 seconds running....
449
450 Do you want to stop now?" 0 0 2>/dev/null
451 }
452
453 if [ -n "$AUTOINSTALL" ] ; then
454    if checkforrun ; then
455       eerror "Exiting as requested" ; eend 0
456       exit 1
457    fi
458 else # if not running automatic installation display configuration and prompt for execution:
459    einfo "$PN - Please recheck configuration before execution:"
460    echo
461    echo "   Target:          $TARGET"
462       case "$MNTPOINT" in "$TARGET") ;; *) echo "   Mount point:     $MNTPOINT" ;; esac
463       [ -n "$GRUB" ]    && echo "   Install grub:    $GRUB" || echo "   Install grub:    no"
464       [ -n "$RELEASE" ] && echo "   Using release:   $RELEASE"
465       [ -n "$MIRROR" ]  && echo "   Using mirror:    $MIRROR"
466       [ -n "$ISO" ]     && echo "   Using iso:       $ISO"
467       case "$MNTPOINT" in "$TARGET") ;; *) echo "   Important! Continuing will delete all data from ${TARGET}!" ;; esac
468       echo
469    einfon "Is this ok for you? [y/N] "
470    read a
471    if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
472       eerror "Exiting as requested." ; eend 1
473       exit 1
474    fi
475 fi
476 # }}}
477
478 # create filesystem {{{
479 mkfs() {
480   if [ -n "$MKFS" ] ; then
481      einfo "Running $MKFS on $TARGET"
482      $MKFS $TARGET
483      eend $?
484   fi
485 }
486 # }}}
487
488 # modify filesystem settings {{{
489 tunefs() {
490   if [ -n "$TUNE2FS" ] ; then
491      einfo "Disabling automatic filesystem check on $TARGET via tune2fs"
492      $TUNE2FS $TARGET
493      eend $?
494   fi
495 }
496 # }}}
497
498 # mount the new partition or if it's a directory do nothing at all {{{
499 mount_target() {
500   if [ -n "$DIRECTORY" ] ; then
501      einfo "Running grml-debootstrap on a directory, nothing to mount."
502   else
503      if grep -q $TARGET /proc/mounts ; then
504         eerror "$TARGET already mounted, exiting."
505      else
506        [ -d "$MNTPOINT" ] || mkdir -p "$MNTPOINT"
507        einfo "Mounting $TARGET to $MNTPOINT"
508        mount -o rw,suid,dev $TARGET $MNTPOINT
509        eend $?
510      fi
511   fi
512   if [ -n "$ISODIR" ] ; then
513      einfo "Mounting Debian image loopback to $MNTPOINT/$ISODIR."
514      mkdir -p "$MNTPOINT/$ISODIR"
515      mount --bind "$ISODIR" "$MNTPOINT/$ISODIR"
516      eend $?
517   fi
518 }
519 # }}}
520
521 # install main chroot {{{
522 debootstrap_system() {
523   if ! grep -q $MNTPOINT /proc/mounts ; then
524      mount_target
525   fi
526   if grep -q $MNTPOINT /proc/mounts ; then
527      einfo "Running $DEBOOTSTRAP for release ${RELEASE}${ARCHINFO} using ${MIRROR}${ISO}"
528      [ -n "$MIRROR" ] && $DEBOOTSTRAP $ARCHCMD $RELEASE $MNTPOINT $MIRROR || \
529      $DEBOOTSTRAP $ARCHCMD $RELEASE $MNTPOINT $ISO
530      eend $?
531   else
532      eerror "Error: $MNTPOINT not mounted, can not continue."
533      eend 1
534   fi
535 }
536 # }}}
537
538 # prepare chroot via chroot-script {{{
539 preparechroot() {
540   einfo "Preparing chroot system"
541   cp $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
542   chmod 755 $MNTPOINT/bin/chroot-script
543   mkdir $MNTPOINT/etc/debootstrap/
544
545   # make sure we have our files for later use via chroot-script
546   cp /etc/debootstrap/config    $MNTPOINT/etc/debootstrap/
547   cp /etc/debootstrap/packages  $MNTPOINT/etc/debootstrap/packages
548   cp $CHROOT_VARIABLES          $MNTPOINT/etc/debootstrap/variables # do NOT use $CHROOT_VARIABLES inside chroot!
549
550   cp -a /etc/debootstrap/extrapackages/ $MNTPOINT/etc/debootstrap/
551
552   # make sure we can access network [relevant for cdebootstrap]
553   [ -f "$MNTPOINT/etc/resolv.conf" ] || cp /etc/resolv.conf $MNTPOINT/etc/resolv.conf
554
555   # setup default locales
556   [ -n "$LOCALES" ] && cp /etc/debootstrap/locale.gen  $MNTPOINT/etc/locale.gen
557
558   # copy any existing existing files to chroot
559   [ -d /etc/debootstrap/boot  ] && cp -a /etc/debootstrap/boot/*  $MNTPOINT/boot/
560   [ -d /etc/debootstrap/etc   ] && cp -a /etc/debootstrap/etc/*   $MNTPOINT/etc/
561   [ -d /etc/debootstrap/share ] && cp -a /etc/debootstrap/share/* $MNTPOINT/share/
562   [ -d /etc/debootstrap/usr   ] && cp -a /etc/debootstrap/usr/*   $MNTPOINT/usr/
563   [ -d /etc/debootstrap/var   ] && cp -a /etc/debootstrap/var/*   $MNTPOINT/var/
564
565   # copy local network setup to chroot
566   if [ -r /etc/network/interfaces -a ! -r "${MNTPOINT}"/etc/network/interfaces ] ; then
567      [ -d $MNTPOINT/etc/network ] || mkdir $MNTPOINT/etc/network
568      cp /etc/network/interfaces $MNTPOINT/etc/network/interfaces
569   fi
570
571   eend 0
572 }
573 # }}}
574
575 # execute chroot-script {{{
576 chrootscript() {
577   if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
578      mount_target
579   fi
580   if [ -x "$MNTPOINT/bin/chroot-script" ] ; then
581      einfo "Executing chroot-script now"
582      chroot "$MNTPOINT" /bin/chroot-script
583      eend $?
584   else
585      eerror "Fatal: $MNTPOINT/bin/chroot-script could not be found."
586      eend 1
587   fi
588 }
589 # }}}
590
591 # install booloader grub {{{
592 grub_install() {
593   if [ -z "$GRUB" -o -z "$GROOT" ] ; then
594      echo "Notice: \$GRUB or \$GROOT not defined, will not install grub therefor."
595   else
596      einfo "Installing grub on ${GRUB}:"
597      [ -x /usr/sbin/grub-install ] && GRUBINSTALL=/usr/sbin/grub-install || GRUBINSTALL=/sbin/grub-install
598      $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
599      eend $?
600   fi
601 }
602 # }}}
603
604 # unmount $MNTPOINRT {{{
605 umount_chroot() {
606   if [ -n "$ISODIR" ] ; then
607      if grep -q "$ISODIR" /proc/mounts ; then
608         einfo "Unmount $MNTPOINT/$ISODIR"
609         umount "$MNTPOINT/$ISODIR"
610         eend $?
611      fi
612   fi
613   if grep -q "$MNTPOINT" /proc/mounts ; then
614      if [ -n "$PARTITION" ] ; then
615         einfo "Unmount $MNTPOINT"
616         umount $MNTPOINT
617         eend $?
618      fi
619   fi
620 }
621 # }}}
622
623 # execute filesystem check {{{
624 fscktool() {
625   if [ "$FSCK" = 'yes' ] ; then
626      [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
627      einfo "Checking filesystem on $TARGET using $FSCKTOOL"
628      $FSCKTOOL $TARGET
629      eend $?
630   fi
631 }
632 # }}}
633
634 # now execute all the functions {{{
635 for i in mkfs tunefs mount_target debootstrap_system preparechroot \
636          chrootscript grub_install umount_chroot fscktool ; do
637     if stage "${i}" ; then
638        $i && stage "${i}" done || bailout 2 "i"
639     fi
640 done
641 # }}}
642
643 # stages {{{
644   echo done > $STAGES/grml-debootstrap
645 # }}}
646
647 # end dialog of autoinstallation {{{
648 if [ -n "$AUTOINSTALL" ] ; then
649    dialog --title "$PN" --msgbox \
650           "Finished execution of ${0}.
651 Enjoy your Debian system." 6 60
652 else
653    einfo "Finished execution of $PN - enjoy your Debian system." ; eend 0
654 fi
655 # }}}
656
657 ## END OF FILE #################################################################
658 # vim: ai tw=100 expandtab foldmethod=marker shiftwidth=3