Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- sudo 'mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER'
- #!/bin/bash
- echo -n Password:
- read -s szPassword
- echo $szPassword | sudo -S sh -c 'echo $szPassword | mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER'
- if [[ $EUID -ne 0 ]]; then
- echo "This script must be run as root, use sudo "$0" instead" 1>&2
- exit 1
- fi
- #!/bin/bash
- read -p "Password: " -s szPassword
- printf "%sn" "$szPassword" | sudo --stdin mount -t cifs //192.168.1.1/home /media/$USER/home -o username=$USER,password="$szPassword"
- ALL ALL = NOPASSWD: /bin/mount -t cifs //*/* /media/* -o username=*
- %cifsmount ALL = NOPASSWD: /bin/mount -t cifs //*/* /media/* -o username=*
- #!/bin/bash
- case $EUID in
- 0) : cool we are already root - fall through ;;
- *) # not root, become root for the rest of this session
- # (and ask for the sudo password only once)
- sudo $0 "$@" ;;
- esac
- # now the present process is effective-UID (root)
- # so there's no need to put sudo in front of commands
- any more commands here will run as superuser ...
Add Comment
Please, Sign In to add comment