blob: 78ba7186a54d84734b3e17209ef665e5f7de3dae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/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
if kill -0 ${child}; then
activeChildren="${activeChildren} ${child}"
fi
done
# if no active children, trim the whitespace so we can check for empty string
activeChildren=$(echo ${activeChildren} | xargs echo)
if [ -z "${activeChildren}" ]; then
break
else
activeChildren=""
fi
sleep 5
done
echo "Everything is OK! Press Enter to finish."
read weAreDone
|