I have the following script which works great when I, with my own sudo privileges, run it:
department_wpsites=("/var/www/asiane/wp-ane" "/var/www/english/wp-english")
for f in ${department_wpsites[*]}
do
theme_path="$f/wp-content/themes/dept-theme"
cd $theme_path
echo ">> Performing 'git pull' at $theme_path"
sudo -u www-data git pull
done
Now I want one of my underlings, who does NOT have sudo privileges, to be able to run it. Notice that the need is for all files modified/created by git pull
to be owned by www-data, regardless of who runs the script. What can I do to allow a non-sudo user to use this script or something equivalent?
sudo can be adjusted to allow the administrator to set up what can be run by who. It's not like one-size-fits-all "when I add a user into sodoers file the user is automatically an admin" is forced. sodoers allows for fine grained rules that can help you tailor it to meet your needs where a single user is going to be allowed to run a single script (and nothing else).