You are not logged in.

#1 2019-06-23 16:32:34

momu
Member
Registered: 2017-10-14
Posts: 137

[SOLVED] Problem with overriding systemd services

I'm trying to change LightDM to conflict with TTY7 instead of TTY1 so I can use TTY1.
So this is what I tried to edit.

[nikola@leviathan ~]$ systemctl cat lightdm.service
# /usr/lib/systemd/system/lightdm.service
[Unit]
Description=Light Display Manager
Documentation=man:lightdm(1)
Conflicts=getty@tty1.service
After=getty@tty1.service systemd-user-sessions.service plymouth-quit.service acpid.service

[Service]
ExecStart=/usr/bin/lightdm
Restart=always
IgnoreSIGPIPE=no
BusName=org.freedesktop.DisplayManager

[Install]
Alias=display-manager.service

I run

sudo systemctl edit --full lightdm.service

and edited the file so it looks like this.

[nikola@leviathan ~]$ cat /etc/systemd/system/lightdm.service 
[Unit]
Description=Light Display Manager
Documentation=man:lightdm(1)
Conflicts=getty@tty7.service
After=getty@tty7.service systemd-user-sessions.service plymouth-quit.service acpid.service

[Service]
ExecStart=/usr/bin/lightdm
Restart=always
IgnoreSIGPIPE=no
BusName=org.freedesktop.DisplayManager

[Install]
Alias=display-manager.service

But unfortunately changes are not applied so when I run

systemctl cat lightdm.service

I still get the contents of /usr/lib/systemd/system/lightdm.service.

I guess I just forgot to do something but what I can't find online (I guess I can always symlink /usr/lib/systemd/system/lightdm.service to /etc/systemd/system/ligthdm.service but I don't think it's a good idea).

Last edited by momu (2019-06-23 21:31:59)

Offline

#2 2019-06-23 18:01:15

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] Problem with overriding systemd services

After modifying any .service file you need to run

# systemctl daemon-reload

Offline

#3 2019-06-23 18:22:07

momu
Member
Registered: 2017-10-14
Posts: 137

Re: [SOLVED] Problem with overriding systemd services

This works only for the current session. If I reboot /etc/systemd/system/lightdm.service still exists but systemctl cat lightdm.service returns contents of /usr/lib/systemd/system/lightdm.service and overridden file has no effect i.e. TTY1 is still disabled.

Offline

#4 2019-06-23 18:57:17

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] Problem with overriding systemd services

Have you enabled the service in /etc/systemd? There should be a symlink in /etc/systemd/system/multi-user.target (or another directory, not at the computer now) linking to your modified service. Seems like the enabled one is still linked to the one in /usr. Maybe disable then enable the service again.

Offline

#5 2019-06-23 19:42:57

CarbonChauvinist
Member
Registered: 2012-06-16
Posts: 413
Website

Re: [SOLVED] Problem with overriding systemd services

At least part of what you're describing is due to your use of the "--full" flag. When using "--full" to edit, whatever edits you've made to the service file are saved to /etc/systemd/system/foo.service and this is supposed to take precedence over the /usr/lib/systemd/system/foo.service file. In your case it isn't taking precedence for some reason, and this seemed to also be the issue with your iwd service you had earlier.

I prefer using "systemctl edit" without the "--full" flag as that will create a blank override file instead which you enter the sections/values you want to override and when you exit and save the file is saved to /etc/systemd/system/foo.service.d/override.conf. I prefer this method as it is a bit more visible that we're purposely/manually overriding a service's settings.

In the override file, you list the heading(s) for the value(s) you're over writing. You also first have to blank out the value you want to override. As an example here's my override for sshd.socket, you can see how clearly it shows the changes we've made from the system defaults:

$ cat /etc/systemd/system/sshd.socket.d/override.conf                                                                       
[Socket]                                                                                                                                
ListenStream=                                                                                                                           
ListenStream=65522
$ systemctl status sshd.socket
● sshd.socket
   Loaded: loaded (/usr/lib/systemd/system/sshd.socket; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/sshd.socket.d
           └─override.conf
   Active: active (listening) since Sun 2019-06-23 14:40:10 EDT; 1h 58min ago
   Listen: [::]:65522 (Stream)
 Accepted: 0; Connected: 0;
    Tasks: 0 (limit: 4915)
   Memory: 44.0K
   CGroup: /system.slice/sshd.socket

Jun 23 14:40:10 5510 systemd[1]: Listening on sshd.socket.
$ systemctl cat sshd.socket 
# /usr/lib/systemd/system/sshd.socket
[Unit]
Conflicts=sshd.service
Wants=sshdgenkeys.service

[Socket]
ListenStream=22
Accept=yes

[Install]
WantedBy=sockets.target

# /etc/systemd/system/sshd.socket.d/override.conf
[Socket]
ListenStream=
ListenStream=65522

Last edited by CarbonChauvinist (2019-06-23 20:42:56)


"the wind-blown way, wanna win? don't play"

Offline

#6 2019-06-23 21:31:42

momu
Member
Registered: 2017-10-14
Posts: 137

Re: [SOLVED] Problem with overriding systemd services

firecat53 wrote:

Have you enabled the service in /etc/systemd? There should be a symlink in /etc/systemd/system/multi-user.target (or another directory, not at the computer now) linking to your modified service. Seems like the enabled one is still linked to the one in /usr. Maybe disable then enable the service again.

Solved.

Offline

Board footer

Powered by FluxBB