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.service with 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.target

I’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 with sudo systemctl enable --now daemon.service, it exits with error code 126.

What am I missing?

Edit: typo

Edit 2: Added script modifications. Daemon appears to be some kind of pre-compiled binary.

Solution: ExecStart wanted /usr/bin/env to launch the binary. The service file above has been edited to reflect the correct solution. See this post for further discussion.

  • @bushvin
    link
    3
    edit-2
    4 months ago

    Why use /bin/bash in your ExecStart directive? You can just specify the path to your daemon.

    /bin/bash expects a script, not a binary, which your daemon most probably is…

    • @[email protected]OP
      link
      fedilink
      1
      edit-2
      4 months ago

      Nope, leaving off the initial env call, in this corrected case, gives a 203/EXEC error.

      It would have been easy if I could just call the binary, but alas. Dunno why, but there it is.

      ETA: this is on Bazzite, so maybe systemctl behaves slightly differently…?

      • @bushvin
        link
        24 months ago

        Additional question: when starting the daemon from the cli, does it terminate?

        • @[email protected]OP
          link
          fedilink
          14 months ago

          Nope. sudo /path/to/daemon works. Thankfully, the service launches, now that I’ve included /usr/bin/env.

          It would have been nice if it was an easy to read script, to tell what it needed, but alas.