Skip to content

Commit

Permalink
Add detect-drive-name() function and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
sgtpep committed Dec 7, 2014
1 parent 3278e00 commit 6cb4fea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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|"
}

Expand All @@ -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."
Expand All @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion system.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6cb4fea

Please sign in to comment.