Guest User

Untitled

a guest
Dec 21st, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/bin/bash
  2. sudo 'mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER'
  3.  
  4. #!/bin/bash
  5. echo -n Password:
  6. read -s szPassword
  7. echo $szPassword | sudo -S sh -c 'echo $szPassword | mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER'
  8.  
  9. if [[ $EUID -ne 0 ]]; then
  10. echo "This script must be run as root, use sudo "$0" instead" 1>&2
  11. exit 1
  12. fi
  13.  
  14. #!/bin/bash
  15. read -p "Password: " -s szPassword
  16. printf "%sn" "$szPassword" | sudo --stdin mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER,password="$szPassword"
  17.  
  18. ALL ALL = NOPASSWD: /bin/mount -t cifs //*/* /media/* -o username=*
  19.  
  20. %cifsmount ALL = NOPASSWD: /bin/mount -t cifs //*/* /media/* -o username=*
  21.  
  22. #!/bin/bash
  23. case $EUID in
  24. 0) : cool we are already root - fall through ;;
  25. *) # not root, become root for the rest of this session
  26. # (and ask for the sudo password only once)
  27. sudo $0 "$@" ;;
  28. esac
  29. # now the present process is effective-UID (root)
  30. # so there's no need to put sudo in front of commands
  31.  
  32. any more commands here will run as superuser ...
Add Comment
Please, Sign In to add comment