切换到无线时无法安装 Samba 安装

切换到无线时无法安装 Samba 安装

我有一台装有 Scientific Linux 6.1 的笔记本。我有一个带有 OpenWrt 10.03 - Wrt160NL 的无线路由器。我的路由器上有一个 HDD,我通过 samba 共享:

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?是否有某种缓存存储共享只能通过以太网获得?我尝试卸载/安装共享,但没有成功。

答案1

我用 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

相关内容