After rebooting, all file permissions disappear/reset

Sonarr version (exact version): 3.0.5.1144
Mono version (if Sonarr is not running on Windows): 6.12.0.122
OS: Ubuntu 20.04.2 LTS
Description of issue:
After rebooting, all the permissions of the files inside /opt/Sonarr “reset”. This resulted in sonarr not starting up on boot. See the screenshot below.
Right after rebooting:


After doing sudo chmod 777 /opt/Sonarr/Sonarr.exe, and sudo systemctl restart sonarr.service it worked. So everytime my server (re)boots, I have to set the permissions for sonarr again.

Before chmod (after rebooting):
image

After chmod (after rebooting):
image

I discovered a tool called pathlld which shows the permissions of a file and everything (folders) before it. This is the output after rebooting but before chmod-ing:
image

This is the output after rebooting and chmod-ing:
image

So I chmod Sonarr.exe to make it executable and sonarr works fine. But after rebooting, Sonarr.exe returns to being un-executable (as seen in the output of pathlld before chmod-ing).

I’ve had this problem for quite a while now. Hopefully someone can help!

Thanks.

/opt/Sonarr isn’t the official install location of Sonarr v3. What package are you using? (Not ours)

@Taloth This page -> linux -> ubuntu. This was before v3 came out of beta (that happened a few days ago right? because I installed it before that.).

Nothing significant changed for the debian package for the better part of 2 years. In fact, a deb package update in december 2018 changed the v3 alpha path from /opt/sonarr to /usr/lib/sonarr. So yeah, you’re on an ancient package version.

Fix that, update first. Just follow the regular v3 install instructions on the site. It should upgrade properly (might wanna make a backup though).

I made a backup
I did sudo apt purge sonarr.
After that sudo apt autoremove
And then followed this.
But after that it’s still installed on /opt/Sonarr.

How do completly uninstall sonarr (like it has never been on my server) and after that how to correctly install it?

Sonarr v3 alpha was never installed in /opt/Sonarr only /opt/sonarr based on the code. So my guess is that was done manually somehow, definitely not our package.

You can confirm that with dpkg -S /opt/Sonarr/Sonarr.exe. It’ll show which package is owner of a particular file.

Check if sonarr is running properly in /usr/lib/sonarr, if so then you can probably manually remove the /opt/Sonarr stuff (if dpkg shows nothing owned it). It really depends on how it was installed.
You might have to manually check if the startup logic is correct too.

Hey,

dpkg -S /opt/Sonarr/Sonarr.exe
returned
dpkg-query: no path found matching pattern /opt/Sonarr/Sonarr.exe

I indeed have the /usr/lib/sonarr folder and I see everything in it.
I removed the complete /opt/Sonarr/ folder using sudo rm -R /opt/Sonarr.
Then I edited the .service file of sonarr and changed it to run /usr/lib/sonarr/bin/Sonarr.exe instead of /opt/Sonarr/Sonarr.exe. I reloaded the systemctl daemon and restarted sonarr.service.

After that (I didn’t even need to upload the backup) sonarr ran and showed (via the webinterface) that the startupdir is the new one so that’s good. It’s working now.

Thank you very much.

run systemctl cat sonarr and check which files are involved. The package manages the one in /lib/systemd/system/sonarr.service

(Checking this is important, so it doesn’t get busted on the next update)

sudo systemctl cat sonarr:

# /etc/systemd/system/sonarr.service

[Unit]
Description=Sonarr Daemon
After=network.target
[Service]
User=root
Group=root
ExecStart=/usr/lib/sonarr/bin/Sonarr.exe
Type=simple
TimeoutStopSec=20
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target

Ok, a few things:

  • There should be a /lib/systemd/system/sonarr.service
  • Running as ‘root’ isn’t recommended. It’s possible and ultimately your choice, but not recommended.

Can you do the following:

  • apt policy sonarr confirm you have 3.0.5 installed. If not, then let me know first.
  • backup your /etc/systemd/system/sonarr.service
  • systemctl stop sonarr
  • Remove /etc/systemd/system/sonarr.service
  • systemctl daemon-reload
  • Copy the config to /var/lib/sonarr
  • apt remove sonarr
  • apt install sonarr
  • systemctl cat sonarr
  • If you need to change the user, group, config dir. run dpkg-reconfigure -plow sonarr after install
  • and if needed systemctl start sonarr

Okey, I’m currently at step 7 (Copy the config to /var/lib/sonarr). What config? Do you mean the backup of sonarr.service? Probably not but what do you mean with config and where can I find it?

the sonarr config, given your previous startup it’s likely in /root/.config/sonarr atm

cd-ing to root was not allowed but when using sudo it says cd; command not found. But doing sudo -s and then cd-ing did work. So I did (after doing sudo -s) cd /root/.config/Sonarr and it worked. But when I do ls, it looks exactly like /home/cas/.config/Sonarr. Is this correct? I don’t want to accidentally copy the wrong config.xml. P.S. thanks for helping me so quickly!

This is what it looks like after copying /root/.config/Sonarr/config.xml to /var/lib/sonarr:
image

Okay I think everything is now correctly setup. I’ve followed your instructions. This is after all the instructions. See below:

# /lib/systemd/system/sonarr.service
[Unit]
Description=Sonarr Daemon
After=network.target

[Service]
User=sonarr
Group=sonarr
UMask=002

Type=simple
ExecStart=/usr/bin/mono --debug /usr/lib/sonarr/bin/Sonarr.exe -nobrowser -data=/var/lib/sonarr
TimeoutStopSec=20
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

image

Is this all correct? I have the feeling that it is! I really apprecatie the time you took.

I’m missing the sonarr.db

You know what, you mentioned you made a backup (presumably in app, .zip file). Just restore that backup in-app.

I did indeed make a backup (.zip from webinterface). I’ve uploaded it and everything restored correctly.

The systemd unit and everything else looks fine. Nicely done.

One note, since sonarr is now running as sonarr:sonarr, you may have to check the permissions of your media library. And how your download client downloads files.

Personally I run sonarr as sonarr:mediahost… where mediahost is a group shared between the download client, sonarr and plex so all have read and write permissions.
You can also just add the sonarr user to the appropriate groups as secondary groups. There are some options there.

Okay I understand.

One last question (not really related but I don’t want to make a complete sepperate thread for it)

Now that Sonarr is officially on v3, how do I access the api? I always used http://localhost:8989/api as the root. Is it now http://localhost:8989/api/v3? Are there any benefits of adding the v3 at the end? Because I can still access the api without the v3 at the end…

For the most part the v2 api will remain intact insofar it’s possible. v3 api exposes some of the new features, like release profiles. But it also removed some nested resources that v2 had.
I want to do a more comprehensive api documentation for v3 (if I ever find the time).

If we decide to remove the v2 api when we go to sonarr v4 (or earlier) then we’ll certainly throw up a health check warning for months prior.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.