#!/bin/ksh
# Make sure only root can run our script.
if [ "$(id -u)" != "0" ]; then
echo "This script. must be run as root" 1>&2
exit 1
fi
my_windows="135.251.27.66"
# /dev/null means no output in screen
# &2 means stderr
ping -c 1 -W 2 $my_windows >> /dev/null || { echo "fail, need CSL authentication" >&2; exit 1; }
#echo "have connected my windows ......"
#find mount files
mount_files=`echo "$(mount)"|awk '{print $3}'`
win_mnt=/mnt/huimingf/code
my_mnt=""
check_winmnt()
{
for my_mnt in ${mount_files[@]}
do
if [ "$my_mnt" == "$win_mnt" ]
then
return 0;
fi
done
return 1;
}
check_winmnt;
#function return $? just like the shell return
if [ $? == 0 ]
then
echo "$my_mnt have mount "
else
echo "mount the $win_mnt"
mount -t cifs -o username='AD4/huimingf' -o uid=25623,gid=1830, //135.251.27.66/code /mnt/huimingf/code
fi
exit 0