1

I'm trying to write a systemd service that both starts at boot time and can be used during a user session using the "sudo systemctl restart" command.

However, when using this command I need to be able to pass different parameters such as "-x" or "-h" or whatever the program of this service may use.

e.g.

sudo systemctl restart myservice -v

this command above would show the version info returned by myservice.

So, I would like, when using a specific parameter, to open a terminal and launch a command, then that console session staying open until I close it.

Below is a sample of what I expect to do:

[Unit]
Description=myprog
ConditionFileExecutable=/opt/mystuff/myprog

[Service]
Type=pneshot
ExecStart=/opt/mystuff/myprog -r
ExecStop=/opt/mystuff/myprog -x
ExecRestart=/opt/mystuff/myprog ????  // this is where I need the parameter
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes

[Install]
After=NetworkManager.service

I've spent hours and hours searching on the systemd man pages as well as on multilple Linux forums but until now, I've not been able to find the syntax to do it.

So, could anyone knowing systemd scripts explain what's the correct syntax to pass a parameter to the ExecRestart command.

TIA for your time and advice.

Cheers. Fnux.

Fnux
  • 173
  • 1
  • 8

0 Answers0