1 Star 0 Fork 0

weaver2007/dotfiles

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
smb_mount.sh 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
smb_mount() {
if [ -f ~/.smbrc ]; then
. ~/.smbrc
fi
local smb_host=$1
local smb_host_uri=$smb_user:$smb_password@$smb_host
local smb_share=$2
local smb_mount_point=$3
local result exit_code
if [ -z $smb_host ] || [ -z $smb_share ]; then
cat <<-USAGE
smb_mount {host} {share_name} {mount_point}
Parameters
==========
Host: The hostname or ip address only.
Sharename: The name of the share on the remote host.
Mount point: Optional (will default to /Volumes/{Sharename})
Authentication
==============
This function will use smb_user and smb_password environment variables,
or it will pull those values from a ~/.smbrc file. syntax is:
smb_user={username}
smb_password={password}
NOTE: no spaces between the equal sign.
USAGE
return 1;
fi
if [ -z $smb_mount_point ]; then
smb_mount_point=/Volumes/$smb_share
fi
if ! mount | grep " $smb_mount_point " >/dev/null; then
mkdir -p $smb_mount_point
echo mount -t smbfs //${smb_host_uri}/$smb_share $smb_mount_point
result=$(mount -t smbfs //${smb_host_uri}/$smb_share $smb_mount_point 2>&1)
exit_code=$?
if [ $exit_code -ne 0 ]; then
re='server connection failed: Socket is not connected'
if [[ $result =~ $re ]]; then
echo "'mount -t smbfs' failed, falling back to mount_smbfs"
result=$(mount_smbfs -s //${smb_host_uri}/$smb_share $smb_mount_point 2>&1)
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "mount failed (exit_code: $exit_code): $result"
return 1
fi
fi
fi
else
echo "$smb_mount_point already mounted."
fi
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/weaver2007/dotfiles.git
git@gitee.com:weaver2007/dotfiles.git
weaver2007
dotfiles
dotfiles
master

搜索帮助