I have such a bash script:
#!/bin/bash
cd /home/user/projekt
git config core.sparseCheckout true
git pull origin master
wait
rm -rf /var/www/project/{client,public}
cp -r /home/user/project-checkout/project/dist/* /var/www/project/
cd /var/www/project/
npm install
Since I must run the copy
and the npm install
commands with elevated rights, I run the bash script with sudo
.
However - git pull
does not work as sudo since it reads form the users .gitconfig
and .sshconfig
files. IT says "Please make sure you have correct access rights" as expected when doing a git sudo
How to solve? I was thinking in side the script de-elveate right for one commend - possible?
As a bonus, how can I tell my script to only pursue after line 3 has successfully finished?