1

I have a handful of containers with a FreeIPA server against which all users authenticate. All the OS are linux. Some of my containers have services that are run on startup via systemd. Unfortunately it appears as though those scripts are failing because the authentication fails. However, if I manually start the service later using systemctl start , then the service starts fine.

Here's an example of the service status output for one of my services:

● emby-server.service - Emby Server is a personal media server with apps on just about every device.
   Loaded: loaded (/etc/systemd/system/emby-server.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/emby-server.service.d
           └─override.conf
   Active: failed (Result: exit-code) since Tue 2021-01-19 11:25:45 GMT; 35s ago
  Process: 163 ExecStart=/opt/emby-server/bin/emby-server (code=exited, status=217/USER)
  Process: 150 ExecStartPre=/bin/sleep 20 (code=exited, status=217/USER)
 Main PID: 163 (code=exited, status=217/USER)

Jan 19 11:25:45 emby systemd[1]: Starting Emby Server is a personal media server with apps on just about every device....
Jan 19 11:25:45 emby systemd[150]: emby-server.service: Failed to determine user credentials: Connection refused
Jan 19 11:25:45 emby systemd[150]: emby-server.service: Failed at step USER spawning /bin/sleep: Connection refused
Jan 19 11:25:45 emby systemd[1]: Started Emby Server is a personal media server with apps on just about every device..
Jan 19 11:25:45 emby systemd[163]: emby-server.service: Failed to determine user credentials: Connection refused
Jan 19 11:25:45 emby systemd[163]: emby-server.service: Failed at step USER spawning /opt/emby-server/bin/emby-server: Connection refused
Jan 19 11:25:45 emby systemd[1]: emby-server.service: Main process exited, code=exited, status=217/USER
Jan 19 11:25:45 emby systemd[1]: emby-server.service: Failed with result 'exit-code'.

I suspect I need to introduce a pause before the script runs to allow the FreeIPA client to start itself first because the script fails with the above error on start up, but runs fine if started later.

I tried adding a sleep into the /etc/systemd/system/servicename.service script with ExecStartPre=-/bin/sleep 20, but my guess is that it's failing before then because the script itself can't start until the user has been authenticated.

Please could you help me with:

  1. From the information above, is my identification of the problem correct
  2. Should/could I do anything else to confirm the cause of the problem
  3. How can I introduce a pause before that servicename.service script is run?

Thanks

1
  • to the moderators. Perhaps this question is more suited to Unix & Linux. Please could you kindly move it to that forum?
    – Pedro
    Commented Jan 22, 2021 at 16:39

1 Answer 1

0

Adding the following to the [Unit] section of the systemd service file seems to have resolved the issue for me:

[Unit]
...
After=sssd.service
Requires=sssd.service

This sets a dependency and ordering constraint between the service and the sssd service that provides FreeIPA identity/authentication.

1
  • I don't have the 15 reputation to allow me to vote yet, but just wanted to thank @jiahao Li and confirm that the fix works for me.
    – Pedro
    Commented Nov 4, 2022 at 9:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .