xoxys.zigbee2mqtt/templates/etc/systemd/system/zigbee2mqtt.service.j2
Robert Kaussow 08e654ccb8
Some checks failed
ci/woodpecker/manual/lint Pipeline failed
ci/woodpecker/manual/test unknown status
ci/woodpecker/manual/docs unknown status
ci/woodpecker/manual/notify Pipeline was successful
refacor: migrate to systemd
2024-10-16 22:27:11 +02:00

56 lines
1.8 KiB
Django/Jinja

#jinja2: lstrip_blocks: True
{{ ansible_managed | comment }}
[Unit]
Description=Zigbee2mqtt
Wants=docker.service
After=docker.service
[Service]
Restart=on-failure
RestartSec=5s
EnvironmentFile=/etc/environment
ExecStop=/usr/bin/docker pull {{ zigbee2mqtt_image }}
ExecStop=/bin/sh -c '/usr/bin/docker ps | /bin/grep %p 1> /dev/null && /usr/bin/docker stop %p || true'
ExecStartPre=/bin/sh -c '/usr/bin/docker ps | /bin/grep %p 1> /dev/null && /usr/bin/docker kill %p || true'
ExecStartPre=/bin/sh -c '/usr/bin/docker ps -a | /bin/grep %p 1> /dev/null && /usr/bin/docker rm %p || true'
ExecStartPre=/usr/bin/docker pull {{ zigbee2mqtt_image }}
ExecStart=/usr/bin/docker run --rm \
--name %p \
--hostname %p \
--env-file /etc/sysconfig/zigbee2mqtt \
{% if zigbee2mqtt_network is defined and zigbee2mqtt_network %}
--network {{ zigbee2mqtt_network }} \
{% endif %}
{% for cap in zigbee2mqtt_cap_add %}
--cap-add {{ cap }} \
{% endfor %}
{% for cap in zigbee2mqtt_cap_drop %}
--cap-drop {{ cap }} \
{% endfor %}
{% for opt in zigbee2mqtt_security_opts %}
--security-opt "{{ opt }}" \
{% endfor %}
{% for volume in zigbee2mqtt_volumes %}
--mount '{{ "type=bind," if (volume.type | default(False) | lower == "bind") else "" }}src={{ volume.name }},target={{ volume.dest }}' \
{% endfor %}
{% for device in zigbee2mqtt_devices %}
--device "{{ device.src }}:{{ device.dest }}{% if device.opt is defined %}:{{ device.opt }}{% endif %}" \
{% endfor %}
{% for port in zigbee2mqtt_exposed_ports %}
--publish {{ port }} \
{% endfor %}
{% for item in inst.docker_args | default(zigbee2mqtt_docker_args) %}
{{ item }} \
{% endfor %}
--health-interval 5s \
--health-retries 5 \
--health-timeout 10s \
{{ zigbee2mqtt_image }}
[Install]
WantedBy=multi-user.target