diff --git a/roles/network/templates/hostapd/50-hostapd b/roles/network/templates/hostapd/50-hostapd new file mode 100644 index 000000000..b663599b3 --- /dev/null +++ b/roles/network/templates/hostapd/50-hostapd @@ -0,0 +1,12 @@ + +if [ "$interface" = "wlan0" ]; then + syslog info "50-hostapd-ap0" + sleep 2 + # wpa_supplicant wants MHz for frequency= while hostapd wants channel..... whatever + # FREQ=`iw wlan0 info|grep channel|cut -d' ' -f9` + FREQ=`iw wlan0 info|grep channel|cut -d' ' -f2` + sed -i -e "s/^frequency.*/channel=$FREQ /" /etc/hostapd/hostapd.conf + syslog info "50-hostapd restarting hostapd" + systemctl daemon-reload + systemctl restart hostapd +fi diff --git a/roles/network/templates/hostapd/70-persistent-net.rules b/roles/network/templates/hostapd/70-persistent-net.rules index 5e9cca3c3..7bb53337d 100644 --- a/roles/network/templates/hostapd/70-persistent-net.rules +++ b/roles/network/templates/hostapd/70-persistent-net.rules @@ -1,3 +1,3 @@ SUBSYSTEM=="ieee80211", ACTION=="add|change", KERNEL=="phy0", \ RUN+="/sbin/iw phy phy0 interface add ap0 type __ap", \ - RUN+="MAC=`iw dev wlan0 info | grep addr | sed -e s/addr//` && /bin/ip link set ap0 address $MAC" + RUN+="/sbin/ip link set ap0 address b8:27:99:12:34:56" diff --git a/roles/network/templates/hostapd/hostapd.service.j2 b/roles/network/templates/hostapd/hostapd.service.j2 index 8ccce4c7f..26195358e 100644 --- a/roles/network/templates/hostapd/hostapd.service.j2 +++ b/roles/network/templates/hostapd/hostapd.service.j2 @@ -6,7 +6,8 @@ Before=network.target dhcpcd.service [Service] Type=idle PIDFile=/run/hostapd.pid -ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap +ExecStartPre=/sbin/iw phy phy0 interface add ap0 type __ap 2>1 > /dev/null +ExecStartPre=/sbin/ip link set ap0 address b8:27:99:12:34:56 2>1 > /dev/null ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid /etc/hostapd/hostapd.conf [Install]