Hi all,
Great forum - thank you all for sharing your knowledge.
I have a startup issue using SystemD.
I have a shell script that starts HostAPD, NATing and DNSMASQ, when I start script manually it works fine but when I set it up to autostart during boot using [systemctl enable] it fails to start HostAPD, here are the files I am using:
--- the main script: /usr/lib/systemd/scripts/apstart ---
#!/bin/bash
# Enable NAT
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan0 -j ACCEPT
sleep 5
sysctl -w net.ipv4.ip_forward=1
sleep 5
ifconfig wlan0 down
hostapd -B /etc/hostapd/hostapd.conf
sleep 5
ifconfig wlan0 192.168.2.1 netmask 255.255.255.0
sleep 3
ifconfig wlan0 up
sleep 3
------------
--- Service file: /etc/systemd/system/apstart.service ---
[Unit]
Description=hostapd start
[Service]
ExecStart=/usr/lib/systemd/scripts/apstart 1>/dev/null
[Install]
WantedBy=multi-user.target
---------