FINALLY SOLVED: Thanks to @tom
(added chmod and complete procedure for other users)
- First create a script:
vi /usr/bin/rb5-wifi-static-ip.sh
Content of rb5-wifi-static-ip.sh script (with sample IP):
#!/bin/bash
rb5_net='192.168'
drone_IP='192.168.178.201'
router_IP='192.168.178.1'
netmask_IP='255.255.255.0'
network_interface='wlan0'
# wait for wlan to get it's initial IP from router
rb5-net-check $network_interface $rb5_net
# set new IP
sudo ifconfig $network_interface $drone_IP netmask $netmask_IP
sudo route add default gw $router_IP $network_interface
- Give permission to script (if not, will give you message "Permission denied"):
chmod u+x /usr/bin/rb5-wifi-static-ip.sh
- Create a service:
vi /etc/systemd/system/rb5-wifi-static-ip.service
Content of rb5-wifi-static-ip.service file:
[Unit]
Description=WLAN0 Static IP Service
After=wlan_daemon.service
[Service]
ExecStart=/usr/bin/rb5-wifi-static-ip.sh
[Install]
WantedBy=multi-user.target
- Enable this service when RB5 boots:
systemctl enable rb5-wifi-static-ip.service
Restart RB5 and you will have a static IP!