From 366b68d3c7ab2611f97e2dde3ed18c376fe7db05 Mon Sep 17 00:00:00 2001 From: Delfino Curado Date: Tue, 19 Oct 2021 10:09:35 -0400 Subject: [PATCH] Add option --include-backup to wipedisk The option --include-backup offers the possibility to wipe the directory /opt/platform-backup by ignoring the "protected" partition GUID. Test Plan: PASS: Verify that wipedisk without parameters keep the directory /opt/platform-backup contents PASS: Verify that wipedisk with parameter --include-backup remove contents of /opt/platform-backup Story: 2009291 Task: 43719 Signed-off-by: Delfino Curado Change-Id: I1a7c0b284a4c229d6ea59433fd7db296745ead2f --- mtce/src/scripts/wipedisk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mtce/src/scripts/wipedisk b/mtce/src/scripts/wipedisk index 2dc9bc34..4caa3484 100755 --- a/mtce/src/scripts/wipedisk +++ b/mtce/src/scripts/wipedisk @@ -8,13 +8,14 @@ usage () { - echo "Usage: `basename $0` [-h|--force]" + echo "Usage: `basename $0` [-h|--force|--include-backup]" echo "Erases the master boot record on the hard drive." echo "WARNING: All data on this hard drive will be lost." echo "" echo "Options:" - echo " -h display this help" - echo " --force do not ask for confirmation" + echo " -h display this help" + echo " --force do not ask for confirmation" + echo " --include-backup also removes data from platform backup directory" exit 1 } @@ -40,7 +41,7 @@ unmount_fs() return $ret_code } -OPTS=`getopt -o h -l force -- "$@"` +OPTS=`getopt -o h -l force,include-backup -- "$@"` if [ $? != 0 ] then exit 1 @@ -52,6 +53,7 @@ while true ; do case "$1" in -h) usage; shift;; --force) FORCE=1; shift;; + --include-backup) INCLUDE_BACKUP=1; shift;; --) shift; break;; esac done @@ -141,7 +143,7 @@ do esac sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev) part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}') - if [ "$part_type_guid" == $BACKUP_PART_GUID ]; then + if [[ "$part_type_guid" == $BACKUP_PART_GUID && ! $INCLUDE_BACKUP ]]; then echo "Skipping wipe backup partition $part..." continue fi @@ -185,3 +187,4 @@ else sync echo "The disk(s) have been wiped." fi +