Qrexec-client-vm will not run in a service right before shutdown

I’m trying to run a qrexec-client-vm command in a qube just before it shuts down.

I’ve created a systemd service and the script it runs; I’m confident they are running (largely because I put “sleep” calls in it, but also I have it write to a log file).

But there’s no sign that the qrexec-client-vm call in the script is happening. I do have the service file name qubes-core-agent.service as a “wanted by” in the [install] section. (This is softlinked to qubes-qrexec-agent.service, and I tried explicitly having this be a “wantedby” as well.)

Is there something more I need to do here?

[Unit]
Description=Before Shutdown
RequiresMountsFor=/home /usr/local

[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/usr/local/bin/vera-agent-cleanup
TimeoutSec=infinity

[Install]
WantedBy=multi-user.target qubes-core-agent.service

/usr/local/bin/vera-agent-cleanup contains the qrexec call. Everything else in that file executes. vera-agent-cleanup works when called directly from the command line.

I’m wondering if somehow qrexec is being disabled before this runs, in spite of my WantedBy

You don’t have any After or Before statement.

Keep in mind, the shutdown sequence is going to be the reverse of the startup.

1 Like

OK…so what should it be after or before…for qrexec to work?

Putting After=qubes-core-agent.service into the [Unit] section did the trick, apparently!

1 Like