Skip to content

Instantly share code, notes, and snippets.

@benhylau
Forked from nickjacob/systemd-prblm.service
Created July 25, 2017 18:53
Show Gist options
  • Save benhylau/fc90382ac73ee497a8f8ae52c5f88ab2 to your computer and use it in GitHub Desktop.
Save benhylau/fc90382ac73ee497a8f8ae52c5f88ab2 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