stevejenkins / pihole-cloudsync

Syncs blocklists, blacklists, and whitelists across multiple Pi-holes using a private GitHub repo
MIT License
517 stars 104 forks source link

Script won't update github via cron #4

Closed feerlessleadr closed 4 years ago

feerlessleadr commented 4 years ago

Hi - First off, thanks for pulling this together, it is awesome.

I followed the instructions, and when I manually run the script on my 'push' pihole, everything in my git repo is updated as expected. However, when I try to run the script via cron, my repo is not updated.

I piped the output of the cron job to a log file, and it looks like everything is doing what it should, so I"m not sure what I'm doing wrong. Here is the relevant details:

Pihole is running on Ubuntu server 18.04

Line in my root crontab: (this is just for testing purposes, which is why I have it running every minute)

          • sudo /usr/local/bin/pihole-cloudsync/pihole-cloudsync --push > "/home/kevin/logs/pihole-cloudsync.log"

Output of above:

--push option detected. Running in Push/Upload mode. Local Pi-hole lists are different than remote Git repo. Updating remote repo... Done!

No matter how many times I let the cron job run, my git repo is never updated.

When I run the script manually with the following (no sudo or anything is needed):

/usr/local/bin/pihole-cloudsync/pihole-cloudsync --push

I get the same output, but the git repo is updated.

Any idea on what I could be doind wrong?

gwstorm commented 4 years ago

Same setup as me using headless ubuntu VM. It only works for me if I use root crontab. At that point, you can also pull sudo from your command. Just remember that root's key will be in /.ssh and not your home directory.

feerlessleadr commented 4 years ago

Thanks - turns out that I was doing a couple things wrong. I was already running the script in my root crontab, so I didn't need to run it with sudo.

Second, when I set up my credentials helper, I did it under my names user account, and not under my root account.

I re-ran the credentials helper under the root account, and everything worked as it should.