From 6cb4fea90fc9e97853fbf3ab54e76048d89b0b9f Mon Sep 17 00:00:00 2001 From: Danil Semelenov Date: Sun, 7 Dec 2014 03:44:34 +0300 Subject: [PATCH] Add detect-drive-name() function and use it --- common.sh | 8 ++++---- format.sh | 3 ++- system.sh | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common.sh b/common.sh index bf1dbea..2b0c54e 100644 --- a/common.sh +++ b/common.sh @@ -54,7 +54,7 @@ run-script() { bash -$- "$script_dir"/$script_name.sh $@ } -drive-name-parse() { +parse-drive-name() { grep "^Model: \|^Disk /" | sed "/^Model: .*/N;s|^Model: \(.*\) (.*)\nDisk \(/.*\): \(.*\)|\1 (\3) \2|" } @@ -70,7 +70,7 @@ select-drive() { fi local host_drive_path=`mounted-drive-path /` - local drive_names=(`sudo parted -ls | drive-name-parse | grep -v ") $host_drive_path$"`) + local drive_names=(`sudo parted -ls | parse-drive-name | grep -v ") $host_drive_path$"`) if [[ -z ${drive_names:-} ]]; then [[ ${1:-} != -q ]] || return 0 fatal-error "No drives were found." @@ -85,8 +85,8 @@ select-drive() { unset drive_name } -drive-name() { - sudo parted -s $drive_path print 2>/dev/null | drive-name-parse || : +detect-drive-name() { + drive_name=`sudo parted -s $drive_path print 2>/dev/null | parse-drive-name` } partition-path() { diff --git a/format.sh b/format.sh index 1d6c2e1..a7dae18 100755 --- a/format.sh +++ b/format.sh @@ -3,7 +3,8 @@ select-drive -read -p "Format drive \"`drive-name`\"? All data on it will be destroyed, including home partition! [y/N] " +detect-drive-name +read -p "Format drive \"$drive_name\"? All data on it will be destroyed, including home partition! [y/N] " [[ $REPLY =~ ^[Yy] ]] || exit run-script umount $drive_path diff --git a/system.sh b/system.sh index 3d86b5f..aa62466 100755 --- a/system.sh +++ b/system.sh @@ -8,7 +8,8 @@ target_arch=${2:-} run-script mount $drive_path if [[ `find $mnt_dir -maxdepth 1 -! -name lost+found -a -! -name boot -a -! -name home | sed 1d` ]]; then - read -p "Install system on \"`drive-name`\"? Existing system will be destroyed! [y/N] " + detect-drive-name + read -p "Install system on \"$drive_name\"? Existing system will be destroyed! [y/N] " [[ $REPLY =~ ^[Yy] ]] || exit mkdir -p /tmp/arch-drive/empty/boot