Jump to content

Debian Init-Script for sysvinit users


acn128

Recommended Posts

Hi,

 

as I am using Debian Stretch with the classic SysVinit, the provided .deb file does not work correctly - as the package does not supply a init script.

The older packages from the third party repository included one, but the emby.media-packages do not.

 

So I created an init script which is working on my system, see the attached file (I had to rename it to .txt for being able to attach it).

It uses the /etc/default/emby-server and /etc/emby-server.conf mechanism for setting the defaults and includes the commands from /opt/emby-server/bin/emby-server (as only one such script is really needed...).

To start and stop Emby, it uses start-stop-daemon which works well on my system and creates/removes the PID file on its own to address the process.

 

Feel free to use it or to include it in the next packages.

 

Regards,

Anna

 

emby-server.txt

Link to comment
Share on other sites

@Luke:

In my opinion, it *should* do nothing, as restarting a daemon process via some "/etc/init.d/emby-server restart" is something that only root should be able to do.

 

Besides, I don't know what should happen - the process (EmbyServer) runs as user "emby". It has no rights to start the init scripts and other system-related things (as we are on a UNIX operating system).

 

Btw: What should "restart" and "shutdown" really do? Reboot or shutdown the OS? (Are you kidding me?!)

 

Regards,

Anna

Link to comment
Share on other sites

Oh, I've tried the "restart" button, the following things appear in the logfile:

2018-08-17 15:56:22.506 Info HttpServer: HTTP POST http://xxxxx:8096/emby/System/Restart. UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:52.9) Gecko/20100101 Goanna/4.1 Firefox/52.9 PaleMoon/28.0.0
2018-08-17 15:56:22.508 Info HttpServer: HTTP Response 204 to 1.1.1.1. Time: 2ms. http://xxxxx:8096/emby/System/Restart 
2018-08-17 15:56:22.513 Info App: Calling RestartInternal
2018-08-17 15:56:22.517 Info App: Disposing CoreAppHost
2018-08-17 15:56:22.517 Info App: Disposing IsoManager
2018-08-17 15:56:22.517 Info App: Disposing TaskManager
2018-08-17 15:56:22.519 Info App: Disposing InstallationManager
2018-08-17 15:56:22.520 Info App: Disposing SqliteUserRepository
2018-08-17 15:56:22.540 Info HttpServer: HTTP GET http://xxxxx:8096/web/favicon.ico. UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:52.9) Gecko/20100101 Goanna/4.1 Firefox/52.9 PaleMoon/28.0.0
2018-08-17 15:56:22.540 Info HttpServer: HTTP Response 304 to 1.1.1.1. Time: 0ms. http://xxxxx:8096/web/favicon.ico 
2018-08-17 15:56:22.729 Info App: Disposing SqliteDisplayPreferencesRepository
2018-08-17 15:56:22.782 Info HttpServer: HTTP GET http://xxxxx:8096/emby/System/Info. UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:52.9) Gecko/20100101 Goanna/4.1 Firefox/52.9 PaleMoon/28.0.0
2018-08-17 15:56:22.783 Info HttpServer: HTTP Response 200 to 1.1.1.1. Time: 1ms. http://xxxxx:8096/emby/System/Info 
2018-08-17 15:56:22.843 Info App: Disposing SqliteItemRepository
2018-08-17 15:56:23.303 Info HttpServer: HTTP GET http://xxxxx:8096/emby/System/Info. UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:52.9) Gecko/20100101 Goanna/4.1 Firefox/52.9 PaleMoon/28.0.0
2018-08-17 15:56:23.305 Info HttpServer: HTTP Response 200 to 1.1.1.1. Time: 3ms. http://xxxxx:8096/emby/System/Info

After that, Emby answers with a "503 Service Unavailable".....

 

As it seems, the software quits, but does not get restarted.

Maybe I should add some check or look if start-stop-daemon could do something here.

But at least I do not use these buttons right now.

Edited by acn128
Link to comment
Share on other sites

  • 2 months later...
jamesdtyler

