all repos — shredmaster @ 5ae3818ed833ffcbfe6b1d938679d36368bc154f

script for wiping a bunch of drives at once

0th commit
Iris Lightshard nilix@nilfm.cc
commit

5ae3818ed833ffcbfe6b1d938679d36368bc154f

3 files changed, 86 insertions(+), 0 deletions(-)

jump to
A 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
A 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
A shredmaster.sh

@@ -0,0 +1,3 @@

+#! /bin/sh + +urxvt -e su -c ~/bin/shredmaster/shredder.sh