I'm creating a service file for a daemon, and I would like to use variables (in init scripts I used environment variables) to define some parameters for the executed scripts. For example, I would like to use 2 parameters $PARAM1 $PARAM2:
[Unit]
Description=my daemon
After=network.target
[Service]
ExecStart=/usr/local/bin/daemon1
PIDFile=/var/run/daemon1.pid
EnvironmentVariable=PARAM1=123
EnvironmentVariable=PARAM2=444
ExecStartPre=-/usr/bin/wget -O - --post-data=key1=$PARAM1&key2=$PARAM2 http://192.168.1.2/log.php
ExecStopPost=-/usr/bin/wget -O - --post-data=key1=$PARAM1 http://192.168.1.2/log.php
Type=simple
[Install]
WantedBy=multi-user.target
Needless to say, this example doesn't work. Is there something like this achievable with systemd? What kind of parametrization of exec commands is possible?
Best Answer
The directive is
Environment
, notEnvironmentVariable
.OR
Not sure, but you may need to use them inside braces
{}
: