[Unit]
Description=Run Consul-template to watch instance update image notifications

[Service]
{%- if consul.tokens.wireguard is defined %}
Environment="CONSUL_HTTP_TOKEN={{ consul.tokens.wireguard }}"
{%- endif %}

Environment="CONSUL_HTTP_ADDR=https://127.0.0.1:€# lookup('env','CONSUL_HTTPS_PORT') | default(8501, true) | int #€"
Environment="CONSUL_CACERT=€# layerops_tls_ca_file #€"

TimeoutStartSec=0
ExecStart=€# local_bin_path #€/consul-template \
  -default-left-delimiter '{€' \
  -default-right-delimiter '€}' \
  -template="€# layerops_config_path #€/.image_version.json.tmpl:€# layerops_config_path #€/image_version.json"
ExecStop=/bin/kill -9 $MAINPID

Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
