summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Stevens <nilix@nilfm.cc>2019-12-30 12:21:44 -0500
committerDerek Stevens <nilix@nilfm.cc>2019-12-30 12:21:44 -0500
commit5ae3818ed833ffcbfe6b1d938679d36368bc154f (patch)
tree3ad95ce4ffb2ebae4f4ddc115d2a3b94b2c17a6d
0th commit
-rw-r--r--install25
-rw-r--r--shredder.sh58
-rw-r--r--shredmaster.sh3
3 files changed, 86 insertions, 0 deletions
diff --git a/install b/install
new file mode 100644
index 0000000..33a570d
--- /dev/null
+++ b/install
@@ -0,0 +1,25 @@
+#! /bin/sh
+
+dist="shredmaster.sh shredder.sh"
+
+if [ -z ${1} ]; then
+ echo "usage: ./install TARGET -- installs programs to ~/bin/TARGET/"
+ exit
+fi
+
+if [ ! -d ~/bin/ ]; then
+ mkdir ~/bin/
+ echo "creating ~/bin/"
+fi
+
+if [ ! -d ~/bin/${1}/ ]; then
+ mkdir ~/bin/${1}/
+ echo "creating ~/bin/${1}/"
+fi
+
+
+for i in ${dist}; do
+ cp ./${i} ~/bin/${1}
+ echo "copying ${i} to ~/bin/${1}/"
+ chmod +x ~/bin/${1}/${i}
+done
diff --git a/shredder.sh b/shredder.sh
new file mode 100644
index 0000000..d17bfda
--- /dev/null
+++ b/shredder.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+drives=$(ls /dev/sd[a-z] 2> /dev/null)
+
+safeDrives=""
+children=""
+activeChildren=""
+
+# safe drives are those which are not currently mounted
+
+for x in ${drives}; do
+ mounted=$(df -h | grep ${x} | awk '{print $1}')
+ if [ -z "${mounted}" ]; then
+ safeDrives="${safeDrives} ${x}"
+ n=$((n + 1))
+ fi
+done
+
+echo "Summary of currently mounted drives:"
+df -h
+echo ""
+echo "verify that the following drives are all OK to wipe:"
+echo "${safeDrives}"
+echo ""
+
+while [ "${isItSafe}" != "y" ]; do
+ echo "(y/n)"
+ read isItSafe
+ if [ "${isItSafe}" = "n" ]; then
+ exit
+ fi
+done
+
+echo "OK, shredding!"
+
+# fork each shred into the background and record its PID
+
+for drive in ${safeDrives}; do
+ shred -n 1 -z -v ${drive} & children="${children} $!"
+done
+
+# check if the shred PIDs have completed;
+# if so, everything is OK!
+
+while true; do
+ for child in ${children}; do
+ activeChildren="${activeChildren} $(ps T | grep $child | awk '{print $1}')"
+ done
+ if [ -z "${activeChildren}" ]; then
+ break
+ else
+ activeChildren=""
+ fi
+ sleep 5
+done
+
+echo "Everything is OK! Press Enter to finish."
+read weAreDone
diff --git a/shredmaster.sh b/shredmaster.sh
new file mode 100644
index 0000000..1c78e1d
--- /dev/null
+++ b/shredmaster.sh
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+urxvt -e su -c ~/bin/shredmaster/shredder.sh