velia: Flash green or red LED after service stops

Flash red LED if service is "killed" [1] or green LED if service
"exited" [1].
Note that because of sighandler, velia exits cleanly upon SIGTERM,
therefore green LED flashes.

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#%24EXIT_CODE

Change-Id: I0389d1ad8376ca472ffb8122ada1f7ab8e7b74ef
diff --git a/package/velia/velia.service b/package/velia/velia.service
index 0cf56d3..3db8635 100644
--- a/package/velia/velia.service
+++ b/package/velia/velia.service
@@ -5,13 +5,15 @@
 
 [Service]
 Type=simple
-ExecStartPre=/bin/sh -c 'echo 0 > /sys/class/leds/status:green/brightness'
+ExecStartPre=/bin/sh -c 'for COLOUR in red green blue; do echo none > /sys/class/leds/status:${COLOUR}/trigger; echo 0 > /sys/class/leds/status:green/brightness; done'
 ExecStart=/usr/bin/veliad --log-level=4
+ExecStopPost=/bin/sh -c 'for COLOUR in red green blue; do echo 0 > /sys/class/leds/status:$COLOUR/brightness; done; [[ "$EXIT_CODE" == "exited" ]] && COLOUR="green" || COLOUR="red"; echo timer > /sys/class/leds/status:$COLOUR/trigger; echo 256 > /sys/class/leds/status:$COLOUR/brightness'
 PrivateTmp=yes
 PrivateDevices=no
 ProtectSystem=yes
 ProtectHome=yes
 Restart=always
+RestartSec=10s
 LogRateLimitIntervalSec=10
 LogRateLimitBurst=30000
 SyslogLevel=alert