I want to run a script without prompt for password. I edited /etc/sudoers file and I wrote several lines behind last one. This is my file:
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
#includedir /etc/sudoers.d
jose ALL= NOPASSWD: /sbin/shutdown -h now
jose ALL= NOPASSWD: /sbin/shutdown -r now
jose ALL= NOPASSWD: /home/jose/sync.sh
The script code (it works fine with password) is:
#!/bin/bash
#Filename: sync.sh
echo "Empezando sincronizar....."
ping -c 1 -t 1 172.18.2.100 > /dev/null 2> /dev/null # ping and discard output
if [ $? -eq 0 ]; then # check the exit code
echo "${ip} is up" # display the output
sudo mount -t smbfs //172.18.2.100/Downloads /home/jose/pc1
rsync -r -u -verbose /home/jose/pc1/movies/ /home/jose/Movies/
rsync -r -u -verbose /home/jose/pc1/series/ /home/jose/TV?Shows/
sudo umount /home/jose/pc1
# you could send this to a log file by using the >>pinglog.txt redirect
else
echo "${ip} is down"
fi
echo "Fin sincronizacion"
I can shutdown and reboot without type password but when I try to run the last line, the script prompt for password. I replace the script path for "ALL" and I can run root comands without password but I can't run the mount / umount command and the script.
User belongs....
jose : jose adm dialout cdrom floppy audio video plugdev users lpadmin sambashare admin
Any help? Thanks in advance.
whereis mount
)? I've voted this for closure, but if you're still working through this issue it can be reopened.