尝试有条件地在脚本中启动 /usr/sbin/hostapd
trying to start /usr/sbin/hostapd in a script conditionally
这段代码 运行正在树莓派 pi3
上运行
我有一个脚本 /etc/rc2.d/S05frameapp 有条件地启动 hostapd(查看是否已设置 wifi)
在脚本中(如果没有为此设备设置 wifi,此部分将 运行)
echo "restarting etho"
/sbin/ifup wlan0
echo "Starting hostapd";
/usr/bin/nohup /usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf >> /tmp/hostapd.log 2>&1 &
echo "Starting dnsmasq ";
/usr/sbin/service dnsmasq start;
echo "Starting wifi_config node";
cd /home/wifi_listener/
/usr/bin/nohup /usr/local/bin/node app.js >> /tmp/nodeapp.log 2>&1 &
来自 nohup,在 /tmp/hostapd.log 中我看到
cat /tmp/hostapd.log
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
Could not set channel for kernel driver
Interface initialization failed
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED
wlan0: Unable to setup interface.
hostapd_free_hapd_data: Interface wlan0 wasn't started
但如果我现在登录(通过有线网络)并且 运行 以下内容有效...
#/usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:40:bd:a4 and ssid
"WhatUlooknAtWillis"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
所以我觉得这可能是时间问题?这就是为什么我现在有脚本 运行 S05
感谢您的帮助
我发现了问题。
这是启动hostapd和dnsmasq的顺序
修复方法是您需要先启动 dnsmasq,然后再启动 hostapd
echo "Starting dnsmasq ";
/usr/sbin/service dnsmasq start
echo "Starting hostapd";
/usr/bin/nohup /usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf >> /tmp/hostapd.log 2>&1 &
这段代码 运行正在树莓派 pi3
上运行我有一个脚本 /etc/rc2.d/S05frameapp 有条件地启动 hostapd(查看是否已设置 wifi)
在脚本中(如果没有为此设备设置 wifi,此部分将 运行)
echo "restarting etho"
/sbin/ifup wlan0
echo "Starting hostapd";
/usr/bin/nohup /usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf >> /tmp/hostapd.log 2>&1 &
echo "Starting dnsmasq ";
/usr/sbin/service dnsmasq start;
echo "Starting wifi_config node";
cd /home/wifi_listener/
/usr/bin/nohup /usr/local/bin/node app.js >> /tmp/nodeapp.log 2>&1 &
来自 nohup,在 /tmp/hostapd.log 中我看到
cat /tmp/hostapd.log
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
Could not set channel for kernel driver
Interface initialization failed
wlan0: interface state UNINITIALIZED->DISABLED
wlan0: AP-DISABLED
wlan0: Unable to setup interface.
hostapd_free_hapd_data: Interface wlan0 wasn't started
但如果我现在登录(通过有线网络)并且 运行 以下内容有效...
#/usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:40:bd:a4 and ssid
"WhatUlooknAtWillis"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
所以我觉得这可能是时间问题?这就是为什么我现在有脚本 运行 S05
感谢您的帮助
我发现了问题。 这是启动hostapd和dnsmasq的顺序
修复方法是您需要先启动 dnsmasq,然后再启动 hostapd
echo "Starting dnsmasq ";
/usr/sbin/service dnsmasq start
echo "Starting hostapd";
/usr/bin/nohup /usr/sbin/hostapd -B -P /var/run/hostapd.pid /etc/hostapd/hostapd.conf >> /tmp/hostapd.log 2>&1 &