summaryrefslogtreecommitdiff
path: root/scripts/install
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/install')
-rwxr-xr-xscripts/install/install-functions24
-rwxr-xr-xscripts/install/install-get-partition22
-rwxr-xr-xscripts/install/install-image-existing14
-rwxr-xr-xscripts/install/install-postinst-new2
4 files changed, 48 insertions, 14 deletions
diff --git a/scripts/install/install-functions b/scripts/install/install-functions
index b3ec42c1..feeeb489 100755
--- a/scripts/install/install-functions
+++ b/scripts/install/install-functions
@@ -86,10 +86,10 @@ tolower () {
}
# Validates a user response. Returns the response if valid.
-# Returns the default is the user just hits enter.
+# Returns the default is the user just hits enter.
# Returns nothing if not valid. Default parameter is $1.
# Options are in $2. If options are defined return must be a member
-# of the enum.
+# of the enum.
get_response () {
local ldefault=$(tolower "$1")
local loptions=$(tolower "$2")
@@ -370,6 +370,26 @@ EOF
return 1
}
+# try to unmount. log any errors and return the appropriate status.
+# $1: arguments for umount
+try_unmount ()
+{
+ args="$*"
+ output=$(eval "umount $args 2>&1")
+ status=$?
+ if [ $status == 0 ]; then
+ return 0
+ fi
+ # error
+ cat <<EOF
+Error trying to unmount a partition/directory.
+Please see $INSTALL_LOG for details.
+EOF
+ lecho 'Error trying to unmount a partition/directory.'
+ lecho "umount $args\n$output"
+ return 1
+}
+
# Find 2 drives of the same size.
get_size_raid ()
{
diff --git a/scripts/install/install-get-partition b/scripts/install/install-get-partition
index 138088e6..bb8d8c11 100755
--- a/scripts/install/install-get-partition
+++ b/scripts/install/install-get-partition
@@ -100,8 +100,10 @@ check_for_new_raid () {
driveName=()
driveSize=()
driveNameSize=()
- drives=$(cat /proc/partitions | awk '{ if ($4!="name") { print $4 } }' \
- | egrep -v "[0-9]$" | egrep -v "^$")
+ 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 "^$" | sort)
for instdrv in $drives
do
@@ -235,9 +237,9 @@ check_for_new_raid () {
if [ -d /sys/firmware/efi ]; then
#EFI moves the data parition on RAID to 3
data_dev=3
- echo "Create data partition: /dev/${drive}${data_dev}"
+ echo "Create data partition: ${data_dev} on /dev/${drive}"
else
- echo "Creating data partition: /dev/${drive}${data_dev}"
+ echo "Creating data partition: ${data_dev} on /dev/${drive}"
sfdisk --part-type /dev/$drive $data_dev 0xfd >/dev/null 2>&1
# mark data partition as bootable
lecho "Marking /dev/$drive partition $data_dev bootable"
@@ -251,15 +253,19 @@ check_for_new_raid () {
echo
for drive in $drives; do
- echo "Erasing any previous RAID metadata that may exist on /dev/${drive}${data_dev}"
- mdadm --zero-superblock /dev/${drive}${data_dev}
+ # add "p" suffix for partitions on storages like eMMC, NVME
+ if [[ -n $(echo ${drive} | egrep "c[0-9]d[0-9]$|nvme[0-9]n[0-9]$|mmcblk[0-9]") ]]; then
+ partprefix="p"
+ fi
+ echo "Erasing any previous RAID metadata that may exist on /dev/${drive}${partprefix}${data_dev}"
+ mdadm --zero-superblock /dev/${drive}${partprefix}${data_dev}
done
- echo "Creating RAID-1 group on partitions: /dev/${drive1}${data_dev} /dev/${drive2}${data_dev}"
+ echo "Creating RAID-1 group on partitions: /dev/${drive1}${partprefix}${data_dev} /dev/${drive2}${partprefix}${data_dev}"
raid_dev=md0
yes|mdadm --create /dev/$raid_dev --level=1 --raid-disks=2 --metadata=0.90 \
- /dev/${drive1}${data_dev} /dev/${drive2}${data_dev}
+ /dev/${drive1}${partprefix}${data_dev} /dev/${drive2}${partprefix}${data_dev}
if [ $? = 0 -a -e /dev/$raid_dev ]; then
echo "RAID-1 group created successfully:"
diff --git a/scripts/install/install-image-existing b/scripts/install/install-image-existing
index d00d7735..7cf0b4db 100755
--- a/scripts/install/install-image-existing
+++ b/scripts/install/install-image-existing
@@ -189,9 +189,9 @@ if [ $space_avail -gt $space_needed_configdata ]; then
resp=$(get_response "Yes" "Yes No Y N")
if [ "$resp" == 'yes' ] || [ "$resp" == 'y' ]; then
echo 'Copying current configuration...'
- ndir=${INST_ROOT}/${VYATTA_NEW_CFG_DIR}
+ ndir=${INST_ROOT}/${VYATTA_CFG_DIR}
mkdir -p $ndir
- find $VYATTA_NEW_CFG_DIR -maxdepth 1 -mindepth 1 \
+ find $VYATTA_CFG_DIR -maxdepth 1 -mindepth 1 \
-exec cp '-a' '{}' "$ndir/" ';'
# Set the upgraded flag
@@ -201,7 +201,7 @@ if [ $space_avail -gt $space_needed_configdata ]; then
chmod -R 775 $ndir
# Return original permissions for private files in config/auth. T2713
- rsync -a ${VYATTA_NEW_CFG_DIR}/auth/ ${ndir}/auth/
+ rsync -a ${VYATTA_CFG_DIR}/auth/ ${ndir}/auth/
fi
done
@@ -278,6 +278,14 @@ if [ -e "$DEF_GRUB" ]; then
fi
fi
+# unmount filesystems
+if ! try_unmount "--read-only $INST_ROOT $READ_ROOT"; then
+ failure_exit 'Failed to unmount new squashfs image.'
+fi
+
+# sync underlaying filesystems
+sync
+
logger -p local3.warning -t "SystemImage" "System Image $NEWNAME has been added and made the default boot image"
echo 'Done.'
diff --git a/scripts/install/install-postinst-new b/scripts/install/install-postinst-new
index 8bb7c8bd..14148045 100755
--- a/scripts/install/install-postinst-new
+++ b/scripts/install/install-postinst-new
@@ -157,7 +157,7 @@ install_grub () {
else
if [[ $grub_inst_drv == "md raid" ]]; then
for slave in $raid_slaves; do
- grub_inst_drv=${slave:0:3}
+ grub_inst_drv=$(lsblk --noempty --dedup PKNAME --nodeps --noheadings --output PKNAME /dev/${slave})
output=$(grub-install --no-floppy --recheck --root-directory=$grub_root \
/dev/$grub_inst_drv 2>&1)
lecho "$output"