From c8eed87ebd092cfd4c155ca86702b5d02f05e553 Mon Sep 17 00:00:00 2001 From: Angristan Date: Thu, 18 Aug 2016 18:52:58 +0200 Subject: [PATCH] Fix UFW error --- openvpn-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 8fc5a0a..a3208ab 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -134,7 +134,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then read -p "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE if [[ "$REMOVE" = 'y' ]]; then PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2) - if ufw status | grep -qw active; then + if hash ufw 2>/dev/null && ufw status | grep -qw active; then ufw delete allow $PORT/udp sed -i '/^##OPENVPN_START/,/^##OPENVPN_END/d' /etc/ufw/before.rules sed -i '/^DEFAULT_FORWARD/{N;s/DEFAULT_FORWARD_POLICY="ACCEPT"\n#before openvpn: /DEFAULT_FORWARD_POLICY=/}' /etc/default/ufw @@ -401,7 +401,7 @@ tls-auth tls-auth.key 0" >> /etc/openvpn/server.conf firewall-cmd --zone=trusted --add-masquerade firewall-cmd --permanent --zone=trusted --add-masquerade fi - elif ufw status | grep -qw active; then + elif hash ufw 2>/dev/null && ufw status | grep -qw active; then ufw allow $PORT/udp if [[ "$FORWARD_TYPE" = '1' ]]; then sed -i '1s/^/##OPENVPN_START\n*nat\n:POSTROUTING ACCEPT [0:0]\n-A POSTROUTING -s 10.8.0.0\/24 -o eth0 -j MASQUERADE\nCOMMIT\n##OPENVPN_END\n\n/' /etc/ufw/before.rules