I'm running a Raspberry that executes on the startup from the rc.local the following command:
sudo /usr/bin/python3 /home/pi/skript.py >> log.txt 2>&1 &
I need the sudo rights because the script is manipulating a lot of stuff. When the raspberry is shutdown via a button and the script, the git is called to see if there is an update:
from sh import git
git("--git dir=" self.gitDir + ".git/" ...)
The problem is, that I'm not able to submit the credentials for the remote repository hosted on Bitbucket. For the user pi I created a ~/.netrc file as mentioned here: https://confluence.atlassian.com/bitbucketserver/permanently-authenticating-with-git-repositories-776639846.html
With the user pi it' s working, but the script is run by sudo and sudo is not able to use the credentials from the home directory of pi. I did not find an option to run the git command form sh with something like -H -u pi.
Maybe there is an option to give sudo a ~/.netrc as well, but that I already tried without success. Maybe there is something special to know?