From 26a28a0123500ef8d2d121ade4bb6783d210df41 Mon Sep 17 00:00:00 2001 From: billz Date: Sat, 21 Mar 2020 23:37:05 +0000 Subject: [PATCH] Persist IP forwarding + iptables, update raspapd --- installers/common.sh | 9 +++++---- installers/raspap.service | 5 ++--- installers/servicestart.sh | 10 +--------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/installers/common.sh b/installers/common.sh index fa6e7b60..89aecd3f 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -8,7 +8,7 @@ raspap_dir="/etc/raspap" raspap_user="www-data" raspap_sudoers="/etc/sudoers.d/090_raspap" raspap_dnsmasq="/etc/dnsmasq.d/090_raspap.conf" -raspap_iptables="/etc/raspap.iptables.rules" +raspap_sysctl="/etc/sysctl.d/90_raspap.conf" webroot_dir="/var/www/html" git_source_url="https://github.com/$repo" # $repo from install.raspap.com @@ -291,14 +291,15 @@ function enable_raspap_daemon() { function configure_networking() { install_log "Configuring networking" echo "Enabling IP forwarding" - sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/' /etc/sysctl.conf || install_error "Unable to set IP forwarding" - sudo sysctl -p /etc/sysctl.conf || install_error "Unable to execute sysctl" + echo "net.ipv4.ip_forward=1" | sudo tee $raspap_sysctl || install_error "Unable to set IP forwarding" + sudo sysctl -p $raspap_sysctl || install_error "Unable to execute sysctl" + sudo /etc/init.d/procps restart || install_error "Unable to execute procps" echo "Creating IP tables rules" sudo iptables -t nat -A POSTROUTING -j MASQUERADE || install_error "Unable to execute iptables" sudo iptables -t nat -A POSTROUTING -s 192.168.50.0/24 ! -d 192.168.50.0/24 -j MASQUERADE || install_error "Unable to execute iptables" echo "Persisting IP tables rules" - sudo iptables-save | sudo tee $raspap_iptables + sudo iptables-save | sudo tee /etc/iptables/rules.v4 # Prompt to install RaspAP daemon echo -n "Enable RaspAP control service (Recommended)? [Y/n]: " diff --git a/installers/raspap.service b/installers/raspap.service index 13dcccc1..5c1e28f4 100644 --- a/installers/raspap.service +++ b/installers/raspap.service @@ -1,5 +1,5 @@ ### BEGIN INIT INFO -# Provides: /etc/raspap/hostapd/servicestart +# Provides: raspapd # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 @@ -11,8 +11,7 @@ [Unit] Description=RaspAP Service Daemon DefaultDependencies=no -After=systemd-sysctl.service -Before=sysinit.target +After=network.target [Service] Type=oneshot diff --git a/installers/servicestart.sh b/installers/servicestart.sh index ba87ba2c..5f6145e3 100755 --- a/installers/servicestart.sh +++ b/installers/servicestart.sh @@ -3,7 +3,7 @@ # up network services in a specific order and timing to avoid race conditions. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -NAME=raspap +NAME=raspapd DESC="Service control for RaspAP" CONFIGFILE="/etc/raspap/hostapd.ini" DAEMONPATH="/lib/systemd/system/raspap.service" @@ -36,7 +36,6 @@ set -- "${positional[@]}" echo "Stopping network services..." systemctl stop openvpn-client@client -systemctl stop systemd-networkd systemctl stop hostapd.service systemctl stop dnsmasq.service systemctl stop dhcpcd.service @@ -65,15 +64,8 @@ if [ -r "$CONFIGFILE" ]; then echo "Removing uap0 interface..." iw dev uap0 del - - echo "Enabling systemd-networkd" - systemctl start systemd-networkd - systemctl enable systemd-networkd fi else - echo "Disabling systemd-networkd" - systemctl disable systemd-networkd - echo "Removing br0 interface..." ip link set down br0 ip link del dev br0