mrworf / plexupdate

Plex Update script to simplify the life of Linux Plex Media Server users.
GNU General Public License v2.0
1.77k stars 146 forks source link

"error: cannot open .git/FETCH_HEAD: Permission denied" when testing installer.sh #277

Closed Byrd910 closed 4 years ago

Byrd910 commented 4 years ago

I followed the instructions for installation on the main page (bash -c "$(wget -qO - https://raw.githubusercontent.com/mrworf/plexupdate/master/extras/installer.sh)"), but when I select the option to run the script with the settings chosen during install, I get the error "error: cannot open .git/FETCH_HEAD: Permission denied". I get the same error whenever I rerun installer.sh from /opt/plexupdate/extras/installer.sh and have it test the settings chosen. I am choosing Yes to Plex Pass versions, No to auto-install, and Yes to everything else. I am running Ubuntu Server 20.04 LTS. I have tried giving the entire /opt/plexupdate/.git folder 774 permissions, but the installer then said I had modified plexupdate files and it reinstalled again. I still get the same error. Is this expected, or is there something else I need to do?

demonbane commented 4 years ago

The most likely issue is that you either installed it with a different user than you're trying to run it as, or there was an issue with sudo while installing. Can you please run the following and provide the output?

id && ls -al /opt/plexupdate /opt/plexupdate/.git
Byrd910 commented 4 years ago

Sorry it took a while to get back to you - here is the output requested (note the plex user is the user I created when installing Ubuntu Server):

uid=1000(plex) gid=1000(plex) groups=1000(plex),4(adm),24(cdrom),27(sudo),30(dip),44(video),46(plugdev),109(render,),116(lxd) /opt/plexupdate: total 72 drwxr-xr-x 4 root root 4096 Jul 11 04:51 . drwxr-xr-x 6 root root 4096 Jul 11 04:51 .. drwxrwxr-x 8 root root 4096 Jul 11 06:25 .git -rw-rw-r-- 1 root root 18025 Jul 11 04:51 LICENSE -rwxrwxr-x 1 root root 5321 Jul 11 04:51 README.md drwxrwxr-x 2 root root 4096 Jul 11 04:51 extras -rwxrwxr-x 1 root root 8068 Jul 11 04:51 plexupdate-core -rwxrwxr-x 1 root root 17302 Jul 11 04:51 plexupdate.sh

/opt/plexupdate/.git: total 56 drwxrwxr-x 8 root root 4096 Jul 11 06:25 . drwxr-xr-x 4 root root 4096 Jul 11 04:51 .. -rwxrwxr-x 1 root root 98 Jul 20 06:25 FETCH_HEAD -rwxrwxr-x 1 root root 23 Jul 11 04:51 HEAD drwxrwxr-x 2 root root 4096 Jul 11 04:51 branches -rwxrwxr-x 1 root root 261 Jul 11 04:51 config -rwxrwxr-x 1 root root 73 Jul 11 04:51 description drwxrwxr-x 2 root root 4096 Jul 11 04:51 hooks -rwxrwxr-x 1 root root 576 Jul 11 06:25 index drwxrwxr-x 2 root root 4096 Jul 11 04:51 info drwxrwxr-x 3 root root 4096 Jul 11 04:51 logs drwxrwxr-x 4 root root 4096 Jul 11 04:51 objects -rwxrwxr-x 1 root root 346 Jul 11 04:51 packed-refs drwxrwxr-x 5 root root 4096 Jul 11 04:51 refs

demonbane commented 4 years ago

It looks like you were root at the time you installed it, hence the problem. You can either just run it as root (or using sudo), or if you’d prefer to run it as the plex user, just delete the /opt/plexupdate directory and install it again, making sure you’re logged in as plex when you do it. The installer may ask you for sudo permission but it will use it to set the permissions to the user you’re currently logged in as so it should work just fine. Let me know if that takes care of it for you.

Byrd910 commented 4 years ago

Thanks! I believe I did originally install it under the plex user, but I went ahead and deleted the plexupdate directory, and the plexupdate.conf/plexupdate.cron.conf files under /etc, and the cron job under /etc/cron.daily. Then I made sure I was not running as root and re-ran the installer. It asked me for sudo credentials as you said, and I selected:

1) The default /opt/plexupdate installation directory 2) Y to PlexPass releases 3) N to automatically installing latest releases when downloaded 4) Y to setting up automatic updates for Plex

It is at number 4 where it tells me "WARNING: For security reasons, plexupdate needs to be installed as root in order to run automatically. In order to finish setting up automatic updates, we will change the ownership of '/opt/plexupdate' to root:root."

I select Y here, as otherwise the installer exits. I select N to writing to syslog, Y to sending emails, and then Y to run plexupdate with these settings now. When it runs with these settings, it throws the "error: cannot open .git/FETCH_HEAD: Permission denied" again.

demonbane commented 4 years ago

Ah, ok. Yes, that’s unavoidable unfortunately. If you want to have plexupdate run automatically via cron it has to be installed as root, so the installer made that change for you. If you want it to run automatically every day, all you have to do is just run it as root (or use sudo) when you want to run it manually. It will automatically run every night and already have the permissions it needs.

If you want to just have it installed as the plex user, you can do that as well, you just can’t enable automatic updates that way.

Byrd910 commented 4 years ago

Gotcha - thanks for the clarification! I just wanted to make sure there wasn't a problem when I was seeing that error when it asked me to test the setup.

demonbane commented 4 years ago

Oh, I didn't realize that was during your initial setup. That part is a bug. If the installer ends up installing plexupdate as root it should run it as root if you answer Y to run with these settings now. I'll reopen this for now and then close it once an update is pushed out. Sorry it took me a while to figure out what you meant.