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 if [ -z "$AVAILABLE_PARTITIONS" ] ; then
173 dialog --title "$PN" --trim \
174 --msgbox "Sorry, no partitions found. Please configure your
175 harddisks (see /proc/partitions) using a tool like fdisk,
176 cfdisk, gpart, gparted,..." 0 0
180 PARTITION_LIST=$(for i in $(echo $AVAILABLE_PARTITIONS) ; do
181 echo "$i $(vol_id --type $i 2>/dev/null || echo [no_filesystem_yet])"
184 TARGET=$(dialog --title "$PN" --single-quoted --stdout \
185 --menu "Please select the target partition:" 0 0 0 \
190 # ask for bootmanager {{{
191 prompt_for_bootmanager()
194 for device in sda hda; do
195 if [ /dev/$device != ${TARGET%[0-9]} ]; then
196 grep -q $device /proc/partitions && \
197 ADDITIONAL_PARAMS=:$device:"install bootmanager grub into MBR of /dev/${device}"
200 ADDITIONAL_PARAMS=${ADDITIONAL_PARAMS#:}
204 if echo $TARGET | grep -q "/dev/md" ; then
205 MBRPART="all disks of Software RAID $TARGET"
207 MBRPART="MBR of ${TARGET%[0-9]}"
210 GETMBR=$(dialog --stdout --title "$PN" --default-item mbr \
211 --menu "Where do you want to install the bootmanager grub?" 0 0 0 \
212 mbr "install bootmanager into $MBRPART" \
213 partition "install bootmanager into partition $TARGET" \
214 nowhere "do not install bootmanager at all" \
215 ${ADDITIONAL_PARAMS})
216 [ $? -eq 0 ] || bailout 3
221 # /dev/md0: has to be installed in MBR of /dev/md0 and not in /dev/md:
222 if echo $TARGET | grep -q "*md*" ; then
223 BOOT_PARTITION="${TARGET}"
225 BOOT_PARTITION="${TARGET%[0-9]}"
229 BOOT_PARTITION="$TARGET"
232 BOOT_PARTITION="/dev/hda"
235 BOOT_PARTITION="/dev/sda"
244 # ask for Debian release {{{
247 RELEASE="$(dialog --stdout --title "${PN}" --default-item etch --menu \
248 "Please enter the Debian release you would like to use for installation:" \
251 lenny Debian/testing \
252 sid Debian/unstable)"
256 # ask for hostname {{{
257 prompt_for_hostname()
259 HOSTNAME="$(dialog --stdout --title "${PN}" --inputbox \
260 "Please enter the hostname you would like to use for installation:" \
265 # ask for password {{{
266 prompt_for_password()
270 while [ "$ROOTPW1" != "$ROOTPW2" ]; do
271 ROOTPW1=$(dialog --insecure --stdout --title "${PN}" --passwordbox \
272 "Please enter the password for the root account:" 10 60)
273 ROOTPW2=$(dialog --insecure --stdout --title "${PN}" --passwordbox \
274 "Please enter the password for the root account again for \
275 confirmation:" 10 60)
277 if [ "$ROOTPW1" != "$ROOTPW2" ]; then
278 $(dialog --stdout --title "${PN}" --ok-label \
279 "Retry" --msgbox "Passwords do not match!" 10 60)
282 ROOTPASSWORD="$ROOTPW1"
286 # ask for Debian mirror {{{
289 MIRROR="$(dialog --stdout --title "${PN}" --inputbox \
290 "Please enter Debian mirror you would like to use for installing packages." \
291 0 0 http://ftp.de.debian.org/debian)"
295 # get grub's syntax for /dev/ice {{{
296 # usage example: 'grubdevice /dev/sda2' returns 'hd0,1'
298 if [ -z "$1" ] ; then
299 echo "Usage: grubdevice <device>">&2
304 device_map=/boot/grub/device.map
307 if ! [ -f "$device_map" ] ; then
308 echo 'quit' | grub --device-map="$device_map" 1>/dev/null 2>&1
311 # based on code from d-i's trunk/packages/arch/i386/grub-installer/grub-installer:
312 tmp_disk=`echo "$device" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' \
313 -e 's%\(fd[0-9]*\)$%\1%' \
314 -e 's%/part[0-9]*$%/disc%' \
315 -e 's%\(c[0-7]d[0-9]*\).*$%\1%'`
316 tmp_part=`echo "$device" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' \
317 -e 's%.*/fd[0-9]*$%%' \
318 -e 's%.*/floppy/[0-9]*$%%' \
319 -e 's%.*/\(disc\|part\([0-9]*\)\)$%\2%' \
320 -e 's%.*c[0-7]d[0-9]*p*%%'`
321 tmp_drive=$(grep -v '^#' $device_map | grep "$tmp_disk *$" | sed 's%.*\([hf]d[0-9][a-g0-9,]*\).*%\1%')
324 /dev/[sh]d[a-z]) # we expect something like 'hd0'
327 *) # we expect something like 'hd0,0'
328 echo "$tmp_drive" | sed "s%$%,`expr $tmp_part - 1`%" # FIXME => md0
334 # software raid setup {{{
335 config_swraid_setup()
339 # Currently we support only raid1:
342 #RAIDLEVEL=$(dialog --stdout --title "$PN" --default-item raid1 \
343 # --menu "Which RAID level do you want to use?" 0 0 0 \
344 # raid1 "Software RAID level 1" \
345 # raid5 "Software RAID level 5")
346 #[ $? -eq 0 ] || bailout 20
348 MD_LIST=$(for i in $(seq 0 9) ; do
349 awk '{print $4}' /proc/partitions | grep -q md$i || \
350 echo "/dev/md$i /dev/md$i"
353 TARGET=$(dialog --stdout --title "$PN" --default-item /dev/md0 \
354 --menu "Which device do you want to use for ${RAIDLEVEL}?
356 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 \
358 [ $? -eq 0 ] || bailout 20
360 AVAILABLE_PARTITIONS=$(LANG=C fdisk -l 2>/dev/null | \
362 grep -v 'Extended$' | \
363 gawk -v num=0 -v ORS=' ' '/^\/dev\// {print $1}')
364 [ -n "$AVAILABLE_PARTITIONS" ] || echo "FIXME: no partitions available?"
365 PARTITION_LIST=$(for i in $(echo $AVAILABLE_PARTITIONS) ; do
366 echo "$i $(vol_id --type $i 2>/dev/null || echo [no_filesystem_yet]) off"
369 dialog --title "$PN" --separate-output \
370 --checklist "Please select the partitions you would like to use for your $RAIDLEVEL on ${TARGET}:" 0 0 0 \
371 $PARTITION_LIST 2>$TMPFILE
373 SELECTED_PARTITIONS="$(cat $TMPFILE)"
376 for i in $(cat $TMPFILE) ; do
377 NUM_PARTITIONS=$((${NUM_PARTITIONS}+1))
382 # TODO: better error handling?
383 yes | mdadm --create "${TARGET}" --level="${RAIDLEVEL}" \
384 --raid-devices="${NUM_PARTITIONS}" ${SELECTED_PARTITIONS} 1>/dev/null 2>$ERRORFILE
388 if [ "$RC" = 0 ] ; then
389 dialog --title "$PN" --msgbox \
390 "Creating $TARGET was successful." 0 0
391 rm -f "$TMPFILE" "$ERRORFILE"
393 dialog --title "$PN" --msgbox \
394 "There was an error setting up $TARGET:
399 rm -f "$TMPFILE" "$ERRORFILE"
407 if dialog --stdout --title "$PN" \
408 --defaultno --yesno "Do you want to configure Software RAID?
410 Please notice that only RAID level 1 is supported by ${PN} currently. Configuration will take place using mdadm." 0 0 ; then
416 # make sure the user is aware of the used configuration {{{
419 if [ -n "$AUTOINSTALL" ] ; then
420 if checkforrun ; then
421 eerror "Exiting as requested" ; eend 0
424 elif [ -n "$INTERACTIVE" ] ; then
426 INFOTEXT="Please recheck configuration before execution:
428 [ -n "$TARGET" ] && INFOTEXT="$INFOTEXT
430 [ -n "$GRUB" ] && INFOTEXT="$INFOTEXT
432 [ -n "$RELEASE" ] && INFOTEXT="$INFOTEXT
433 Using release: $RELEASE"
434 [ -n "$HOSTNAME" ] && INFOTEXT="$INFOTEXT
435 Using hostname $HOSTNAME"
436 [ -n "$MIRROR" ] && INFOTEXT="$INFOTEXT
437 Using mirror: $MIRROR"
441 Is this ok for you? Notice: selecting 'No' will exit ${PN}."
443 dialog --title "$PN" --no-collapse \
444 --yesno "$INFOTEXT" 0 0
446 else # if not running automatic installation display configuration and prompt for execution:
447 einfo "$PN - Please recheck configuration before execution:"
449 echo " Target: $TARGET"
450 case "$MNTPOINT" in "$TARGET") ;; *) echo " Mount point: $MNTPOINT" ;; esac
451 [ -n "$GRUB" ] && echo " Install grub: $GRUB" || echo " Install grub: no"
452 [ -n "$RELEASE" ] && echo " Using release: $RELEASE"
453 [ -n "$MIRROR" ] && echo " Using mirror: $MIRROR"
454 [ -n "$ISO" ] && echo " Using iso: $ISO"
455 case "$MNTPOINT" in "$TARGET") ;; *) echo " Important! Continuing will delete all data from ${TARGET}!" ;; esac
457 einfon "Is this ok for you? [y/N] "
459 if ! [ "$a" = 'y' -o "$a" = 'Y' ] ; then
460 eerror "Exiting as requested." ; eend 1
467 # interactive mode {{{
474 # do not prompt for partition dialog if swraid has been configured already
475 [ -n "$TARGET" ] || prompt_for_target
477 prompt_for_bootmanager
485 # use first disk of sw-raid for grub by default, install grub on
486 # all involved disks later on
487 if echo "$TARGET" | grep -q '/dev/md' ; then
488 if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
489 # use hdX and not hdX,Y for $GRUB
490 TMPDEVICE=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}') # use first disk only
491 GRUB="$(grubdevice ${TMPDEVICE%%[0-9]})" # like: hd0
492 GROOT="$(grubdevice ${TMPDEVICE})" # like: hd0,0
493 echo "debug: GRUB = $GRUB - GROOT = $GROOT" >/tmp/debug # FIXME
496 [ -n "$BOOT_PARTITION" ] && GRUB="$(grubdevice $BOOT_PARTITION)"
497 [ -n "$TARGET" ] && GROOT="$(grubdevice $TARGET)"
505 # run interactive mode if we didn't get the according configuration yet
506 if [ -z "$TARGET" -o -n "$INTERACTIVE" ] ; then
507 # only target might be unset, so make sure the INTERACTIVE flag is set as well
513 # finally make sure at least $TARGET is set [the partition for the new system] {{{
514 if [ -n "$TARGET" ] ; then
515 SHORT_TARGET="${TARGET##*/}"
517 eerror "Please adjust /etc/debootstrap/config or..."
518 eerror "... use the interactive version for configuration before running ${0}" ; eend 1
524 if [ -z "$STAGES" ] ; then
525 STAGES="/var/cache/grml-debootstrap/stages_${SHORT_TARGET}"
526 [ -d "$STAGES" ] || mkdir -p "$STAGES"
529 if [ -r "$STAGES"/grml-debootstrap ] ; then
530 if grep -q done $STAGES/grml-debootstrap ; then
531 eerror "Error: grml-debootstrap has been executed already, won't continue therefore."
532 eerror "If you want to re-execute grml-debootstrap just manually remove ${STAGES}" ; eend 1
537 # partition handling {{{
546 # assume we are installing into a directory, don't run mkfs and grub related stuff therefore
558 # architecture setup {{{
559 if [ -n "$ARCH" ] ; then
560 ARCHCMD="--arch $ARCH"
561 ARCHINFO=" (${ARCH})"
563 ARCH="$(dpkg --print-architecture)"
564 ARCHCMD="--arch $ARCH"
565 ARCHINFO=" (${ARCH})"
569 # make sure we have the right syntax when using an iso image {{{
570 if [ -n "$ISO" ] ; then
583 # helper functions {{{
584 # we want to exit smoothly and clean:
586 # make sure $TARGET is not mounted when exiting grml-debootstrap
587 if [ -n "$MNTPOINT" ] ; then
588 if grep -q $MNTPOINT /proc/mounts ; then
589 # make sure nothing is left inside chroot so we can unmount it
590 [ -x "$MNTPOINT"/etc/init.d/ssh ] && "$MNTPOINT"/etc/init.d/ssh stop
591 [ -x "$MNTPOINT"/etc/init.d/mdadm ] && "$MNTPOINT"/etc/init.d/mdadm stop
592 # ugly, but make sure we really don't leav anything
593 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /sys 1>/dev/null 2>&1
594 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount -a 1>/dev/null 2>&1
595 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /proc 1>/dev/null 2>&1
596 [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount /proc 1>/dev/null 2>&1
597 [ -d "$MNTPOINT/$ISODIR" ] && umount "$MNTPOINT/$ISODIR" 1>/dev/null 2>&1
598 einfo "Unmounting $MNTPOINT" ; umount "$MNTPOINT" ; eend $?
600 if [ -n "$STAGES" ] ; then
601 echo -n "Removing stages directory ${STAGES}: "
602 rm -rf "$STAGES" && echo done
605 # remove directory only if we used the default with process id inside the name
606 if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
607 einfo "Removing directory ${MNTPOINT}" ; rmdir $MNTPOINT ; eend $?
612 [ -n "$1" ] && EXIT="$1" || EXIT="1"
613 [ -n "$3" ] && einfo "Notice: just remove $STAGES/$3 to reexecute the stage"
617 trap bailout HUP INT QUIT TERM
619 # we want to execute all the functions only once, simple check for it:
621 if [ -n "$2" ] ; then
622 echo "$2" > "${STAGES}/${1}"
624 elif grep -q done "${STAGES}/${1}" 2>/dev/null ; then
625 ewarn "Notice: stage $1 has been executed already, skipping execution therefore." ; eend 0
627 ewarn "To reexecute it clean up the according directory inside $STAGES" ; eend 0
634 # user should recheck his configuration {{{
635 # support full automatic installation:
637 dialog --timeout 10 --title "$PN" \
638 --yesno "Do you want to stop at this stage?
640 Notice: you are running ${PN} in non-interactive mode.
641 ${PN} will install Debian ${RELEASE} on ${TARGET}.
642 Last chance to quit. Timeout of 10 seconds running....
644 Do you want to stop now?" 0 0 2>/dev/null
647 # create filesystem {{{
649 if [ -n "$MKFS" ] ; then
650 einfo "Running $MKFS on $TARGET"
652 TARGET_UUID="$(vol_id -u $TARGET 2>/dev/null || echo '')"
658 # modify filesystem settings {{{
660 if [ -n "$TUNE2FS" ] ; then
661 einfo "Disabling automatic filesystem check on $TARGET via tune2fs"
668 # mount the new partition or if it's a directory do nothing at all {{{
670 if [ -n "$DIRECTORY" ] ; then
671 einfo "Running grml-debootstrap on a directory, nothing to mount."
673 if grep -q $TARGET /proc/mounts ; then
674 eerror "$TARGET already mounted, exiting."
676 [ -d "$MNTPOINT" ] || mkdir -p "$MNTPOINT"
677 einfo "Mounting $TARGET to $MNTPOINT"
678 mount -o rw,suid,dev $TARGET $MNTPOINT
682 if [ -n "$ISODIR" ] ; then
683 einfo "Mounting Debian image loopback to $MNTPOINT/$ISODIR."
684 mkdir -p "$MNTPOINT/$ISODIR"
685 mount --bind "$ISODIR" "$MNTPOINT/$ISODIR"
691 # install main chroot {{{
692 debootstrap_system() {
693 if ! grep -q $MNTPOINT /proc/mounts ; then
696 if grep -q $MNTPOINT /proc/mounts || [ -n "$DIRECTORY" ] ; then
697 einfo "Running $DEBOOTSTRAP $DEBOOTSTRAP_OPT for release ${RELEASE}${ARCHINFO} using ${MIRROR}${ISO}"
698 [ -n "$MIRROR" ] && $DEBOOTSTRAP $ARCHCMD $DEBOOTSTRAP_OPT $RELEASE $MNTPOINT $MIRROR || \
699 $DEBOOTSTRAP $ARCHCMD $DEBOOTSTRAP_OPT $RELEASE $MNTPOINT $ISO
702 eerror "Error: $MNTPOINT not mounted, can not continue."
708 # prepare chroot via chroot-script {{{
710 einfo "Preparing chroot system"
712 # provide variables to chroot system
713 CHROOT_VARIABLES="/var/cache/grml-debootstrap/variables_${SHORT_TARGET}"
714 touch $CHROOT_VARIABLES
715 chmod 600 $CHROOT_VARIABLES # make sure nobody except root can read it
716 echo "# Configuration of ${PN}" > $CHROOT_VARIABLES
717 [ -n "$ARCH" ] && echo "ARCH=$ARCH" >> $CHROOT_VARIABLES
718 [ -n "$GROOT" ] && echo "GROOT=$GROOT" >> $CHROOT_VARIABLES
719 [ -n "$GRUB" ] && echo "GRUB=$GRUB" >> $CHROOT_VARIABLES
720 [ -n "$HOSTNAME" ] && echo "HOSTNAME=$HOSTNAME" >> $CHROOT_VARIABLES
721 [ -n "$ISODIR" ] && echo "ISODIR=$ISO" >> $CHROOT_VARIABLES
722 [ -n "$ISO" ] && echo "ISO=$ISO" >> $CHROOT_VARIABLES
723 [ -n "$MIRROR" ] && echo "CHROOTMIRROR=$MIRROR" >> $CHROOT_VARIABLES
724 [ -n "$MIRROR" ] && echo "MIRROR=$MIRROR" >> $CHROOT_VARIABLES
725 [ -n "$KEEP_SRC_LIST" ] && echo "KEEP_SRC_LIST=$KEEP_SRC_LIST" >> $CHROOT_VARIABLES
726 [ -n "$ROOTPASSWORD" ] && echo "ROOTPASSWORD=$ROOTPASSWORD" >> $CHROOT_VARIABLES
727 [ -n "$TARGET" ] && echo "TARGET=$TARGET" >> $CHROOT_VARIABLES
728 [ -n "$TARGET_UUID" ] && echo "TARGET_UUID=$TARGET_UUID" >> $CHROOT_VARIABLES
730 cp $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script
731 chmod 755 $MNTPOINT/bin/chroot-script
732 mkdir $MNTPOINT/etc/debootstrap/
734 # make sure we have our files for later use via chroot-script
735 cp /etc/debootstrap/config $MNTPOINT/etc/debootstrap/
736 # make sure we adjust the configuration variables accordingly:
737 sed -i "s#RELEASE=.*#RELEASE=\"$RELEASE\"#" $MNTPOINT/etc/debootstrap/config
738 sed -i "s#TARGET=.*#TARGET=\"$TARGET\"#" $MNTPOINT/etc/debootstrap/config
739 sed -i "s#GRUB=.*#GRUB=\"$GRUB\"#" $MNTPOINT/etc/debootstrap/config
740 sed -i "s#GROOT=.*#GROOT=\"$GROOT\"#" $MNTPOINT/etc/debootstrap/config
742 cp /etc/debootstrap/packages $MNTPOINT/etc/debootstrap/packages
743 [ -f /etc/debootstrap/debconf-selections -a "$DEBCONF" = 'yes' ] && \
744 cp /etc/debootstrap/debconf-selections $MNTPOINT/etc/debootstrap/
746 # notice: do NOT use $CHROOT_VARIABLES inside chroot but statically file instead!
747 cp $CHROOT_VARIABLES $MNTPOINT/etc/debootstrap/variables
749 cp -a /etc/debootstrap/extrapackages/ $MNTPOINT/etc/debootstrap/
751 # make sure we can access network [relevant for cdebootstrap]
752 [ -f "$MNTPOINT/etc/resolv.conf" ] || cp /etc/resolv.conf $MNTPOINT/etc/resolv.conf
754 # provide system's /etc/hosts to the target:
755 if ! [ -f "$MNTPOINT/etc/hosts" ] ; then
756 cp /etc/hosts $MNTPOINT/etc/hosts
757 sed -i "s#127.0.0.1 .*#127.0.0.1 localhost $HOSTNAME#" /etc/hosts
760 # setup default locales
761 [ -n "$LOCALES" ] && cp /etc/debootstrap/locale.gen $MNTPOINT/etc/locale.gen
763 # MAKEDEV is just a forking bomb crap, let's do it on our own instead :)
764 ( cd $MNTPOINT/dev && tar zxf /etc/debootstrap/devices.tar.gz )
766 # copy any existing files to chroot
767 [ -d /etc/debootstrap/bin ] && cp -a -L /etc/debootstrap/bin/* $MNTPOINT/bin/
768 [ -d /etc/debootstrap/boot ] && cp -a -L /etc/debootstrap/boot/* $MNTPOINT/boot/
769 [ -d /etc/debootstrap/etc ] && cp -a -L /etc/debootstrap/etc/* $MNTPOINT/etc/
770 [ -d /etc/debootstrap/sbin ] && cp -a -L /etc/debootstrap/sbin/* $MNTPOINT/sbin/
771 [ -d /etc/debootstrap/share ] && cp -a -L /etc/debootstrap/share/* $MNTPOINT/share/
772 [ -d /etc/debootstrap/usr ] && cp -a -L /etc/debootstrap/usr/* $MNTPOINT/usr/
773 [ -d /etc/debootstrap/var ] && cp -a -L /etc/debootstrap/var/* $MNTPOINT/var/
775 # copy local network setup to chroot
776 if [ -r /etc/network/interfaces -a ! -r "${MNTPOINT}"/etc/network/interfaces ] ; then
777 [ -d $MNTPOINT/etc/network ] || mkdir $MNTPOINT/etc/network
778 cp /etc/network/interfaces $MNTPOINT/etc/network/interfaces
785 # execute chroot-script {{{
787 if ! [ -r "$MNTPOINT/bin/chroot-script" ] ; then
790 if [ -x "$MNTPOINT/bin/chroot-script" ] ; then
791 einfo "Executing chroot-script now"
792 chroot "$MNTPOINT" /bin/chroot-script
795 eerror "Fatal: $MNTPOINT/bin/chroot-script could not be found."
801 # install booloader grub {{{
803 if [ -z "$GRUB" -o -z "$GROOT" ] ; then
804 echo "Notice: \$GRUB or \$GROOT not defined, will not install grub therefor."
805 elif [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid
806 for device in $SELECTED_PARTITIONS ; do
807 # TMPDEVICE=$(echo ${SELECTED_PARTITIONS} | awk '{print $1}')
808 # GRUB="$(grubdevice ${TMPDEVICE})"
809 # GRUB="$(grubdevice ${TMPDEVICE%%[0-9]})"
810 # GRUB=$(grubdevice $device)
811 GRUB="$(grubdevice ${device%%[0-9]})"
812 einfo "Installing grub on ${GRUB}:"
813 [ -x /usr/sbin/grub-install ] && GRUBINSTALL="/usr/sbin/grub-install --no-floppy" || GRUBINSTALL="/sbin/grub-install --no-floppy"
814 $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
818 einfo "Installing grub on ${GRUB}:"
819 [ -x /usr/sbin/grub-install ] && GRUBINSTALL="/usr/sbin/grub-install --no-floppy" || GRUBINSTALL="/sbin/grub-install --no-floppy"
820 $GRUBINSTALL --root-directory="$MNTPOINT" "(${GRUB})"
826 # unmount $MNTPOINRT {{{
828 if [ -n "$ISODIR" ] ; then
829 if grep -q "$ISODIR" /proc/mounts ; then
830 einfo "Unmount $MNTPOINT/$ISODIR"
831 umount "$MNTPOINT/$ISODIR"
835 if grep -q "$MNTPOINT" /proc/mounts ; then
836 if [ -n "$PARTITION" ] ; then
837 einfo "Unmount $MNTPOINT"
845 # execute filesystem check {{{
847 if [ "$FSCK" = 'yes' ] ; then
848 [ -n "$FSCKTOOL" ] || FSCKTOOL="fsck.${MKFS#mkfs.}"
849 einfo "Checking filesystem on $TARGET using $FSCKTOOL"
856 # now execute all the functions {{{
857 for i in mkfs tunefs mount_target debootstrap_system preparechroot \
858 chrootscript grub_install umount_chroot fscktool ; do
859 if stage "${i}" ; then
860 $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "i"
866 einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" ; eend $?
867 einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $?
869 # Remove temporary mountpoint again
870 if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
871 einfo "Removing directory ${MNTPOINT}" ; rmdir "$MNTPOINT" ; eend $?
875 # end dialog of autoinstallation {{{
876 if [ -n "$AUTOINSTALL" ] ; then
877 dialog --title "$PN" --msgbox \
878 "Finished execution of ${PN}. Enjoy your Debian system." 0 0
880 einfo "Finished execution of ${PN}. Enjoy your Debian system." ; eend 0
884 ## END OF FILE #################################################################
885 # vim: ai tw=100 expandtab foldmethod=marker shiftwidth=3