-
Notifications
You must be signed in to change notification settings - Fork 39
/
uninstall.sh
executable file
·90 lines (76 loc) · 2.48 KB
/
uninstall.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /bin/bash
#
# Subnodes uninstall script. Removes dnsmasq, hostapd, bridge-utils, batctl, iw. Does *not* yet remove Node.js. Deletes subnoes folder and files within.
# Sarah Grant
# Updated 18 July 2017
#
# TO-DO
# - Remove node.js
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# CHECK USER PRIVILEGES
(( `id -u` )) && echo "This script *must* be ran with root privileges, try prefixing with sudo. i.e sudo $0" && exit 1
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Uninstall Subnodes
#
read -p "Do you wish to uninstall subnodes from your Raspberry Pi? [N] " yn
case $yn in
[Yy]* )
clear
echo "Disabling the batman-adv kernel..."
# remove the batman-adv module to be started on boot
#sed -i '$a batman-adv' /etc/modules
modprobe -r batman-adv;
echo ""
echo -en "Disabling hostapd and dnsmasq on boot..."
update-rc.d hostapd disable
update-rc.d dnsmasq disable
# remove hostapd init file
echo -en "Deleting default hostapd and configuration files..."
rm /etc/default/hostapd
rm /etc/hostapd/hostapd.conf
echo -en "[OK]\n"
# remove dnsmasq
echo -en "Deleting dnsmasq configuration file..."
rm /etc/dnsmasq.conf
echo -en "[OK]\n"
echo ""
echo -en "Purging iw, batctl, bridge-utils, hostapd and dnsmasq..."
# how do i uninstall with apt-get
apt-get purge -y bridge-utils hostapd dnsmasq batctl iw
apt-get autoremove
echo -en "[OK]\n"
# restore the previous interfaces file
echo -en "Restoring previous network interfaces configuration file..."
rm /etc/network/interfaces
mv /etc/network/interfaces.bak /etc/network/interfaces
echo -en "[OK]\n"
# restore the previous /etc/dhcpcd.conf file
echo -en "Restoring previous dhcpcd configuration file..."
rm /etc/dhcpcd.conf
mv /etc/dhcpcd.conf.bak /etc/dhcpcd.conf
echo -en "[OK]\n"
# Remove startup scripts and delete
echo -en "Disabling and deleting startup subnodes startup scripts..."
update-rc.d -f subnodes_mesh remove
rm /etc/init.d/subnodes_mesh
update-rc.d -f subnodes_ap remove
rm /etc/init.d/subnodes_ap
# Remove subnodes config file
echo -en "Deleting /etc/subnodes.config..."
rm /etc/subnodes.config
echo "Deleting subnodes folder"
cd "$(dirname "$(pwd)")"
rm -rf subnodes
echo -en "[OK]\n"
read -p "Do you wish to reboot now? [N] " yn
case $yn in
[Yy]* )
reboot;;
[Nn]* ) exit 0;;
esac
;;
[Nn]* ) exit 0;;
esac
exit 0