[Unit]
Description={{ container_name }} Podman Container
After=network.target

[Service]
Type=simple
TimeoutStartSec={{ systemd_TimeoutStartSec }}
ExecStartPre=-/usr/bin/rm -f {{ pidfile }} {{ cidfile }}
User={{ container_run_as_user }}

ExecStart=/usr/bin/podman run --name {{ container_name }} \
  {{ container_run_args }} \
  --conmon-pidfile  {{ pidfile }} --cidfile {{ cidfile }} \
  {{ container_image }} {% 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=none
PIDFile={{ pidfile }}

[Install]
WantedBy=multi-user.target
