我有一个家用NAS,希望可以让udev探测,如果连接到了家用wifi上,就自动挂载NAS上的几个分区,否则就不动。该如何写udev规则,望达人指点。
另,如果有其他方式可以做到这个,也请不吝赐教。
udev如何检测连接的SSID
- smartliu
- 帖子: 174
- 注册时间: 2006-08-04 11:10
- 系统: Arch, macOS, Windows
- 来自: Jinan, Shandong, China
- 联系:
udev如何检测连接的SSID
2007年10月成功用Ubuntu 10.04 Beta 4光盘引导起来我的DELL XPS M1330,开启了我在私人电脑上的Linux生涯。
2007年12月无法忍受Ubuntu的龟速,开始使用Gentoo。
2008年3月,显卡坏掉,人在国外上学而DELL只提供大陆境内保修服务,无奈在当地买了台MacBook,自此8年远离了Linux的世界。
2015年,用工资买了Lenovo ThinkPad X250,我又回来啦……哈哈哈!!!
http://liuf.net
2007年12月无法忍受Ubuntu的龟速,开始使用Gentoo。
2008年3月,显卡坏掉,人在国外上学而DELL只提供大陆境内保修服务,无奈在当地买了台MacBook,自此8年远离了Linux的世界。
2015年,用工资买了Lenovo ThinkPad X250,我又回来啦……哈哈哈!!!
http://liuf.net
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: udev如何检测连接的SSID
希望這一篇 能夠幫上忙
http://unix.stackexchange.com/questions ... ed-in-udev
Auto-run script when Wifi card is plugged in (udev)
如果是 systemd 請另外再貼文
還有問題 請提供 作業系統版本
http://unix.stackexchange.com/questions ... ed-in-udev
Auto-run script when Wifi card is plugged in (udev)
如果是 systemd 請另外再貼文
還有問題 請提供 作業系統版本
- smartliu
- 帖子: 174
- 注册时间: 2006-08-04 11:10
- 系统: Arch, macOS, Windows
- 来自: Jinan, Shandong, China
- 联系:
Re: udev如何检测连接的SSID
感谢回复,不过这篇文章里似乎是说当无线网卡插上时执行脚本,而没有连接到哪个SSID的内容。还有其他资源吗?poloshiao 写了:希望這一篇 能夠幫上忙
http://unix.stackexchange.com/questions ... ed-in-udev
Auto-run script when Wifi card is plugged in (udev)
如果是 systemd 請另外再貼文
還有問題 請提供 作業系統版本
我的系统是 Funtoo(OpenRC),没有用 systemd。
2007年10月成功用Ubuntu 10.04 Beta 4光盘引导起来我的DELL XPS M1330,开启了我在私人电脑上的Linux生涯。
2007年12月无法忍受Ubuntu的龟速,开始使用Gentoo。
2008年3月,显卡坏掉,人在国外上学而DELL只提供大陆境内保修服务,无奈在当地买了台MacBook,自此8年远离了Linux的世界。
2015年,用工资买了Lenovo ThinkPad X250,我又回来啦……哈哈哈!!!
http://liuf.net
2007年12月无法忍受Ubuntu的龟速,开始使用Gentoo。
2008年3月,显卡坏掉,人在国外上学而DELL只提供大陆境内保修服务,无奈在当地买了台MacBook,自此8年远离了Linux的世界。
2015年,用工资买了Lenovo ThinkPad X250,我又回来啦……哈哈哈!!!
http://liuf.net
- vickycq
- 帖子: 4507
- 注册时间: 2011-03-20 13:12
- 系统: Debian
- 来自: 山东省寿光县
- 联系:
Re: udev如何检测连接的SSID
看看这几篇 有没有帮助
https://wiki.ubuntu.com/OnNetworkConnectionRunScript
http://askubuntu.com/questions/258580/h ... connection
http://superuser.com/questions/32658/ru ... k-in-linux
http://unix.stackexchange.com/questions ... -connected
根据您使用的网络管理器不同,可采取不同的方案。
https://wiki.ubuntu.com/OnNetworkConnectionRunScript
http://askubuntu.com/questions/258580/h ... connection
http://superuser.com/questions/32658/ru ... k-in-linux
http://unix.stackexchange.com/questions ... -connected
根据您使用的网络管理器不同,可采取不同的方案。
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
欢迎所有 Debian GNU/Linux 用户
-
- 论坛版主
- 帖子: 18279
- 注册时间: 2009-08-04 16:33
Re: udev如何检测连接的SSID
試試而没有连接到哪个SSID的内容。还有其他资源吗?
https://wiki.ubuntu.com/OnNetworkConnectionRunScript
Advanced
If you want to do something only when connecting to a certain network you need your scripts to check if the network connection matches. To do this you could check the SSID (the Network Name that Identifies a Network). Here is an example of how this can be achieved :
if [ `iwlist eth0 scanning | grep YourNetworkSSID` ]
then
mount //192.168.0.2/directory /mountpoint -t cifs -o iocharset=utf8,gid=1000,uid=1000,credentials=/root/.smbcredentials,dmask=770,fmask=770
fi
On a wired LAN you could ping a specific Server as follows (look in /etc/hostname, /etc/hosts, /etc/dhcp3/dhcpd.conf for how to configure this) :
...
if [ `ping -c 1 server.local | grep "1 packets transmitted"` ]
...