I'm trying to set up a mesh network, and to do so, I'm configuring the network when the device is starting. This is the startup script of a service which is enabled to load during boot:
#!/bin/bash
/sbin/ifconfig wlan0 down &>> /var/log/meshnet
/sbin/ip link set down dev wlan0 &>> /var/log/meshnet
/sbin/iwconfig wlan0 mode ad-hoc &>> /var/log/meshnet
/sbin/iwconfig wlan0 channel 7 &>> /var/log/meshnet
/sbin/iwconfig wlan0 essid mesh2 &>> /var/log/meshnet
/sbin/ifconfig wlan0 up &>> /var/log/meshnet
/sbin/ip link set up dev wlan0 &>> /var/log/meshnet
/sbin/ip addr add 192.168.4.3/24 dev wlan0 &>> /var/log/meshnet
/sbin/ip route add default via 192.168.4.1 &>> /var/log/meshnet
However, I'm getting the following errors (in the log file):
Error for wireless request "Set Mode" (8B06) : SET failed on device wlan0 ; Operation not permitted.
Error for wireless request "Set ESSID" (8B1A) : SET failed on device wlan0 ; Operation not permitted.
When I run the script using sudo it works just fine.
Is there anything I can do to make this work?
Running on a chip (getchip.com)
chip@chip:~$ cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
usermod -a -G netdev your_username