summarize
sudo mount -t cifs //windows_ip/windows_share /home/linux_path/linux_mount -o rw,username=xxx,password=xxx,....
sudo mount -t cifs //windows_ip/windows_share /home/linux_path/linux_mount -o rw,username=xxx,....
sudo mount -t cifs //windows_ip/windows_share /home/linux_path/linux_mount -o rw,credentials=/~PATH/xxxx.txt,....
xxxx.txt
#username=xxxxxxxx
#password=xxxxxxxx

 

#//-----------------------------------------------

#//== here !!=> set default parameter ==//
DOCHECK=1
DOCLOAK=1

#//---------------------------
#//== here !!=> provision
AUTO_DIR="${PWD}"
#echo "AUTO_DIR =====> ${AUTO_DIR}"

REF_FD=""

#//---------------------------
ARG_IPV4ADDR="//10.5.56.58"
ARG_WINSHARE="VSTS"
LINUX_MOUNTP="_VSTS_"

#//---------------------------
#set Path (R)elative (A)bsolute
#
if [[ "${REF_FD}" != "" ]];then
export LINUX_DIR="${AUTO_DIR}/${REF_FD}"
else
export LINUX_DIR="${AUTO_DIR}"
fi
echo "LINUX_DIR =====> ${LINUX_DIR}"
#-------------------------
ARG_SOURCE="${ARG_IPV4ADDR}/${ARG_WINSHARE}"
ARG_TARGET="${LINUX_DIR}/${LINUX_MOUNTP}"
echo "ARG_SOURCE =====> ${ARG_SOURCE}"
echo "ARG_TARGET =====> ${ARG_TARGET}"
#//---------------------------
#rm -f *.bak
#//-----------------------------------------------
#//== here !!=> start to do work ==//
#===================
#STEP 0
#===================
#-------------------------
cd ${LINUX_DIR}
if [[ ${DOCHECK} == 1 ]];then
if [[ -d ${LINUX_MOUNTP} ]];then
DOCHECK=0
else
mkdir ${LINUX_MOUNTP}
chmod 766 ${LINUX_MOUNTP}
fi
fi
#-------------------------
if [[ ${DOCLOAK} == 1 ]];then
#sudo apt-get install cifs-utils
ARG_PRIVATE="${LINUX_DIR}/private.txt"
#username=welkinchen
#password=xxxxxxxxxx
#rw
#uid=
#請留意:
#文件使用 unix mode。
#參數自己補上。
#不可以有空格且不能採用被加密的密碼。
#用戶名稱的格式可以是 username=<域名>/<主機名>
sudo mount -t cifs ${ARG_SOURCE} ${ARG_TARGET} -o credentials=${ARG_PRIVATE}
#//-----------------------------------------------
#/etc/fstab
#//ip/windows_share /home/linux_mount cifs defaults,credentials=/${PATH}/pwd.txt,iocharset=utf8 0 0
else
#-------------------------
#"65""13"
#COMMON_ARG="rw,iocharset=utf8,codepage=cp950"
COMMON_ARG="rw,iocharset=utf8"
#NORMAL_ARG="username=welkinchen,password=xxx,workgroup=taipei.via.com.tw"
NORMAL_ARG="username=welkinchen"
#EXTERN_ARG="uid=xxx"
EXTERN_ARG=""
sudo mount -t cifs ${ARG_SOURCE} ${ARG_TARGET} \
-o ${COMMON_ARG},${NORMAL_ARG},${EXTERN_ARG}
#//-----------------------------------------------
#/etc/fstab
#//ip/windows_share /home/linux_mount cifs defaults,credentials=/${PATH}/pwd.txt,iocharset=utf8 0 0
fi
#ls -la ${ARG_TARGET}
#-------------------------
#smb://ip/windows_share
#-------------------------

BB 發表在 痞客邦 PIXNET 留言(0) 人氣()