I see a section of the init file refers to "$EMBY_USER" and "$EMBY_GROUP", and I get an error when starting.

I attempted to set both to my existing user, and it seemed to think that was ok. Are there defaults that the DEB package creates with the POSTINST script.

 

Finally, the convention seems different for this server than some of the other servers out there (i.e. nzbdrone,or sonarr)

is this text file meant to be contained in "/etc/init.d/emby-server" "/etc/default/emby-server.conf" or "(something else)"

 

monodevelop started the git version(allowing me to run the wizard), but I could not determine how to add the server to sysV.

seeking this information, I arrived at this post.

 

Thanks,

Jay

Link to comment
Share on other sites

Hallo Jay,

 

the script needs the files /etc/default/emby-server and /etc/emby-server.conf.

The "default" file holds the defaults as provided by Emby and in /etc/emby-server.conf you should enter your local overrides.

 

What error do you see?

 

Anna

Link to comment
Share on other sites

jamesdtyler

The 3.6 deb installed, but I don't think that the postinst script was ever performed.

 

error is "[....] Starting emby-server daemon:start-stop-daemon: missing group name"

 

I manually went through the "configure" section of postinst, with sudo.

postinst:

configure)
    getent group emby > /dev/null 2>&1 || groupadd -r emby
    getent passwd emby > /dev/null 2>&1 && usermod -c 'Emby Server' -g emby -d /var/lib/emby -m -s /usr/bin/nologin emby
    getent passwd emby > /dev/null 2>&1 || useradd -r -c 'Emby Server' -g emby -d /var/lib/emby -m -s /usr/bin/nologin emby
    passwd -l emby > /dev/null
    [ -d /var/lib/emby ] || mkdir /var/lib/emby
    chmod 755 /var/lib/emby
    chown emby:emby -R /var/lib/emby
    if [ -x "$(which systemctl)" ]; then
      systemctl daemon-reload
      systemctl enable emby-server || true
      systemctl start emby-server || true
    else
      service emby-server start
    fi
    ;;

commands like so...

groupadd -r emby
usermod -c 'Emby Server' -g emby -d /var/lib/emby -m -s /usr/bin/nologin emby
useradd -r -c 'Emby Server' -g emby -d /var/lib/emby -m -s /usr/bin/nologin emby
passwd -l emby > /dev/null
mkdir /var/lib/emby
chmod 755 /var/lib/emby
chown emby:emby -R /var/lib/emby
ldconfig
service emby-server start

did a reboot...

tyler@shade:~$ sudo service emby-server status
[FAIL] emby-server is not running ... failed!
tyler@shade:~$ sudo service emby-server start
[....] Starting emby-server daemon:start-stop-daemon: missing group name
 failed!
tyler@shade:~$ ls -al /var/lib | grep emby
drwxr-xr-x   2 emby          emby          4096 Nov 19 10:34 emby

(scratches head)

 

files installed on system with -la

https://pastebin.com/gNNKLDme

 

perhaps my files have incorrect contents?

 

Thanks, Jay

Link to comment
Share on other sites

  • 3 months later...
sczan1101
Thanks for your work. 
I reinstall emby-server, but thers is no file /etc/default/emby-server
# service emby-server start
/etc/init.d/emby-server:line33: /etc/default/emby-server: no such file or directory
I stayed in this interface for more than ten minutes.
Alerts > scan media library failed
Unable to cast object of type 'MediaBrowser.Controller.Entities.Folder' to type 'MediaBrowser.Controller.Entities.AggregateFolder'.
at Emby.Server.Implementations.Library.LibraryManager.CreateRootFolder()
at Emby.Server.Implementations.Library.LibraryManager.get_RootFolder()
at Emby.Server.Implementations.IO.LibraryMonitor.Start()
at Emby.Server.Implementations.Library.LibraryManager.ValidateMediaLibraryInternal(IProgress`1 progress, CancellationToken cancellationToken)
at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)

 

5c8b6af513575_20190315170502.png

Edited by sczan1101
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...