Fix UFW error

This commit is contained in:
Angristan 2016-08-18 18:52:58 +02:00 committed by GitHub
parent 41a38a1e32
commit c8eed87ebd

View File

@ -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