Return-path: <voyage-linux-bounces+punkytse=punknix.com@list.voyage.hk>
Envelope-to: punkytse@punknix.com
Delivery-date: Sun, 23 Sep 2012 01:41:17 +0800
Received: from localhost ([127.0.0.1] helo=punknix.punknix.com)
	by punknix.punknix.com with esmtp (Exim 4.72)
	(envelope-from <voyage-linux-bounces+punkytse=punknix.com@list.voyage.hk>)
	id 1TFThd-0007F1-Iv
	for punkytse@punknix.com; Sun, 23 Sep 2012 01:41:17 +0800
Received: from [212.70.193.242] (helo=orion.ozo.com)
	by punknix.punknix.com with esmtp (Exim 4.72)
	(envelope-from <jim.cromie@gmail.com>) id 1TFTMu-0003Pi-58
	for voyage-linux@voyage.hk; Sun, 23 Sep 2012 01:19:53 +0800
Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com
	[209.85.223.180])
	by orion.ozo.com (8.14.5/8.14.5) with ESMTP id q8MHJcYL010316
	for <voyage-linux@voyage.hk>; Sat, 22 Sep 2012 20:19:47 +0300
Received: by ieje10 with SMTP id e10so7148788iej.11
	for <voyage-linux@voyage.hk>; Sat, 22 Sep 2012 10:19:38 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
	h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;
	bh=jccszOl2HVKQEJk+rFJSYQ4wgTyBSErkTyXJ6FTLlto=;
	b=Ss0+gk6M4NhQeCWUeEPxGlRzekp447vJYj6tWCsmFphVAI9uT4I485OW6IsW4wKRCP
	JQGr/soNgXrQbUCPNPfroiDFtEfF1OEdoz6k5FLoWJuQCC5Z1lbdn1aCsX8MCTqFOu3F
	B7jV0vDa0UMYdEXI0UHb1LLhh+orx2N14F8FXv1xvSxxtlAgKIR9V/ekhHaD4KmfitiJ
	47KULXZ8g5O55Vd9xWwjLohBU2OamkJSIN19kADA5jJTjVFTAlZmkqXyWlYNrAINI1Jf
	ERr/TBESZ49A947LS07SECIQRLIjBH8qotpGtP3FeyTPwUWPnZMki3uGb4ekCrb2No81
	PSUQ==
Received: by 10.50.57.130 with SMTP id i2mr1461287igq.56.1348334378601;
	Sat, 22 Sep 2012 10:19:38 -0700 (PDT)
Received: from groucho.jimc.earth.net (c-75-70-77-50.hsd1.co.comcast.net.
	[75.70.77.50])
	by mx.google.com with ESMTPS id a1sm1799795igc.7.2012.09.22.10.19.37
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sat, 22 Sep 2012 10:19:37 -0700 (PDT)
From: Jim Cromie <jim.cromie@gmail.com>
To: voyage-linux@voyage.hk, voyage-linux@voyage.hk
Date: Sat, 22 Sep 2012 11:19:18 -0600
Message-Id: <1348334358-23093-5-git-send-email-jim.cromie@gmail.com>
X-Mailer: git-send-email 1.7.11.4
In-Reply-To: <1348334358-23093-1-git-send-email-jim.cromie@gmail.com>
References: <1348334358-23093-1-git-send-email-jim.cromie@gmail.com>
X-Scanned-By: MIMEDefang 2.73
Subject: [Voyage-linux] [PATCH 4/4] voyage-install: guess target disk from
	partition label
X-BeenThere: voyage-linux@list.voyage.hk
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Discussion about voyage linux <voyage-linux.list.voyage.hk>
List-Unsubscribe: <http://list.voyage.hk/mailman/options/voyage-linux>,
	<mailto:voyage-linux-request@list.voyage.hk?subject=unsubscribe>
List-Archive: <http://list.voyage.hk/pipermail/voyage-linux/>
List-Post: <mailto:voyage-linux@list.voyage.hk>
List-Help: <mailto:voyage-linux-request@list.voyage.hk?subject=help>
List-Subscribe: <http://list.voyage.hk/mailman/listinfo/voyage-linux>,
	<mailto:voyage-linux-request@list.voyage.hk?subject=subscribe>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: voyage-linux-bounces+punkytse=punknix.com@list.voyage.hk
Sender: "Voyage-linux"
	<voyage-linux-bounces+punkytse=punknix.com@list.voyage.hk>

Find VOYAGE_FS in mount output, and parse out values needed, ie:
TARGET_DISK, TARGET_PART.  Print the guess before prompting user to
accept or change the device.  New UI output is below, in context with
old output before and after.

Partitions information
major minor  #blocks  name

   8        0  976762584 sda
   8        1      48163 sda1
   8        2   10156032 sda2
   8        3  491423744 sda3
   8        4          1 sda4
   8        5     512000 sda5
   8        6  474618880 sda6
  11        0      64516 sr0
   8       16  976762584 sdb
   8       17      40131 sdb1
   8       18   15360000 sdb2
   8       19  348247765 sdb3
   8       20          1 sdb4
   8       21  589095486 sdb5
   8       22   24009111 sdb6
 252        0   52428800 dm-0
   8       32    3964464 sdc
   8       33    3964124 sdc1
 252        1   10289152 dm-1
 252        2  205062144 dm-2

guessing target: /dev/sdc1 on /run/media/jimc/VOYAGE_FS type ext2
ie:
	TARGET_DISK:	/dev/sdc
	TARGET_PART:	1
	MOUNT_POINT:	/run/media/jimc/VOYAGE_FS

Which device accesses the target disk [/dev/sdc]?

Which partition should I use on /dev/sdc for the Voyage system [1]?

Device information for /dev/sdc1
device        fs_type label    mount point       UUID
--------------------------------------------------------------------------------------
/dev/sdc1     ext2    VOYAGE_FS /run/media/jimc/VOYAGE_FS 61598f9f-ca5f-4a93-b8f5-44e9594e9263

Where can I mount the target disk [/mnt/cf]?

Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
 usr/local/sbin/voyage-install.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/usr/local/sbin/voyage-install.sh b/usr/local/sbin/voyage-install.sh
index 1837e40..74d245b 100755
--- a/usr/local/sbin/voyage-install.sh
+++ b/usr/local/sbin/voyage-install.sh
@@ -42,6 +42,22 @@ select_target_disk() {
 		echo
 	fi
 	
+	#print existing device with ROOT_LBL
+	guessdisk=`mount | grep $ROOT_LBL | cut -d\  -f1-5`
+	if [ -n "$guessdisk" ] ; then
+	    echo "guessing target: $guessdisk"
+	    MOUNTPT=`echo $guessdisk | cut -d\  -f3`
+	    guessdisk=`echo $guessdisk | cut -d\  -f1`
+	    guessdisk=`echo $guessdisk | sed -e 's/[0-9][0-9]*/ &/g'`
+	    TARGET_DISK=`echo $guessdisk | cut -d\  -f1`
+	    TARGET_PART=`echo $guessdisk | cut -d\  -f2`
+	    echo "ie:"
+	    printf "\tTARGET_DISK:\t$TARGET_DISK\n"
+	    printf "\tTARGET_PART:\t$TARGET_PART\n"
+	    printf "\tMOUNT_POINT:\t$MOUNTPT\n"
+	    echo ""
+	fi
+
 	while true
 	do
 		read_response "Which device accesses the target disk [$TARGET_DISK]? " a
-- 
1.7.11.4


_______________________________________________
Voyage-linux mailing list
Voyage-linux@list.voyage.hk
http://list.voyage.hk/mailman/listinfo/voyage-linux
