its-ap-builder/files/tl-wr841-v10/etc/uci-defaults/50-config-from-mac

24 lines
504 B
Bash
Executable File

#!/bin/sh
set -e
mac=$(cat /sys/class/net/wlan0/address)
hostname=
channel=
if [ "$mac" = 60:e3:27:b8:16:ec ]; then
hostname=cz-ap0
channel=6
elif [ "$mac" = 60:e3:27:ed:86:9a ]; then
hostname=cz-ap1
channel=11
elif [ "$mac" = 60:e3:27:ed:9b:b0 ]; then
hostname=lz-ap0
channel=1
fi
uci set system.@system[0].hostname=$hostname
uci commit system
uci set wireless.radio0.channel=$channel
uci commit wireless
echo $(uci get system.@system[0].hostname) > /proc/sys/kernel/hostname