X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=grml-debootstrap;h=8d9cffb8a07fbed92ecbf5db8c9471e3a6429600;hp=30682a280b14e5e2fd0ebb5c5496a0ef5e11ece6;hb=586077721fa6533418c4fb7db9b78357fcbbb001;hpb=530fd2ad7c930c3cca810a2d351de30971cd5fc4 diff --git a/grml-debootstrap b/grml-debootstrap index 30682a2..8d9cffb 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -1,9 +1,9 @@ -#!/bin/sh -# Filename: grml-bootstrap -# Purpose: wrapper around debootstrap for installing plain Debian via grml +#!/bin/bash +# Filename: grml-debootstrap +# Purpose: wrapper around debootstrap for installing plain Debian via Grml # Authors: grml-team (grml.org), (c) Michael Prokop # Bug-Reports: see http://grml.org/bugs/ -# License: This file is licensed under the GPL v2. +# License: This file is licensed under the GPL v2+ ################################################################################ # http://www.debian.org/releases/stable/i386/index.html.en @@ -11,7 +11,8 @@ set -e # exit on any error # variables {{{ PN="$(basename $0)" -VERSION='0.37' +VERSION="$(dpkg --list $PN 2>/dev/null| awk '/^i/ {print $3}')" +VERSION="${VERSION:-unknown}" MNTPOINT="/mnt/debootstrap.$$" # inside the chroot system locales might not be available, so use minimum: @@ -81,7 +82,7 @@ Send bugreports to the grml-team: bugs (at) grml.org || http://grml.org/bugs/ " } -if [ "$1" = '-h' ] || [ "$1" = '-help' ] ; then +if [ "$1" = '-h' ] || [ "$1" = '-help' ] || [ "$1" = "--help" ] ; then usage echo 'Please notice that this script requires root permissions!' exit 0 @@ -90,7 +91,6 @@ fi # make sure we have what we need {{{ check4progs debootstrap dialog || exit 1 -check4root || exit 1 # }}} # source main configuration file {{{ @@ -165,6 +165,13 @@ fi } # }}} +# check for root permissions {{{ +if ! check4root ; then + echo "For usage instructions please execute '$PN --help'." + exit 1 +fi +# }}} + # source specified configuration file {{{ if [ -n "$CONFIGFILE" ] ; then einfo "Reading specified config file $CONFIGFILE." @@ -298,12 +305,13 @@ prompt_for_bootmanager() # ask for Debian release {{{ prompt_for_release() { - [ -n "$RELEASE" ] && DEFAULT_RELEASE="$RELEASE" || DEFAULT_RELEASE='lenny' + [ -n "$RELEASE" ] && DEFAULT_RELEASE="$RELEASE" || DEFAULT_RELEASE='squeeze' RELEASE="$(dialog --stdout --title "${PN}" --default-item $DEFAULT_RELEASE --menu \ "Please enter the Debian release you would like to use for installation:" \ - 0 50 3 \ - lenny Debian/stable \ - squeeze Debian/testing \ + 0 50 4 \ + lenny Debian/old-stable \ + squeeze Debian/stable \ + wheezy Debian/testing \ sid Debian/unstable)" } # }}} @@ -409,11 +417,17 @@ for i in $(cat $TMPFILE) ; do NUM_PARTITIONS=$((${NUM_PARTITIONS}+1)) done +# force metadata version 0.90 for lenny so old grub can boot from this array. +METADATA_VERSION="" +if [ $RELEASE = "lenny" ]; then + METADATA_VERSION="-e0" +fi + ERRORFILE=$(mktemp) set +e # TODO: better error handling? yes | mdadm --create "${TARGET}" --level="${RAIDLEVEL}" \ - --raid-devices="${NUM_PARTITIONS}" ${SELECTED_PARTITIONS} >/dev/null 2>$ERRORFILE + --raid-devices="${NUM_PARTITIONS}" ${METADATA_VERSION} ${SELECTED_PARTITIONS} >/dev/null 2>$ERRORFILE RC=$? set -e @@ -522,14 +536,14 @@ interactive_mode() { welcome_dialog + prompt_for_release + prompt_for_swraid prompt_for_target prompt_for_bootmanager - prompt_for_release - prompt_for_hostname prompt_for_password @@ -644,7 +658,7 @@ bailout(){ [ -x "$MNTPOINT"/etc/init.d/ssh ] && "$MNTPOINT"/etc/init.d/ssh stop [ -x "$MNTPOINT"/etc/init.d/mdadm ] && "$MNTPOINT"/etc/init.d/mdadm stop # ugly, but make sure we really don't leave anything (/proc /proc is intended) - for ARG in /sys -a /proc /proc ; do + for ARG in /sys /proc /proc ; do [ -x "$MNTPOINT"/bin/umount ] && chroot "$MNTPOINT" umount $ARG >/dev/null 2>&1 || true done umount "$MNTPOINT"/dev >/dev/null 2>&1 || true @@ -798,13 +812,14 @@ preparechroot() { [ -n "$INSTALL_NOTES" ] && echo "INSTALL_NOTES=$INSTALL_NOTES" >> $CHROOT_VARIABLES [ -n "$ISODIR" ] && echo "ISODIR=$ISO" >> $CHROOT_VARIABLES [ -n "$ISO" ] && echo "ISO=$ISO" >> $CHROOT_VARIABLES - [ -n "$MIRROR" ] && echo "MIRROR=$MIRROR" >> $CHROOT_VARIABLES [ -n "$KEEP_SRC_LIST" ] && echo "KEEP_SRC_LIST=$KEEP_SRC_LIST" >> $CHROOT_VARIABLES + [ -n "$MIRROR" ] && echo "MIRROR=$MIRROR" >> $CHROOT_VARIABLES [ -n "$PACKAGES" ] && echo "PACKAGES=$PACKAGES" >> $CHROOT_VARIABLES + [ -n "$RM_APTCACHE" ] && echo "RM_APTCACHE=$RM_APTCACHE" >> $CHROOT_VARIABLES [ -n "$ROOTPASSWORD" ] && echo "ROOTPASSWORD=$ROOTPASSWORD" >> $CHROOT_VARIABLES + [ -n "$SELECTED_PARTITIONS" ] && echo "SELECTED_PARTITIONS=$SELECTED_PARTITIONS" >> $CHROOT_VARIABLES [ -n "$TARGET" ] && echo "TARGET=$TARGET" >> $CHROOT_VARIABLES [ -n "$TARGET_UUID" ] && echo "TARGET_UUID=$TARGET_UUID" >> $CHROOT_VARIABLES - [ -n "$RM_APTCACHE" ] && echo "RM_APTCACHE=$RM_APTCACHE" >> $CHROOT_VARIABLES cp $VERBOSE $CONFFILES/chroot-script $MNTPOINT/bin/chroot-script chmod 755 $MNTPOINT/bin/chroot-script @@ -932,33 +947,6 @@ chrootscript() { } # }}} -# install booloader grub {{{ -grub_install() { - if [ -z "$GRUB" ] ; then - echo "Notice: \$GRUB not defined, will not install grub therefore." - return 0 - fi - - if ! [ -x "$(which grub-install)" ] ; then - echo "Error: grub-install not available. (Error while installing grub package?)" - return 1 - fi - - if [ -n "$SELECTED_PARTITIONS" ] ; then # using sw-raid - for device in $SELECTED_PARTITIONS ; do - GRUB="${device%%[0-9]}" - einfo "Installing grub on ${GRUB}:" - grub-install --no-floppy --root-directory="$MNTPOINT" "$GRUB" - eend $? - done - else - einfo "Installing grub on ${GRUB}:" - grub-install --no-floppy --root-directory="$MNTPOINT" "$GRUB" - eend $? - fi -} -# }}} - # unmount $MNTPOINT {{{ umount_chroot() { @@ -998,7 +986,7 @@ fscktool() { # now execute all the functions {{{ for i in mkfs tunefs mount_target debootstrap_system preparechroot \ - execute_pre_scripts chrootscript execute_scripts grub_install umount_chroot \ + execute_pre_scripts chrootscript execute_scripts umount_chroot \ fscktool ; do if stage "${i}" ; then $i && ( stage "${i}" done && rm -f "${STAGES}/${i}" ) || bailout 2 "i" @@ -1018,8 +1006,12 @@ fi # end dialog of autoinstallation {{{ if [ -n "$AUTOINSTALL" ] ; then - dialog --title "$PN" --msgbox \ - "Finished execution of ${PN}. Enjoy your Debian system." 0 0 + if dialog --title "${PN}" --pause "Finished execution of ${PN}. +Automatically rebooting in 10 seconds. + +Choose Cancel to skip rebooting." 10 60 10 ; then + noeject noprompt reboot + fi else einfo "Finished execution of ${PN}. Enjoy your Debian system." ; eend 0 fi