-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset
More file actions
36 lines (30 loc) · 1.17 KB
/
reset
File metadata and controls
36 lines (30 loc) · 1.17 KB
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
#!/usr/bin/sh
if [ $USER != "root" ]; then
echo "Please run as root"
exit 1
fi
localdir="/home/$SUDO_USER/usb-data"
usbdir=$(dirname "$(pwd)")
echo "Removing Local directories..."
if [ ! -z "$(find $localdir/Send/* 2> /dev/null)" ] || \
[ ! -z "$(find $localdir/Recv/* 2> /dev/null)" ]; then
echo "Files present in Local data directory..."
echo -n "Delete them? [Y/n] "; read r
if [ "$r" != "Y" ] && [ "$r" != "y" ]; then
echo "Empty the directory to reset"; exit 0; fi; fi
rm -rf "$localdir"
echo "Removing USB directories..."
if [ ! -z "$(find $usbdir/Data/1-to-2/* ! -path '*/todelete' 2> /dev/null)" ] || \
[ ! -z "$(find $usbdir/Data/2-to-1/* ! -path '*/todelete' 2> /dev/null)" ]; then
echo "Files present in USB directory..."
echo -n "Delete them? [Y/n] "; read r
if [ "$r" != "Y" ] && [ "$r" != "y" ]; then
echo "Empty the directory to reset"; exit 0; fi; fi
rm -rf "$usbdir/Data"
echo "Removing source files..."
rm -f "/etc/udev/rules.d/99-usb.rules"
rm -f "/etc/systemd/system/usb@.service"
rm -f "/usr/local/bin/usb.sh"
echo "Reset Done"
echo -n "Run setup? [Y/n] "; read r
if [ "$r" = "Y" ] || [ "$r" = "y" ]; then sh setup; fi