Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Serkan Özdemir
- ### 30.07.2018
- ### Kullanım;
- ### <script> //<remoteipadress>/<sharedfoldername> <linuxmountfolder> <username> <password>
- ### sh ./mountwindir.sh //10.10.10.10/sharedfolder /mnt/test <username> <password>
- ### Eğer şifre girilmez ise soracaktır. If password not entered, asked next steps.
- #!/bin/bash
- remote=$1
- local=$2
- username=$3
- if [ -z "$4" ]; then
- echo "-- Login Password :"
- read -s password
- else
- password=$4
- fi
- if [ ! -d "$local" ]; then
- sudo mkdir $local
- echo "-- Directory Created"
- sudo chmod 777 -R $local
- echo "-- Directory permissions enabled"
- else
- echo "-- Directory already exist"
- fi
- mounted=0
- if [ $(mount | grep $local -c)>0 ]; then
- echo "-- this folder is already mounted"
- mounted=1
- else
- mount -t cifs $remote $local -o username=$username -o password=$password
- echo "-- successfully mounted $remote in $local"
- fi
- mountnow="n"
- if [ $mounted = 1 ]; then
- read -p "-- if you umount directory and mount in connection (y n)" mountnow
- fi
- if [ $mountnow = "y" ]; then
- umount $local
- echo "-- umounted directory"
- mount -t cifs $remote $local -o username=$username -o password=$password
- echo "-- successfully mounted $remote in $local"
- else
- echo "-- No Any Changes Mount Directory in $local"
- fi
Add Comment
Please, Sign In to add comment