]> spindle.queued.net Git - xodist/commitdiff
installer: figure out where to install to..
authorAndres Salomon <dilinger@collabora.co.uk>
Tue, 2 Jun 2009 23:39:32 +0000 (19:39 -0400)
committerAndres Salomon <dilinger@collabora.co.uk>
Tue, 2 Jun 2009 23:39:32 +0000 (19:39 -0400)
Signed-off-by: Andres Salomon <dilinger@collabora.co.uk>
installer

index f9d6d916f459f8c200fa866007e34c33badf4796..0d2f2417b4cd591df73f7310920fc7c8e6b6e5b1 100755 (executable)
--- 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