Guest User

Untitled

a guest
Dec 19th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. ### Serkan Özdemir
  2. ### 30.07.2018
  3. ### Kullanım;
  4. ### <script> //<remoteipadress>/<sharedfoldername> <linuxmountfolder> <username> <password>
  5. ### sh ./mountwindir.sh //10.10.10.10/sharedfolder /mnt/test <username> <password>
  6. ### Eğer şifre girilmez ise soracaktır. If password not entered, asked next steps.
  7.  
  8. #!/bin/bash
  9. remote=$1
  10. local=$2
  11. username=$3
  12.  
  13. if [ -z "$4" ]; then
  14. echo "-- Login Password :"
  15. read -s password
  16. else
  17. password=$4
  18. fi
  19.  
  20. if [ ! -d "$local" ]; then
  21. sudo mkdir $local
  22. echo "-- Directory Created"
  23. sudo chmod 777 -R $local
  24. echo "-- Directory permissions enabled"
  25. else
  26. echo "-- Directory already exist"
  27. fi
  28.  
  29. mounted=0
  30. if [ $(mount | grep $local -c)>0 ]; then
  31. echo "-- this folder is already mounted"
  32. mounted=1
  33. else
  34. mount -t cifs $remote $local -o username=$username -o password=$password
  35. echo "-- successfully mounted $remote in $local"
  36. fi
  37.  
  38. mountnow="n"
  39. if [ $mounted = 1 ]; then
  40. read -p "-- if you umount directory and mount in connection (y n)" mountnow
  41. fi
  42.  
  43. if [ $mountnow = "y" ]; then
  44. umount $local
  45. echo "-- umounted directory"
  46. mount -t cifs $remote $local -o username=$username -o password=$password
  47. echo "-- successfully mounted $remote in $local"
  48. else
  49. echo "-- No Any Changes Mount Directory in $local"
  50. fi
Add Comment
Please, Sign In to add comment