Skip to content

Instantly share code, notes, and snippets.

@leonowski
Forked from nickjacob/systemd-prblm.service
Created December 8, 2020 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonowski/22d8745521d9eef7f20bb2544065d978 to your computer and use it in GitHub Desktop.
Save leonowski/22d8745521d9eef7f20bb2544065d978 to your computer and use it in GitHub Desktop.
execute arbitrary bash code/variable substitution in systemd units
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment