Hacker News new | ask | show | jobs
by jjgreen 16 days ago
key-value pairs where the = cannot be surrounded by spaces, so I have to write

  [Service]
  Type=oneshot
  WorkingDirectory={{ home }}/current/
  Environment=RAILS_ENV=production
  ExecStart=/bin/sh -lc "bin/db-backup --verbose"
which fills me with sadness
2 comments

Whitespace immediately before or after the equals sign is completely ignored by the parser. Its the standard INI format.
What? You absolutely can have spaces; most of mine look more like

  [Service]
  Type             = oneshot
  WorkingDirectory = %h/current/
  Environment      = RAILS_ENV=production
  ExecStart        = /bin/sh -lc "bin/db-backup --verbose"
Friend, you have changed my life
Is this one of those cases where at one point you had an error in the file and you figured it was down to spaces? You fixed that issue, it still didn't work but from that point you never thought to question the assumption.

I find myself doing this sort of thing all the time..

Somewhere in my head I had that spaces caused a syntax error, and the UI for systemd is not obvious when you first start using it ... so if it's working then leave well alone. I'll be making all of my .service files (not so many) human-readable in the near future!
That was (cough still is) ddclient for me.
My epiphany a month ago was that I can use

   Environment = MULTIPLE=environment VARIABLES="in single line"
Just remember: never use Environment= for secrets, since they are visible to all users on the system.

(Use EnvironmentFile= instead)