Support uplink network management when two wlan devices are available
[infodrom/musiikki-web.git] / install-system
index 710319e..1696cd1 100755 (executable)
@@ -371,6 +371,28 @@ assert_hostapd()
     fi
 }
 
+assert_network()
+{
+    if ! grep -q '^source /etc/network/interfaces.d/wlan1.conf' /etc/network/interfaces
+    then
+       echo >> /etc/network/interfaces
+       echo 'source /etc/network/interfaces.d/wlan1.conf' >> /etc/network/interfaces
+       echo >> /etc/network/interfaces
+    fi
+
+    sed -i 's!#net.ipv4.ip_forward=1!net.ipv4.ip_forward=1!' /etc/sysctl.conf
+    if ! grep -q '^net.ipv4.ip_forward=1' /etc/sysctl.conf
+    then
+       echo >> /etc/sysctl.conf
+       echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
+    fi
+
+    # iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
+    # iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
+    # iptables -A FORWARD -i wlan1 -o wlan0 -j ACCEPT
+    # iptables-save > /srv/musiikki/iptables_nat.conf
+}
+
 assert_dhcpd()
 {
     assert_system_subnet
@@ -547,6 +569,7 @@ assert_packages || exit 2
 
 assert_musiikki
 assert_hostapd
+assert_network
 assert_dhcpd
 assert_super
 assert_minidlna