0th commit

This commit is contained in:
Iris Lightshard 2019-12-30 12:21:44 -05:00
commit 5ae3818ed8
3 changed files with 86 additions and 0 deletions

25
install Normal file
View file

@ -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

58
shredder.sh Normal file
View file

@ -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

3
shredmaster.sh Normal file
View file

@ -0,0 +1,3 @@
#! /bin/sh
urxvt -e su -c ~/bin/shredmaster/shredder.sh