summaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/install')
-rwxr-xr-xscripts/install/install-functions58
-rwxr-xr-xscripts/install/install-get-partition209
-rwxr-xr-xscripts/install/install-image2
-rwxr-xr-xscripts/install/install-postinst-new4
4 files changed, 136 insertions, 137 deletions
diff --git a/scripts/install/install-functions b/scripts/install/install-functions
index e319b84d..458d2e63 100755
--- a/scripts/install/install-functions
+++ b/scripts/install/install-functions
@@ -177,7 +177,7 @@ select_drive () {
drives=$(cat /proc/partitions | \
awk '{ if ($4!="name") { print $4 } }' | \
egrep "c[0-9]d[0-9]$|[hsv]d[a-z]$|nvme[0-9]n[0-9]|mmcblk[0-9]" | \
- egrep -v "^$")
+ egrep -v "^$" | sort)
#this needs more testing to decide if better than above
#drives=$(lsblk -dn -o name -I8)
@@ -370,3 +370,59 @@ EOF
return 1
}
+# Find 2 drives of the same size.
+get_size_raid ()
+{
+ x=0
+ declare -i x
+ for drive in "${driveName[@]}"
+ do
+ drivesize=${driveSize[$x]}
+ y=0
+ declare -i y
+ for size in ${driveSize[@]}
+ do
+ if [ $drivesize -eq $size ] && [ $drive != ${driveName[$y]} ]; then
+ raiddrives="${driveName[$y]} $drive"
+ fi
+ y+=1
+ done
+ x+=1
+ done
+ if [ -n "$raiddrives" ]; then
+ echo $raiddrives
+ fi
+}
+
+# Manually select 2 items for use in RAID-1
+get_manual_raid ()
+{
+ PS3="Select the first drive: "
+ IFS=$'\n' s_driveNameSize=($(sort <<<"${driveNameSize[*]}"))
+ unset IFS
+ select drive1 in "${s_driveNameSize[@]}"
+ do
+ break
+ done
+
+ driveNameSize=()
+ for drive in "${driveName[@]}"
+ do
+ if ! echo $drive1 | grep -q $drive; then
+ driveNameSize+=("$drive $(get_drive_size $drive) MB")
+ fi
+ done
+
+ PS3="Select the second drive: "
+ IFS=$'\n' s_driveNameSize=($(sort <<<"${driveNameSize[*]}"))
+ unset IFS
+ select drive2 in "${s_driveNameSize[@]}"
+ do
+ break
+ done
+
+ drive1=`echo $drive1 | awk '{ print $1 }'`
+ drive2=`echo $drive2 | awk '{ print $1 }'`
+
+ echo $drive1 $drive2
+}
diff --git a/scripts/install/install-get-partition b/scripts/install/install-get-partition
index 1a96ac81..32487379 100755
--- a/scripts/install/install-get-partition
+++ b/scripts/install/install-get-partition
@@ -49,7 +49,9 @@ warn_of_dire_consequences () {
done
}
-check_for_old_raid () {
+delete_old_raid () {
+ ldrive=$1
+
# First, trigger construction of previously configured RAID groups
echo -n "Looking for pre-existing RAID groups..."
raid_config=`mdadm --examine --scan`
@@ -66,132 +68,37 @@ check_for_old_raid () {
raid_drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' \
| grep "md" | egrep -v "^$")
if [ -z "$raid_drives" ]; then
- echo "Unable to configure any RAID groups."
return
fi
- numraids=`echo $raid_drives | wc -w`
- if [ $numraids -eq 1 ]; then
- echo "The following RAID group is now configured:"
- else
- echo "The following RAID groups are now configured:"
- fi
-
for drive in $raid_drives; do
- cat /proc/mdstat | grep --after-context 2 ^$drive | sed -e 's/^/\t/'
+ members=`ls /sys/block/$drive/slaves`
+ for member in $members; do
+ cdrive=`lsblk -dn -o pkname /dev/$member`
+ if [ "$ldrive" == "$cdrive" ]; then
+ mdadm --stop --scan
+ for member in $members; do
+ drive=${member:0:3}
+ part=${member:3:1}
+ echo "Re-setting partition ID for RAID group $raid_drive member /dev/${member}:"
+ if [ -d /sys/firmware/efi ]; then
+ sgdisk --part-type /dev/$drive $part 0x83
+ else
+ sfdisk --part-type /dev/$drive $part 0x83
+ fi
+ echo "Clearing RAID superblock from RAID group $raid_drive member /dev/${member}."
+ mdadm --zero-superblock /dev/$member
+ done
+ fi
+ done
done
-
- if [ $numraids -eq 1 ]; then
- echo -n "Would you like to use this one? (Yes/No) [Yes]:"
- else
- echo -n "Would you like to use one of these? (Yes/No) [Yes]:"
- fi
-
- response=$(get_response "Yes" "Yes No Y N")
- if [ "$response" == "no" ] || [ "$response" == "n" ]; then
- echo
- echo "Ok. Not using existing RAID groups."
- echo
-
- # pick the first RAID group to be broken
- raid_drive=$(echo $raid_drives | /usr/bin/awk '{ print $1 }')
-
- echo "Would you like to break RAID group $raid_drive so that its"
- echo "members can be re-used for a new installation, understanding"
- echo -n "that doing so will destroy all data on it? (Yes/No) [No]:"
- destroy_raid=$(get_response "No" "Yes No Y N")
- echo
-
- if [ "${destroy_raid:0:1}" = "y" ]; then
- echo "OK. Breaking the RAID group $raid_drive."
-
- members=`ls /sys/block/$raid_drive/slaves`
-
- echo "First, stopping all existing RAID groups:"
- mdadm --stop --scan
-
- for member in $members ; do
- drive=${member:0:3}
- part=${member:3:1}
- echo "Re-setting partition ID for RAID group $raid_drive member /dev/${member}:"
- sfdisk --change-id /dev/$drive $part 0x83
- echo "Clearing RAID superblock from RAID group $raid_drive member /dev/${member}."
- mdadm --zero-superblock /dev/$member
- done
- else
- echo "OK. Stopping, but not breaking, existing RAID groups:"
- mdadm --stop --scan
- fi
-
- echo
- return
- fi
-
- if [ $numraids -eq 1 ]; then
- INSTALL_DRIVE=$raid_drives
- else
- # take the first drive as the default
- INSTALL_DRIVE=$(echo $raid_drives | /usr/bin/awk '{ print $1 }')
- echo -n "Which one would you like to use? ($raid_drives) [$INSTALL_DRIVE]: "
- INSTALL_DRIVE=$(get_response "$INSTALL_DRIVE" "$drives")
- fi
-
- echo "Using RAID partition $INSTALL_DRIVE"
-
- raid_degraded=`cat /sys/block/$INSTALL_DRIVE/md/degraded`
- raid_sync_action=`cat /sys/block/$INSTALL_DRIVE/md/sync_action`
-
- if [ "$raid_degraded" = "1" ]; then
- echo
- if [ "$raid_sync_action" = "recover" ]; then
- echo "Error: This RAID set is degraded and is in the process of"
- echo "rebuilding. It is not safe to install onto it while the"
- echo "rebuild is in progress. Please wait for the rebuild to"
- echo "complete and then re-start the installation. You may"
- echo "monitor the progress of the RAID rebuild with the"
- echo "command:"
- echo
- echo " show raid $INSTALL_DRIVE"
- echo
- exit 1
- fi
- echo "Warning: This RAID set is degraded, but is not in the"
- echo "process of rebuilding. It is safe to perform the installation"
- echo "onto a degraded RAID set that is not in the process of"
- echo "rebuilding. You may stop the installation now and rebuild the"
- echo "RAID set, or continue installing onto it. If you continue"
- echo "installing, do not attempt to rebuild the RAID set until the"
- echo "installation has completed and you have rebooted the system."
- echo
- fi
-
- warn_of_dire_consequences
-
- ROOT_PARTITION=$INSTALL_DRIVE
- ROOT_PARTITION_TYPE=new
-
- # make sure we aren't working on a mounted part
- unmount "$INSTALL_DRIVE"
-
- # check for an old config on the partition
- mkdir -p /mnt/tmp
- output=$(mount -r /dev/"$ROOT_PARTITION" /mnt/tmp 2>&1)
- if [ $? != 0 ]; then
- echo "Cannot mount $ROOT_PARTITION to check for old config file"
- lecho "Cannot mount $ROOT_PARTITION"."\n"
- lecho "mount $ROOT_PARTITION /mnt/tmp\n"
- lecho "$output"
- else
- save_old_info "$ROOT_PARTITION"
- umount /mnt/tmp
- fi
-
- # create the filesystem on the part
- make_filesystem "$ROOT_PARTITION"
}
check_for_new_raid () {
# Identify physical drives
+ driveName=()
+ driveSize=()
+ driveNameSize=()
drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' \
| egrep -v "[0-9]$" | egrep -v "^$")
@@ -200,17 +107,63 @@ check_for_new_raid () {
if mount | grep iso9660 | grep -q $instdrv
then
drives=${drives//"$instdrv"/}
+ else
+ driveName+=("$instdrv")
+ driveSize+=($(get_drive_size $instdrv))
+ driveNameSize+=("$instdrv $(get_drive_size $instdrv) MB")
fi
done
numdrives=`echo $drives | wc -w`
- # Need at least two drives for RAID-1. We don't yet have the code
- # to handle selection of two from a set of 3 or more, so for now, we
- # only support two drives.
- #
- if [ $numdrives -ne 2 ]; then
+ # Need at least two drives for RAID-1. If there are more than two
+ # drives found we have the option to check for two drives of the same size
+ # or configure manually.
+
+ if [ $numdrives -lt 2 ]; then
return
+ elif [ $numdrives -gt 2 ]; then
+ echo "Found ${numdrives} drives."
+ echo -n "Would you like to configure RAID-1 mirroring? (Yes/No) [Yes]:"
+ response=$(get_response "Yes" "Yes No Y N")
+ if [ "$response" == "no" ] || [ "$response" == "n" ]; then
+ echo "Ok. Not configuring RAID-1."
+ return
+ else
+ echo -n "Would you like find and use 2 drives of the same size? (Yes/No) [Yes]:"
+ response=$(get_response "Yes" "Yes No Y N")
+ if [ "$response" == "yes" ] || [ "$response" == "y" ]; then
+ raiddrives=$(get_size_raid)
+ if [ -n "$raiddrives" ]; then
+ drives=$raiddrives
+ else
+ echo "No drives with the same size found."
+ echo -n "Would you like to manually select the drives? (Yes/No) [Yes]:"
+ response=$(get_response "Yes" "Yes No Y N")
+ if [ "$response" == "yes" ] || [ "$response" == "y" ]; then
+ raiddrives=$(get_manual_raid)
+ if [ -n "$raiddrives" ]; then
+ drives=$raiddrives
+ fi
+ else
+ echo "Ok. Not configuring RAID-1."
+ return
+ fi
+ fi
+ else
+ echo -n "Would you like to manually select the drives? (Yes/No) [Yes]:"
+ response=$(get_response "Yes" "Yes No Y N")
+ if [ "$response" == "yes" ] || [ "$response" == "y" ]; then
+ raiddrives=$(get_manual_raid)
+ if [ -n "$raiddrives" ]; then
+ drives=$raiddrives
+ fi
+ else
+ echo "Ok. Not configuring RAID-1."
+ return
+ fi
+ fi
+ fi
fi
drive1=`echo $drives | awk '{ print $1 }'`
@@ -606,6 +559,8 @@ save_old_info() {
delete_partitions () {
ldrive=$1
+ delete_old_raid $ldrive
+
# get the partitions on the drive
# in the first grep below we add the optional [p] in order to
# accomdate cciss drives
@@ -950,13 +905,6 @@ while true; do
progress_indicator stop
echo "OK"
- # try old raid
- check_for_old_raid
- if [ -n "$ROOT_PARTITION" ]; then
- # got partition. done.
- break
- fi
-
# try new raid
check_for_new_raid
if [ -n "$ROOT_PARTITION" ]; then
@@ -1005,4 +953,3 @@ fi
echo "$ROOT_PARTITION_TYPE $ROOT_PARTITION $INSTALL_DRIVE" >$OUTFILE
becho 'Done!'
exit 0
-
diff --git a/scripts/install/install-image b/scripts/install/install-image
index 5e040e5e..b4b9cfba 100755
--- a/scripts/install/install-image
+++ b/scripts/install/install-image
@@ -145,7 +145,7 @@ fetch_iso_by_url ()
fi
fi
if [ -f ${filename}.asc ]; then
- gpg --keyring /etc/apt/trusted.gpg --verify ${filename}.asc
+ gpg --verify ${filename}.asc ${filename} >/dev/null 2>&1
fi
if [ $? -ne 0 ]; then
echo "Signature check FAILED."
diff --git a/scripts/install/install-postinst-new b/scripts/install/install-postinst-new
index 3a20cac3..0078287f 100755
--- a/scripts/install/install-postinst-new
+++ b/scripts/install/install-postinst-new
@@ -124,10 +124,6 @@ install_grub () {
progress_indicator start
if [ -f "/tmp/efiparts.tmp" ]; then
- # Remove grub-pc packages
- dpkg -r grub-pc grub2 >&/dev/null
- # Install grub-efi packages
- dpkg -i /usr/share/vyos/packages/grub-efi*.deb >&/dev/null
mkdir -p $grub_root/boot/efi
readarray parts < /tmp/efiparts.tmp
part_length=${#parts[@]}