From: Andres Salomon Date: Tue, 2 Jun 2009 23:39:32 +0000 (-0400) Subject: installer: figure out where to install to.. X-Git-Tag: v0.6~47 X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?p=xodist;a=commitdiff_plain;h=f2f4abdb6892a1571af9cd01f26047fe808d06dd installer: figure out where to install to.. Signed-off-by: Andres Salomon --- diff --git a/installer b/installer index f9d6d91..0d2f241 100755 --- a/installer +++ b/installer @@ -14,20 +14,53 @@ case "$1" in ;; esac +# find the disk to install to +find_target() +{ + SRC=$1 + + for f in /sys/block/[sh]d[a-z]; do + bdev=$(basename $f) + if [ "$bdev" = "$SRC" ]; then + continue + fi + # the first block device that's not root? take it! + echo "$bdev" + break + done +} + do_install() { echo echo - echo "Triggering installer!" + echo + echo "Starting installer!" + if [ ! -d /root/etc ]; then + echo "Error: /root doesn't appear to have a valid filesystem mounted!" + exit 1 + fi + ROOT_SRC=$(grep ' /root ' /proc/mounts | cut -d' ' -f1) - ROOT_SRC=$(readlink -f $ROOT_SRC) + ROOT_SRC=$(readlink -f $ROOT_SRC | sed 's/.*\/\([hs]d[a-z]\)[0-9]\+$/\1/') - echo "root src: $ROOT_SRC" - [ -d /root/etc ] || { - echo "Error: /root doesn't appear to have a valid filesystem mounted!" + TARGET=$(find_target "$ROOT_SRC") + + if [ -z "$TARGET" ]; then + echo "Error: couldn't find drive to install to!" exit 1 - } + fi + + echo "Copying data from $ROOT_SRC => $TARGET" + echo "IF THIS IS INCORRECT, REBOOT NOW OR YOU WILL LOSE DATA! (waiting 15s)" + # wait 15s for user realize that they've made a mistake + sleep 15 + + echo "Too late, starting copy..." +sleep 20 + + echo "Done. Remove installer and reboot." } for x in $(cat /proc/cmdline); do