-
Notifications
You must be signed in to change notification settings - Fork 0
/
wiper.sh
63 lines (53 loc) · 2.65 KB
/
wiper.sh
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
#!/usr/bin/env bash
# Keeping it portable.
# see: https://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html
echo "╔═══════════════════════════════════════════════════════════════════════╗"
echo "║ Linux Server Wiping Script ║"
echo "║ © 2020 Kevin Karhan - kevin.karhan@jtl-software.com ║"
echo "║ made for JTL Software - https://www.jtl-software.de/ ║"
echo "║ licensed under GPLv3 ║"
echo "╠═══════════════════════════════════════════════════════════════════════╣"
echo "║ USE ON YOUR OWN RISK! THE AUTHOR IS NOT LIABLE FOR ANY DAMAGES! ║"
echo "╟───────────────────────────────────────────────────────────────────────╢"
echo "║ PREPARE FOR FORESEEABLE CONSEQUENCES! ~ YOU HAVE BEEN WARNED! ║"
echo "╚═══════════════════════════════════════════════════════════════════════╝"
echo " "
echo "detecting devices..."
echo " "
lsblk -e7 -d -io NAME -n
# lists devices, excluding loopback devices partitions and header line.
# see: https://unix.stackexchange.com/questions/414305/lsblk-capture-only-the-disks
# output should only yield /dev/ devicenames like sda & nvme0n1
echo " "
echo "All the detected drives will be overwritten multiple times irreversibly."
echo " "
echo "Do you wish to wipe these?"
# Final explainer
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "THERE IS NO TURNING BACK NOW!"; break;;
No ) echo "ABORTED!"; exit;;
esac
done
# Yes/No security question
mapfile -t my_array < <(lsblk -e7 -d -io NAME -n)
for i in "${my_array[@]}"
do
shred -f -n 1 -v -z /dev/$i
echo "/dev/$i nuked!"
echo " "
done
# wipe each detected disk [physical block device] twice with shred & output progress
echo " "
echo "finished!"
echo "Do you wish to reboot the system?"
# reboot question
select yn in "Yes" "No"; do
case $yn in
Yes ) echo "rebooting"; break;;
No ) echo "done"; exit;;
esac
done
sudo reboot && exit
# Reboots it yes,
# Quits the script if no