From a31aaf82f3664e5854c617752a5493011ede731f Mon Sep 17 00:00:00 2001 From: Nyr Date: Sun, 29 Jan 2017 19:03:49 +0100 Subject: [PATCH] Fix #255 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ubuntu no longer includes the rc.local file, so iptables weren’t applied after a system reboot. --- openvpn-install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index cb9e60b..e945d59 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -36,8 +36,6 @@ elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then OS=centos GROUPNAME=nobody RCLOCAL='/etc/rc.d/rc.local' - # Needed for CentOS 7 - chmod +x /etc/rc.d/rc.local else echo "Looks like you aren't running this installer on a Debian, Ubuntu or CentOS system" exit 5 @@ -311,6 +309,12 @@ crl-verify crl.pem" >> /etc/openvpn/server.conf fi # Avoid an unneeded reboot echo 1 > /proc/sys/net/ipv4/ip_forward + # Needed to use rc.local with some systemd distros + if [[ "$OS" = 'debian' && ! -e $RCLOCAL ]]; then + echo '#!/bin/sh -e +exit 0' > $RCLOCAL + fi + chmod +x $RCLOCAL # Set NAT for the VPN subnet iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to $IP sed -i "1 a\iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to $IP" $RCLOCAL