Files

56 lines
1.6 KiB
Django/Jinja

[Unit]
Description={{ container_name }} Podman Container
{% for unit in systemd_After %}
After={{ unit }}
{% endfor %}
{% for unit in systemd_Before %}
Before={{ unit }}
{% endfor %}
{% for unit in systemd_Conflicts %}
Conflicts={{ unit }}
{% endfor %}
{% for unit in systemd_Requires %}
Requires={{ unit }}
{% endfor %}
{% for unit in systemd_Wants %}
Wants={{ unit }}
{% endfor %}
[Service]
Type=simple
TimeoutStartSec={{ systemd_TimeoutStartSec }}
ExecStartPre=-/usr/bin/podman stop -t {{ container_stop_timeout|quote }} {{ container_name|quote }}
ExecStartPre=-/usr/bin/podman rm -f {{ container_name|quote }}
ExecStartPre=-/usr/bin/rm -f {{ pidfile }} {{ cidfile }}
{% if container_run_as_user == 'root' %}
User={{ container_run_as_user }}
{% endif %}
ExecStart=/usr/bin/podman run --name {{ container_name }} \
{{ container_run_args }} \
--conmon-pidfile {{ pidfile }} --cidfile {{ cidfile }} \
{{ _container_image_list | map(attribute='image') | first }} {% if container_cmd_args is defined %} \
{{ container_cmd_args }} {% endif %}
ExecStop=/usr/bin/sh -c "/usr/bin/podman stop -t "{{ container_stop_timeout }}" `cat {{ cidfile }}`"
ExecStop=/usr/bin/sh -c "/usr/bin/podman rm -f `cat {{ cidfile }}`"
Restart={{ container_restart }}
RestartSec={{ systemd_RestartSec }}
KillMode=mixed
PIDFile={{ pidfile }}
Environment=PODMAN_SYSTEMD_UNIT=%n
[Install]
{% if container_run_as_user == 'root' %}
WantedBy=multi-user.target
{% endif %}
{% if container_run_as_user != 'root' %}
WantedBy=default.target
{% endif %}
{% for unit in systemd_RequiredBy %}
RequiredBy={{ unit }}
{% endfor %}
{% for unit in systemd_WantedBy %}
WantedBy={{ unit }}
{% endfor %}