X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=grml-debootstrap;h=fb8562c470ef02da3135f965d74f56b64eb53b46;hp=dc4006d3e081aa7a4b1f5c29319764d99aa91843;hb=76ed29a773435264b5bb623b51c50d974a70e380;hpb=c62dadf69387a747f3bb5f4e02ca1f62a9114382 diff --git a/grml-debootstrap b/grml-debootstrap index dc4006d..fb8562c 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.38' +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." @@ -409,11 +416,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 +535,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 +657,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