Guest User

Untitled

a guest
Dec 22nd, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #!/bin/bash
  2. command -v mount.cifs >/dev/null 2>&1 || {
  3. echo "I require mount.cifs but it's not installed. You can install via apt:" >&2;
  4. echo " sudo apt-get install cifs-utils"
  5. echo ""
  6. echo "Press any key to abort."
  7. read
  8. exit 1;
  9. }
  10.  
  11. myPath=$HOME/tmp/$(uuidgen)
  12. mkdir -p $myPath
  13.  
  14. echo 'Defaults:'
  15. echo ' IP : 192.168.1.X (You must enter X)'
  16. echo ' windows username : fakeuser'
  17. echo ' windows password : fakepassword'
  18. echo ''
  19. read -p 'Use Default Value? [Yes]/no:' defaults
  20. if [ "$defaults" = "" ]
  21. then
  22. read -p 'IP : 192.168.1.' winIP
  23. winIP="192.168.1."$winIP
  24. read -p 'windows shared folder : ' winDir
  25. winUser=fakeuser
  26. winPass=fakepassword
  27. else
  28. read -p 'IP : ' winIP
  29. read -p 'windows shared folder : ' winDir
  30. read -p 'username : ' winUser
  31. if [ "$winUser" = "" ]
  32. then
  33. winUser=fakeuser
  34. fi
  35. read -sp 'password : ' winPass
  36. if [ "$winPass" = "" ]
  37. then
  38. winPass=fakepassword
  39. fi
  40.  
  41. fi
  42.  
  43. echo " "
  44.  
  45. sudo mount -t cifs "//"$winIP"/"$winDir $myPath -o dir_mode=0777,file_mode=0777,username=$winUser,password=$winPass
  46. xdg-open $myPath
  47. echo ""
  48. read -p "Done with sharing? Ready to unmount folder?"
  49. sudo umount "//"$winIP"/"$winDir
  50. rmdir $myPath
Add Comment
Please, Sign In to add comment