我有一个问题,我想启动一个脚本来启动"hostapd“,当我在我的E200ha上插入一个vga/hdmi适配器时。当我在逗号行中直接启动脚本时,脚本工作得很好,但是当被"udev“调用时,脚本就不能工作了。
这是udev捕获的路线:
ACTION=="change", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN="/home/user/hotspot.sh"这是脚本"hotspot.sh“
#!/bin/bash
exec > /var/log/hotplug-vga.log 2>&1;
service NetworkManager stop
killall wpasupplicant
hostapd -dd /etc/hostapd/hostapd.conf &这是"hostapd.conf“文件
interface=wlan0
ieee80211n=1
driver=nl80211
ssid=chingpro
hw_mode=g
channel=6
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0当我执行指令"/usr/sbin/hostapd /home/user/hostapd.sh“时,所有操作都很好:
wpasupplicant: aucun processus trouvé
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=0
nl80211: TDLS supported
nl80211: TDLS external setup
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
[...]
nl80211: assocresp_ies - hexdump(len=10): 7f 08 04 00 00 02 00 00 00 40
nl80211: Set wlan0 operstate 0->1 (UP)
netlink: Operstate: ifindex=18 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
wlan0: Setup of interface done.
ctrl_iface not configured!
[...]但是,当我连接我的vga/hdmi时,我可以看到我的脚本是在“/var/ log /hotplu-vga.log”中使用日志执行的,但是启动"hostapd“失败了:
wpasupplicant: no process found
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
ctrl_interface_group=0
nl80211: TDLS supported
nl80211: TDLS external setup
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported cipher 00-0f-ac:6
nl80211: Supported cipher 00-0f-ac:13
nl80211: Supported cipher 00-0f-ac:11
nl80211: Supported cipher 00-0f-ac:12
nl80211: Supports Probe Response offload in AP mode
nl80211: Using driver-based off-channel TX
nl80211: Driver-advertised extended capabilities (default) - hexdump(len=8): 04 00 00 00 00 00 00 40
nl80211: Driver-advertised extended capabilities mask (default) - hexdump(len=8): 04 00 00 00 00 00 00 40
nl80211: Use separate P2P group interface (driver advertised support)
nl80211: Enable multi-channel concurrent (driver advertised support)
nl80211: use P2P_DEVICE support
nl80211: interface wlan0 in phy phy15
nl80211: Set mode ifindex 18 iftype 3 (AP)
nl80211: Setup AP(wlan0) - device_ap_sme=0 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x557d15b300e0
nl80211: Register frame type=0xb0 (WLAN_FC_STYPE_AUTH) nl_handle=0x557d15b300e0 match=
nl80211: Register frame command failed (type=176): ret=-114 (Operation already in progress)
nl80211: Register frame match - hexdump(len=0): [NULL]
nl80211: Could not configure driver mode
nl80211: deinit ifname=wlan0 disabled_11b_rates=0
nl80211: Remove monitor interface: refcount=0
nl80211: Remove beacon (ifindex=18)
netlink: Operstate: ifindex=18 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)
nl80211 driver initialization failed.
hostapd_interface_deinit_free(0x557d15b294c0)
hostapd_interface_deinit_free: num_bss=1 conf->num_bss=1
hostapd_interface_deinit(0x557d15b294c0)
wlan0: interface state UNINITIALIZED->DISABLED
hostapd_bss_deinit: deinit bss wlan0
wlan0: AP-DISABLED
hostapd_cleanup(hapd=0x557d15b2a730 (wlan0))
hostapd_free_hapd_data: Interface wlan0 wasn't started
hostapd_interface_deinit_free: driver=(nil) drv_priv=(nil) -> hapd_deinit
hostapd_interface_free(0x557d15b294c0)
hostapd_interface_free: free hapd 0x557d15b2a730
hostapd_cleanup_iface(0x557d15b294c0)
hostapd_cleanup_iface_partial(0x557d15b294c0)
hostapd_cleanup_iface: free iface=0x557d15b294c0我花了很多时间来理解直接或由udev发送这个脚本的不同之处,但暂时没有成功。
我正在做一个新的"debian破坏程序“安装
我用相同的脚本安装Ubuntu18.04,我也有同样的问题:脚本在命令行中运行良好,但在udev启动时失败!
谢谢你的帮忙
发布于 2019-01-20 23:26:58
首先,您确定“服务NetworkManager停止”真的在运行吗?“手动运行但不是从cron/udev/initscript”中的许多问题都是由路径的差异引起的。有可能“服务”不在udev的路径上。
第二,这真的是你应该运行的命令吗?在https://bugs.launchpad.net/ubuntu/+source/wpa/+bug/1289047上,建议采用以下解决方案:
nmcli nm wifi off
rfkill unblock wlan或者在有悬念的情况下,也许最好把它写成
/usr/bin/nmcli nm wifi off
/usr/sbin/rfkill unblock wlan发布于 2020-08-15 08:52:13
我知道这是个老问题,但我也努力解决这个问题,找到了一个解决办法。
我不知道为什么hostapd在从udev调用时会有不同的行为,但是页面processes给出了一个解决方案,但考虑到了另一个问题。这样做的目的是处理udev之外的守护进程的hostapd执行,在本例中是atd。这个守护进程在包' at‘at debian中。安装后,您可以从udev脚本调用hostapd
echo "/usr/sbin/hostapd -B -P /path/to/pidfile /path/to/hostapd.config“
https://stackoverflow.com/questions/50906029
复制相似问题