From c87dfdb0d881f8decbda89d3ae9600548dcd9141 Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Sun, 25 Sep 2022 10:43:15 -0500 Subject: [PATCH] Improve VPN setup - When uninstalling the VPN, remove the two TCP BBR related lines from /etc/sysctl.conf, if they were added during VPN setup. --- extras/vpnuninstall.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extras/vpnuninstall.sh b/extras/vpnuninstall.sh index ae3f75b..24a8aa3 100755 --- a/extras/vpnuninstall.sh +++ b/extras/vpnuninstall.sh @@ -184,10 +184,17 @@ update_sysctl() { if grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then bigecho "Updating sysctl settings..." conf_bk "/etc/sysctl.conf" + count=17 + line1=$(grep -A 18 "hwdsl2 VPN script" /etc/sysctl.conf | tail -n 1) + line2=$(grep -A 19 "hwdsl2 VPN script" /etc/sysctl.conf | tail -n 1) + if [ "$line1" = "net.core.default_qdisc = fq" ] \ + && [ "$line2" = "net.ipv4.tcp_congestion_control = bbr" ]; then + count=19 + fi if [ "$os_type" = "alpine" ]; then - sed -i '/# Added by hwdsl2 VPN script/,+17d' /etc/sysctl.conf + sed -i "/# Added by hwdsl2 VPN script/,+${count}d" /etc/sysctl.conf else - sed --follow-symlinks -i '/# Added by hwdsl2 VPN script/,+17d' /etc/sysctl.conf + sed --follow-symlinks -i "/# Added by hwdsl2 VPN script/,+${count}d" /etc/sysctl.conf fi if [ ! -f /usr/bin/wg-quick ] && [ ! -f /usr/sbin/openvpn ]; then echo 0 > /proc/sys/net/ipv4/ip_forward