From 30b374054cdd994c3265143be0d6a4c0ec65c667 Mon Sep 17 00:00:00 2001 From: Orazio Date: Mon, 20 Jan 2020 21:51:36 +0100 Subject: [PATCH] Enable cloneandupdate() function, fixed detecting existing iptables rules. - Uncommented lines inside the cloneandupdate() function in the update script, so pivpn -up can pull scripts from the master branch - The script was checking for the existence of PiVPN rules in the INPUT and FORWARD chain by passing 'iptables -t nat -S' to grep, but it couldn't find them as they belong to the filer table and not the nat table. The correct command is 'iptables -S' --- auto_install/install.sh | 4 ++-- scripts/update.sh | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index 1e5f7d6..6639e0f 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -1746,7 +1746,7 @@ confNetwork(){ # chain (using -I). if [ "$INPUT_RULES_COUNT" -ne 0 ] || [ "$INPUT_POLICY" != "ACCEPT" ]; then - if $SUDO iptables -t nat -S | grep -q "${VPN}-input-rule"; then + if $SUDO iptables -S | grep -q "${VPN}-input-rule"; then INPUT_CHAIN_EDITED=0 else $SUDO iptables -I INPUT 1 -i "${IPv4dev}" -p "${pivpnPROTO}" --dport "${pivpnPORT}" -j ACCEPT -m comment --comment "${VPN}-input-rule" @@ -1757,7 +1757,7 @@ confNetwork(){ fi if [ "$FORWARD_RULES_COUNT" -ne 0 ] || [ "$FORWARD_POLICY" != "ACCEPT" ]; then - if $SUDO iptables -t nat -S | grep -q "${VPN}-forward-rule"; then + if $SUDO iptables -S | grep -q "${VPN}-forward-rule"; then FORWARD_CHAIN_EDITED=0 else $SUDO iptables -I FORWARD 1 -d "${pivpnNET}/${subnetClass}" -i "${IPv4dev}" -o "${pivpnDEV}" -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -m comment --comment "${VPN}-forward-rule" diff --git a/scripts/update.sh b/scripts/update.sh index 9481c4a..c11d8eb 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -50,16 +50,10 @@ updatefromtest(){ ##Clone and copy pivpn scripts to /opt/pivpn cloneandupdate(){ - ##This is to be removed after merge. - ##Alert for users trying to update from master. - echo "ERROR: You have installed pivpn from test branch." - echo "Wireguard not yet available on master, please use -t flag" - exit 1 - ## Remove Above and uncomment below when test is moved to master -# git clone "$pivpnrepo" "$pivpnlocalpath" -# cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts" -# cp "${pivpnlocalpath}"/scripts/$VPN/*.sh "$pivpnscripts" -# cp "${pivpnlocalpath}"/scripts/$VPN/bash-completion "$bashcompletiondir" + git clone "$pivpnrepo" "$pivpnlocalpath" + cp "${pivpnlocalpath}"/scripts/*.sh "$pivpnscripts" + cp "${pivpnlocalpath}"/scripts/$VPN/*.sh "$pivpnscripts" + cp "${pivpnlocalpath}"/scripts/$VPN/bash-completion "$bashcompletiondir" } ##same as cloneandupdate() but from test branch