Skip to content

Instantly share code, notes, and snippets.

@LordFPL
Forked from nickjacob/systemd-prblm.service
Created May 9, 2016 11:12
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 LordFPL/8edee8ec3a062104468b944ef81c6ca3 to your computer and use it in GitHub Desktop.
Save LordFPL/8edee8ec3a062104468b944ef81c6ca3 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/ech "2 + 2 = ${MYVAR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment