Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 864581 - www-apps/sonarr installs with service which won't start up
Summary: www-apps/sonarr installs with service which won't start up
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michael Crawford (ali3nx)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-09 17:43 UTC by Davyd McColl
Modified: 2022-08-10 13:17 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
init script, cloned and modified from radarr (sonarr,1.09 KB, text/plain)
2022-08-09 17:44 UTC, Davyd McColl
Details
bash script stub to start up Sonarr.exe with mono (Sonarr,42 bytes, application/x-shellscript)
2022-08-09 17:45 UTC, Davyd McColl
Details
suggestion for the sonarr init script (sonarr-init-suggestion,197 bytes, text/plain)
2022-08-10 13:08 UTC, Davyd McColl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Davyd McColl 2022-08-09 17:43:34 UTC
This has happened twice now - I figured the first time was an oopsie that might be resolved this time around, but apparently not.

www-apps/sonarr installs with a broken init script, missing the depend function as well as the check_config, start and stop functions.

The only way I get things to work again is to:
1. copy /etc/init.d/radarr to /etc/init.d/sonarr
2. find-and-replace: radarr -> sonarr & Radarr -> Sonarr
3. add a new file: /opt/sonarr/Sonarr, which is just a shell script doing `mono $(dirname $0)/Sonarr.exe` as (1) nothing in that folder is marked as executable (so even with the mono binfmt magic, it won't start up) and (2) the copied-over radarr script points to Radarr, so it keeps the fix-up simpler.

Without these changes, the service "appears" to start, but doesn't actually run - attempting to browse to it with firefox fails. After these updates, things are back to working as per usual.

Currently installed version: 3.0.9.1549
Comment 1 Davyd McColl 2022-08-09 17:44:41 UTC
Created attachment 799011 [details]
init script, cloned and modified from radarr
Comment 2 Davyd McColl 2022-08-09 17:45:02 UTC
Created attachment 799013 [details]
bash script stub to start up Sonarr.exe with mono
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-10 03:15:03 UTC
Did you file a bug for the issue when you first hit it?

In this case, I'm pretty sure the OpenRC init script got included as a courtesy, but the maintainer doesn't use it, so it makes sense they hadn't noticed I guess.
Comment 4 Davyd McColl 2022-08-10 04:23:51 UTC
This is the first time I've raised the issue - I think that last time I worked around it and mistakenly thought that this package was still coming from the usenet overlay, so didn't get around to logging.

I'd appreciate some clarification on severity ratings for logging bugs - I sat there for a while trying to determine the correct level as I don't want to be alarmist nor do I want to underrate it. I selected blocker because it literally blocks vanilla usage of the application (at least under openrc, but I wouldn't know about that other init system) but I see it's been dropped to normal. Perhaps there's a doc somewhere I need to read?
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-10 04:33:21 UTC
(In reply to Davyd McColl from comment #4)
> This is the first time I've raised the issue - I think that last time I
> worked around it and mistakenly thought that this package was still coming
> from the usenet overlay, so didn't get around to logging.
> 
> I'd appreciate some clarification on severity ratings for logging bugs - I
> sat there for a while trying to determine the correct level as I don't want
> to be alarmist nor do I want to underrate it. I selected blocker because it
> literally blocks vanilla usage of the application (at least under openrc,
> but I wouldn't know about that other init system) but I see it's been
> dropped to normal. Perhaps there's a doc somewhere I need to read?

Honestly, it's tricky. In a sense, it doesn't _really_ matter, although we should probably use them more.

See https://bugs.gentoo.org/enter_bug.cgi?product=Gentoo%20Linux&format=guided. If you click through, at the bottom, it'll give a list of severities/priorities and descriptions.
Comment 6 Craig Andrews gentoo-dev 2022-08-10 12:42:29 UTC
(In reply to Davyd McColl from comment #0)
> www-apps/sonarr installs with a broken init script, missing the depend
> function as well as the check_config, start and stop functions.

The depend function isn't necessary. Your script has a dependency on net, which isn't required for sonarr to start.

The start and stop functions also are unnecessary. Simple defaults are provided that use command=, command_args=, and pidfile= which the Gentoo provided script includes.

Please see https://github.com/OpenRC/openrc/blob/master/service-script-guide.md

> The only way I get things to work again is to:
> 1. copy /etc/init.d/radarr to /etc/init.d/sonarr

The init script attached at https://bugs.gentoo.org/attachment.cgi?id=799011 isn't copied from Gentoo's radarr init script, it must come from an overlay. Here's Gentoo radarr init: https://github.com/gentoo/gentoo/blob/0877509414c54a84d3bddbeda4e5b4dc89ccb4ef/www-apps/radarr/files/radarr.init

> 2. find-and-replace: radarr -> sonarr & Radarr -> Sonarr
> 3. add a new file: /opt/sonarr/Sonarr, which is just a shell script doing
> `mono $(dirname $0)/Sonarr.exe` as (1) nothing in that folder is marked as
> executable (so even with the mono binfmt magic, it won't start up) and (2)
> the copied-over radarr script points to Radarr, so it keeps the fix-up
> simpler.

I can definitely add a simple /opt/sonarr/Sonarr as you suggest, but I think we should get to the bottom of why the init script doesn't work first.

> Without these changes, the service "appears" to start, but doesn't actually
> run - attempting to browse to it with firefox fails. After these updates,
> things are back to working as per usual.
> 
> Currently installed version: 3.0.9.1549

As noted in https://bugs.gentoo.org/864581#c3, I don't use OpenRC (I used systemd), so the openrc script is provided as a courtesy. I had it reviewed by other Gentoo developers, and I tried my best to ensure it worked but ultimately I can't test it.

When you run it, do you get any error output? We need to figure out what's going wrong and fix it. Thank you for the report and for your ongoing support in fixing this problem!
Comment 7 Larry the Git Cow gentoo-dev 2022-08-10 12:55:06 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8fb51d0518a8bdefde5499d41e1b43b638838eb1

commit 8fb51d0518a8bdefde5499d41e1b43b638838eb1
Author:     Craig Andrews <candrews@gentoo.org>
AuthorDate: 2022-08-10 12:50:47 +0000
Commit:     Craig Andrews <candrews@gentoo.org>
CommitDate: 2022-08-10 12:55:02 +0000

    www-apps/sonarr: add executable to make running Sonarr easier
    
    Bug: https://bugs.gentoo.org/864581
    Signed-off-by: Craig Andrews <candrews@gentoo.org>

 www-apps/sonarr/files/Sonarr                |  3 ++
 www-apps/sonarr/files/sonarr.init-r1        |  7 +++++
 www-apps/sonarr/files/sonarr.service-r1     | 30 ++++++++++++++++++
 www-apps/sonarr/sonarr-3.0.9.1549-r1.ebuild | 47 +++++++++++++++++++++++++++++
 4 files changed, 87 insertions(+)
Comment 8 Davyd McColl 2022-08-10 13:08:27 UTC
Thanks for the info Craig

I'm not an open-rc guru - I hadn't (until now) ever seen an open-rc init script without at least the start function, so it's interesting to learn that there's a "minimal" way to do these scripts, at least in theory

I don't recall making the radarr init script myself, but perhaps I did, very long ago when I first ran Radarr and Sonarr from sources manually built on my machine. 

If I do a re-install of sonarr (emerge -1 sonarr) and use the new init script, I can see that there is a sonarr process running, however, I can't browse to the web ui - and I think it might be because the service is being started as the sonarr user, instead of the user I've configured in /etc/conf.d/sonarr

I've made a minor modification to the original script and attached - this one is working (:

Again, remembering that I'm not an open-rc guru (but quite willing to both test and learn), I would (with my limited understanding) suggest that the depend function be included - both sonarr and radarr aren't very useful if the network isn't up yet.

I definitely need to read https://github.com/OpenRC/openrc/blob/master/service-script-guide.md properly - I have needed to write my own open-rc init scripts before, and I've tended to simply copy and modify some other working script ^_^

Edit: I see you commented whilst I was writing this (: with that change to the init script, obviously mine couldn't be taken as-is: it would need an update to use the Sonarr stub script you've added (:
Comment 9 Davyd McColl 2022-08-10 13:08:49 UTC
Created attachment 799131 [details]
suggestion for the sonarr init script
Comment 10 Davyd McColl 2022-08-10 13:09:25 UTC
So it seems that the only real issue is that the USER/GROUP settings from /etc/conf.d aren't applied (: Thanks for looking into this.
Comment 11 Craig Andrews gentoo-dev 2022-08-10 13:14:02 UTC
(In reply to Davyd McColl from comment #9)
> Created attachment 799131 [details]
> suggestion for the sonarr init script

> command_user="${GROUP=sonarr}:${USER=sonarr}"

I think the better syntax is:
command_user="${GROUP:-sonarr}:${USER:-sonarr}"

So I'm going to go with that.

(In reply to Davyd McColl from comment #10)
> So it seems that the only real issue is that the USER/GROUP settings from
> /etc/conf.d aren't applied (: Thanks for looking into this.

Awesome, that'll be an easy fix then. Thanks again for working through this!
Comment 12 Larry the Git Cow gentoo-dev 2022-08-10 13:17:33 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2737bb5e0286b4b497fff427bf01b2c802e299df

commit 2737bb5e0286b4b497fff427bf01b2c802e299df
Author:     Craig Andrews <candrews@gentoo.org>
AuthorDate: 2022-08-10 13:16:47 +0000
Commit:     Craig Andrews <candrews@gentoo.org>
CommitDate: 2022-08-10 13:17:29 +0000

    www-apps/sonarr: allowing overriding user/group in openrc init script
    
    Closes: https://bugs.gentoo.org/864581
    Signed-off-by: Craig Andrews <candrews@gentoo.org>

 www-apps/sonarr/files/sonarr.init-r2        |  7 +++++
 www-apps/sonarr/sonarr-3.0.9.1549-r2.ebuild | 47 +++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)