Support reverting UFW changes on uninstall

This commit is contained in:
Kaladin Light 2016-05-15 16:57:42 -04:00
parent a432e187b9
commit 3916acf665
2 changed files with 13 additions and 2 deletions

View file

@ -760,8 +760,7 @@ confNetwork() {
$SUDO sed -i 's/IPv4dev/'$IPv4dev'/' /tmp/ufw_add.txt
$SUDO sed -i "s/\(DEFAULT_FORWARD_POLICY=\).*/\1\"ACCEPT\"/" /etc/default/ufw
$SUDO sed -i -e '/delete these required/r /tmp/ufw_add.txt' -e//N /etc/ufw/before.rules
$SUDO ufw disable
$SUDO ufw enable
$SUDO ufw reload
echo "::: UFW configuration completed."
fi
else
@ -769,13 +768,18 @@ confNetwork() {
fi
# else configure iptables
if [[ $noUFW -eq 1 ]]; then
echo 1 > /tmp/noUFW
$SUDO iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o $IPv4dev -j MASQUERADE
if [[ $PLAT == "Ubuntu" ]]; then
$SUDO iptables-save
else
$SUDO netfilter-persistent save
fi
else
echo 0 > /tmp/noUFW
fi
$SUDO cp /tmp/noUFW /etc/pivpn/NO_UFW
}
confOVPN() {

View file

@ -18,6 +18,7 @@ fi
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
NO_UFW=$(cat /etc/pivpn/NO_UFW)
# Find the rows and columns
rows=$(tput lines)
@ -99,6 +100,12 @@ echo ":::"
sed -i '/net.ipv4.ip_forward=1/c\#net.ipv4.ip_forward=1' /etc/sysctl.conf
sysctl -p
if [[ $NO_UFW -eq 0 ]]; then
$SUDO sed -i "s/\(DEFAULT_FORWARD_POLICY=\).*/\1\"DROP\"/" /etc/default/ufw
$SUDO sed -i '/START OPENVPN RULES/,/END OPENVPN RULES/ d' /etc/ufw/before.rules
$SUDO ufw reload
fi
echo ":::"
printf "::: Finished removing PiVPN from your system.\n"
printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L https://install.pivpn.io | bash\n:::\n::: at any time!\n:::\n"