cross-posted from: https://reddthat.com/post/21668140
I have a VPN daemon that needs to run before the client will work. Normally, this would have been set up automatically by its install script, but the system is immutable.
I've created the systemd service via
sysyemctl edit --force --full daemon.servicewith the following parameters:[Unit] Description=Blah After=network-online.target [Service] User=root Group=root ExecStart=/usr/bin/env /path/to/daemon [Install] WantedBy=multi-user.targetI've verified that the daemon is actually executable, and it runs fine when I manually call it via
sudo daemon. When I try to run it withsudo systemctl enable --now daemon.service, it exits with error code 126.What am I missing?
Edit: Typo, and added the relevant user and group to the Service section. Still throwing a 126.
Solution: the system wanted /usr/bin/env in ExecStart to launch the binary. The .service file above has been edited to show the working solution.
13 Comments
nhowell77@sh.itjust.works · 3 pts · 2y
If that is your full .service file you are missing the directive to tell the daemon what user to run under. Under service try adding
User=root
Group=root
Before the ExecStart command line.
Successful_Try543@feddit.org · 4 pts · 2y
Is that necessary for processes running as
root? AfaIk,rootis default.Keywords should be in CamelCase format, thus the space in
Wanted Byis wrong.nhowell77@sh.itjust.works · 3 pts · 2y
Honestly can't believe I completely missed the space in Wanted By. This is likely the bigger culprit to the failed to run error. Poster above me is correct should read
WantedBy
Telorand@reddthat.com · 2 pts · 2y
It's an autocorrect typo. It's actually
WantedByin the file.Successful_Try543@feddit.org · 2 pts · 2y
Would have been nice if this would have been the error.
Telorand@reddthat.com · 2 pts · 2y
Foiled by autocorrect! There's no space in the original file, and I've edited my post to reflect that.
Rustmilian@lemmy.world · 4 pts · 2y
Telorand@reddthat.com · 2 pts · 2y
Thanks, I verified that it's in the correct place. Still throwing a 126 (see the modifications in the edit).
Rustmilian@lemmy.world · 1 pts · 2y
Telorand@reddthat.com · 1 pts · 2y
Private Internet Access
Rustmilian@lemmy.world · 1 pts · 2y
Telorand@reddthat.com · 2 pts · 2y
Yep, more specifically I tried
sudo systemctl enable --now daemon.service. Gives the same error, and maybe that's because it's some kind of binary.sudo /bin/bash /path/to/daemonthrows the same error, butsudo /path/to/daemondoes not. However, if I drop ,/bin/bashfrom the service file, it throws a 203 error instead.Rustmilian@lemmy.world · 3 pts · 2y
Telorand@reddthat.com · 2 pts · 2y
I added the relevant user and group, and it's still throwing a 126. I checked the daemon itself, and it looks like it's a pre-compiled binary. Manually running
/bin/bash /path/to/daemongives the same error, butsudo /path/to/daemonstarts the daemon.Successful_Try543@feddit.org · 1 pts · 2y
Does the command in
ExecStartwork in a root environment, e.g.sudo -i?