-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·38 lines (32 loc) · 1.15 KB
/
install
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
#!/bin/bash
# Run as root
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
# We'll need pv. Install it if needed.
if [ -z "$(which pv)" ]; then
echo "I need pv and it's missing. I'll install it."
apt-get -y update
apt-get -y install pv
fi
UNIT="RPiDiskWiper"
SOURCE="${BASH_SOURCE[0]}"
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
sed -e "s|__DIR__|$DIR|g" $DIR/$UNIT@.service > /etc/systemd/system/$UNIT@.service
systemctl daemon-reload
# Adjust the device name range you want to enable
for n in $(echo {a..z}); do
# Check to see if /dev/sd$n is currently connected to the system. If so, warn the user and don't enable that device's systemd unit
if [ -b "/dev/sd$n" ]; then
echo
echo "There is a device /dev/sd$n currently connected to this system. I will not enable wiping of /dev/sd$n in case it's needed."
echo "If you want to eable wiping of /dev/sd$n, then please unplug it from the system and run this install script again."
continue
fi
# Enable the unit template for each device
systemctl enable $UNIT@sd$n
done
echo
echo "All done! Plug a storage device to wipe it. You can monitor the log file like this:"
echo "tail -F /tmp/wipe.log"