Wifi
切換到無線時未安裝 Samba 安裝
我有一個裝有 Scientific Linux 6.1 的筆記本。我有一個帶有 OpenWrt 10.03 - Wrt160NL 的無線路由器。我在通過 samba 共享的路由器上有一個 HDD:
cat /etc/samba/smb.conf.template [global] workgroup = workgroup guest account = nobody security = share browseable = yes guest ok = yes guest only = no log level = 2 log file = /tmp/log/smbd.log max log size = 100 encrypt passwords = yes dns proxy = no host allow = 192.168.1.0/24 netbios name = Router server string = Linksys WRT160NL Router socket options = TCP_NODELAY client code page = 852 dos charset = 852 unix charset = UTF-8 display charset = UTF-8 character set = ISO8859-2 [SHARE] comment = SHARE path = /mnt/hdd/PUB browseable = yes public = yes guest ok = yes writable = no
在客戶端:
cat /etc/fstab //192.168.1.1/SHARE /home/USERNAME/Desktop/SHARE cifs ro,noexec,nosuid,nodev,noatime,password=,nolock 0 0
這很好用!
- 當有人通過乙太網電纜連接到路由器時,它可以看到路由器上的共享。
- 當有人通過無線連接到路由器時,它可以看到路由器上的共享。
當有人使用乙太網電纜,然後拔下它並切換到無線時,就會出現問題:共享消失,並且無法安裝它:
mount -vvv //192.168.1.1/SHARE /home/USERNAME/Desktop/SHARE -o ro,noexec,nosuid,nodev,noatime,password=,nolock -t cifs
因為命令超時。但是,如果我們重新插入乙太網電纜並進入 GNOME2 下的“SHARE”目錄,它會自動掛載。
切換到無線後如何安裝 SHARE?是否有某種記憶體儲存 SHARE 只能通過乙太網使用?我嘗試解除安裝/掛載 SHARE,但沒有成功。
我用 bash 腳本解決了它..(簡而言之,它使用 rmmod cifs/modprobe cifs - 之後我可以在沒有超時的情況下安裝共享..ü)
#!/bin/bash which timeout > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no coreutils package'; exit 1; fi which nc > /dev/null 2>&1; if [[ $? -ne 0 ]]; then echo -e '\nerror, no nc package'; exit 1; fi # variables PATHTOIT="//192.168.1.1/SHARE" # functions function notthesame() { # umount PATHTOIT while `mount | grep -qi $PATHTOIT`; do timeout -s 9 2 umount -l $PATHTOIT; done timeout -s 9 2 pkill -9 -f "SHARE" timeout -s 9 2 pkill -9 -f "umount -a -t cifs" timeout -s 9 2 pkill -9 -f "/sbin/mount.cifs" timeout -s 9 2 pkill -9 -f "rmmod -fw cifs" timeout -s 9 2 pkill -9 -f "/sbin/modprobe -q -- cifs" timeout -s 9 2 pkill nautilus # remove/add cifs kernel module timeout -s 9 2 rmmod -fw cifs timeout -s 9 2 modprobe cifs # mount PATHTOIT timeout -s 9 2 mount $PATHTOIT } while true; do # wait until we can reach the samba server while true; do nc -w 1 192.168.1.1 139 >& /dev/null && break && sleep 10; done # first sample REGIINTERF=`netstat -nr | awk '/0/ {print $NF}' | sort -u` # sleep 10 sleep 10 # second sample MILYENINTERFMOST=`netstat -nr | awk '/0/ {print $NF}' | sort -u` # compare the samples [ "${MILYENINTERFMOST}" = "${REGIINTERF}" ] || notthesame # if can't find mountpoint then mount it if ! mount | grep -qi $PATHTOIT; then notthesame; fi done