Browse Source

Update 'wiper.sh'

added yum for the installation of prerequisites and some sources I took code from
panda 2 years ago
parent
commit
591e0a7500
1 changed files with 33 additions and 8 deletions
  1. 33 8
      wiper.sh

+ 33 - 8
wiper.sh

@@ -1,9 +1,11 @@
 #!/usr/bin/env bash
 
 #variables:
-random_pass=7
+random_pass=3
 zeroing_pass=1
 prereq_list="pv smartmontools hdparm"
+YUM_CMD=$(which yum)
+APT_CMD=$(which apt-get)
 
 #check that a disk has been provided:
 if [ -z "$1" ]
@@ -19,15 +21,31 @@ if [ ! -e "/dev/$1" ]; then
 fi
 
 #prerequisites:
-for prereq in $prereq_list; do
-	REQUIRED_PKG="$prereq"
-	PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
-	#echo Checking for $REQUIRED_PKG: $PKG_OK
+
+if [[ ! -z $APT_CMD ]]; then
+  for prereq in $prereq_list; do
+	PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $prereq|grep "install ok installed")
+	#echo Checking for $prereq: $PKG_OK
 	if [ "" = "$PKG_OK" ]; then
-	  echo "INFO: $REQUIRED_PKG is not present. Setting up $REQUIRED_PKG."
-	  sudo apt-get --yes install $REQUIRED_PKG
+	  echo "INFO: $prereq is not present. Setting up $prereq."
+	  sudo apt-get --yes install $prereq
 	fi
-done
+  done
+elif [[ ! -z $YUM_CMD ]]; then
+  for prereq in $prereq_list; do
+	if ! rpm -qa | grep -qw $prereq; then
+		yum install $prereq
+	fi
+  done
+else
+	echo "ERROR: error can't find the correct installer for the prerequisites"
+	exit 1;
+fi
+
+echo "---"
+
+
+
 
 #collect data about disk type:
 disk_type=$(smartctl -a /dev/$1 | grep -i "Rotation Rate:" | cut -d':' -f2 | tr -d " ")
@@ -111,3 +129,10 @@ for z_pass in $(seq 1 $zeroing_pass); do
 done
 
 echo "!!! FINISHED wiping $1 !!!"
+
+
+
+#some of the sources used:
+#https://stackoverflow.com/questions/12806176/checking-for-installed-packages-and-if-not-found-install
+#https://stackoverflow.com/questions/19477682/bash-script-determine-vendor-and-install-system-apt-get-yum-etc
+#https://jschumacher.info/2016/03/erasing-with-openssl/