Browse Source

added --override to wipe a broken disk

panda 2 years ago
parent
commit
787a2a8dde
1 changed files with 16 additions and 6 deletions
  1. 16 6
      wiper.sh

+ 16 - 6
wiper.sh

@@ -20,6 +20,12 @@ if [ ! -e "/dev/$1" ]; then
 	exit
 fi
 
+#check that a disk has been provided:
+if [ "$2" == "--override" ]
+then
+	override=1
+fi
+
 #prerequisites:
 
 if [[ ! -z $APT_CMD ]]; then
@@ -62,8 +68,12 @@ else
 	exit
 fi
 
-#check for disk errors, differntiating by device type since smart output is different between sata and sas drives:
-if smartctl -a /dev/$1 | grep -q "SATA"; then
+#
+if [[ "$override" -eq 1 ]]; then
+	echo "INFO: continuing to wipe since override has been issued"
+else
+  #check for disk errors, differentiating by device type since smart output is different between sata and sas drives:
+  if smartctl -a /dev/$1 | grep -q "SATA"; then
 	#echo "Type of disk: SATA"
 	if smartctl -a /dev/$1 | grep -q "No Errors Logged"; then
 		echo "INFO: This is a SATA disk, detecting no errors, going on:"
@@ -79,7 +89,7 @@ if smartctl -a /dev/$1 | grep -q "SATA"; then
 		echo "Serial: $sata_serial"
 		exit
 	fi
-elif smartctl -a /dev/$1 | grep -q "SAS"; then
+  elif smartctl -a /dev/$1 | grep -q "SAS"; then
 	#echo "Type of disk: SAS"
 	sas_errors=$(smartctl -a /dev/$1 | grep "Elements in grown defect list" | cut -d':' -f2 | tr -d " ")
 	if [ "$sas_errors" -gt 0 ]; then
@@ -98,12 +108,12 @@ elif smartctl -a /dev/$1 | grep -q "SAS"; then
 	else
 		echo "INFO: This is a SAS disk, detecting no errors, going on:"
 	fi
-else
+  else
 	echo "ERROR: the disk type is none of the expected ones, exiting"
 	exit
+  fi
 fi
 
-
 #warning if is an ssd
 if [ "$disk_ssd" -eq 1 ]; then
 	echo "WARNING: DISK IS AN SSD, Remember that sectors are reallocated thus unwanted data might remain on the flash."
@@ -137,4 +147,4 @@ echo "!!! FINISHED wiping $1 !!!"
 #https://stackoverflow.com/questions/19477682/bash-script-determine-vendor-and-install-system-apt-get-yum-etc
 #https://jschumacher.info/2016/03/erasing-with-openssl/
 #https://wiki.archlinux.org/title/Securely_wipe_disk/Tips_and_tricks#dd_-_advanced_example
-#https://serverfault.com/questions/6440/is-there-an-alternative-to-dev-urandom
+#https://serverfault.com/questions/6440/is-there-an-alternative-to-dev-urandom