-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuninstall.sh
More file actions
74 lines (63 loc) · 2.74 KB
/
uninstall.sh
File metadata and controls
74 lines (63 loc) · 2.74 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
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
#!/bin/sh
ABSOLUTE_FILENAME=`readlink -f "$0"`
HOME_FOLDER=`dirname "$ABSOLUTE_FILENAME"` && HOME_FOLDER_SED=$(echo $HOME_FOLDER | sed 's/\//\\\//g')
LISTS=$HOME_FOLDER/lists
SCRIPTS=$HOME_FOLDER/scripts
SYSTEM_FOLDER=`echo $HOME_FOLDER | awk -F/opt '{print $1}'`
SYSTEM_FOLDER=$SYSTEM_FOLDER/opt && SYSTEM_FOLDER_SED=$(echo $SYSTEM_FOLDER | sed 's/\//\\\//g')
SCRIPTS=$HOME_FOLDER/scripts
while true; do
echo "Begin uninstall? y/n"
read yn
case $yn in
[Yy]* )
if [ $(echo $ABSOLUTE_FILENAME | grep -c Bird4Static) -eq 1 ]; then Bird4Static=1; else Bird4Static=0; fi
# Stop Services
$SYSTEM_FOLDER/etc/init.d/S03ipset-table stop
# Remove packages
# ipset
answer=0; echo "Do you want remove 'ipset'? 0 - no 1 - yes (default: no)"; read answer
if [ "$answer" = "1" ]; then $SYSTEM_FOLDER/bin/opkg remove ipset; fi
# iptables
answer=0; echo "Do you want remove 'iptables'? 0 - no 1 - yes (default: no)"; read answer
if [ "$answer" = "1" ]; then $SYSTEM_FOLDER/bin/opkg remove iptables; fi
# diff and patch
answer=0; echo "Do you want remove 'diffutils' and 'patch'? 0 - no 1 - yes (default: no)"; read answer
if [ "$answer" = "1" ]; then $SYSTEM_FOLDER/bin/opkg remove diffutils patch; fi
# Remove DNS Settings
if [ -f "$SYSTEM_FOLDER/etc/dnsmasq.conf" ]; then
if [ $(cat $SYSTEM_FOLDER/etc/dnsmasq.conf | grep "conf-file=$SYSTEM_FOLDER/etc/ipset4static_list.conf" -c ) -eq 1 ]; then
sed -i '/conf-file='$SYSTEM_FOLDER_SED'\/etc\/ipset4static_list.conf/d' $SYSTEM_FOLDER/etc/dnsmasq.conf
$SYSTEM_FOLDER/etc/init.d/S56dnsmasq restart
fi
fi
if [ -f "$SYSTEM_FOLDER/etc/AdGuardHome/AdGuardHome.yaml" ]; then
if [ $(cat $SYSTEM_FOLDER/etc/AdGuardHome/AdGuardHome.yaml | grep "ipset_file: $SYSTEM_FOLDER/etc/ipset4static_list.conf" -c ) -eq 1 ]; then
sed -i 's/ipset_file.*/ipset_file: ""/' $SYSTEM_FOLDER/etc/AdGuardHome/AdGuardHome.yaml
$SYSTEM_FOLDER/etc/init.d/S99adguardhome restart
fi
fi
# Remove start folders
rm -r $SCRIPTS
# Remove scripts into folders
rm -f $SYSTEM_FOLDER/etc/init.d/S03ipset-table
rm -f $SYSTEM_FOLDER/etc/ndm/ifstatechanged.d/012-ipset-isp-route.sh
rm -f $SYSTEM_FOLDER/etc/ndm/ifstatechanged.d/011-ipset-vpn1-route.sh
rm -f $SYSTEM_FOLDER/etc/ndm/ifstatechanged.d/010-ipset-vpn2-route.sh
rm -f $SYSTEM_FOLDER/etc/ndm/netfilter.d/012-ipset-isp-netfilter.sh
rm -f $SYSTEM_FOLDER/etc/ndm/netfilter.d/012-ipset-vpn1-netfilter.sh
rm -f $SYSTEM_FOLDER/etc/ndm/netfilter.d/010-ipset-vpn2-netfilter.sh
# Remove ipset conf
rm -f $SYSTEM_FOLDER/etc/ipset4static.conf
rm -f $SYSTEM_FOLDER/etc/ipset4static_list.conf
if [ "$Bird4Static" == "1" ]; then
cd $HOME_FOLDER && cd ..
rm -f lists/user-ipset*.list
rm -f scripts/update-ipset.sh
fi
exit 0
;;
[Nn]* ) exit 0;;
* ) echo "Please answer yes or no.";;
esac
done