forked from ModBros/mobro-raspberrypi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.sh
69 lines (55 loc) · 1.97 KB
/
reset.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
64
65
66
67
68
69
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script requires root privileges"
exit 1
fi
if grep -q "boot=overlay" /proc/cmdline; then
echo "OverlayFS is still enabled!"
exit 1
fi
if findmnt /boot | grep -q " ro,"; then
echo "/boot still mounted read-only!"
exit 1
fi
# remove development files
rm -f /home/modbros/mobro-raspberrypi/dependencies.txt
# remove documentation from already installed packages
rm -rf /usr/share/man/* /usr/share/groff/* /usr/share/info/*
rm -rf /usr/share/lintian/* /usr/share/linda/* /var/cache/man/*
# stop service
service mobro stop
# remove log files
rm -f /var/log/{auth,boot,bootstrap,daemon,kern}.log
rm -f /var/log/{debug,dmesg,messages,syslog}
rm -f /mobro/log/*
# clean apt cache
apt-get clean
# reset configurations
cat /home/modbros/mobro-raspberrypi/config/config.txt >/boot/config.txt
cat /home/modbros/mobro-raspberrypi/config/cmdline.txt >/boot/cmdline.txt
cat /home/modbros/mobro-raspberrypi/config/99-fbturbo.conf >/usr/share/X11/xorg.conf.d/99-fbturbo.conf
cat /home/modbros/mobro-raspberrypi/config/wpa_supplicant_clean.conf >/etc/wpa_supplicant/wpa_supplicant.conf
cat /home/modbros/mobro-raspberrypi/config/mobro_config_default >/home/modbros/mobro-raspberrypi/config/mobro_config
: >/home/modbros/mobro-raspberrypi/config/mobro_configtxt
rm -rf /etc/X11/xorg.conf.d/*
rm -f /etc/network/interfaces.d/usb0
rm -f /etc/modprobe.d/g_ether.conf
rm -f /mobro/skip_service
rm -f /mobro/connected_host
rm -f /mobro/mobro_config
rm -f /mobro/mobro_configtxt
# overwrite free space of partitions
# sfill -f -z -l -l -v /
# sfill -f -z -l -l -v /boot
# sfill -f -z -l -l -v /mobro
# delete cache + bash history
rm -rf /home/modbros/.cache/*
: >/home/modbros/.bash_history
# enable overlayfs
sudo /home/modbros/mobro-raspberrypi/scripts/fsmount.sh --rw mobro
sudo /home/modbros/mobro-raspberrypi/scripts/fsmount.sh --ro root
# clean dhcp leases
sudo dhcpcd --release
sudo systemctl stop dhcpcd
sudo rm -rf /var/lib/dhcpcd5/*
sudo shutdown -h now