From beafab9dd6b520fe82ad7e36dc430cd829bed877 Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Thu, 6 Jun 2024 14:23:41 +0200 Subject: [PATCH] Install systemd service template --- TODO | 1 - debian/kam-shipcat.postinst | 11 +++++++++++ debian/kam-shipcat.shc@.service | 20 ++++++++++++++++++++ debian/rules | 3 +++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 debian/kam-shipcat.postinst create mode 100644 debian/kam-shipcat.shc@.service diff --git a/TODO b/TODO index 1811744..7175992 100644 --- a/TODO +++ b/TODO @@ -3,5 +3,4 @@ Albireo cleanup: - prerouting rule -- shc@.service - containers diff --git a/debian/kam-shipcat.postinst b/debian/kam-shipcat.postinst new file mode 100644 index 0000000..626bb53 --- /dev/null +++ b/debian/kam-shipcat.postinst @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +# systemd reload is usually added automatically by dh_installsystemd, but our +# package provides only a template unit, which is not detected by DH. Let us do +# it manually. +if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + fi +fi diff --git a/debian/kam-shipcat.shc@.service b/debian/kam-shipcat.shc@.service new file mode 100644 index 0000000..decd960 --- /dev/null +++ b/debian/kam-shipcat.shc@.service @@ -0,0 +1,20 @@ +[Unit] +Description=Container %i (via shipcat) +Wants=network-online.target +After=network-online.target +RequiresMountsFor=/run/containers/storage + +[Service] +Type=forking +TimeoutStopSec=60 +PIDFile=%t/shc/%i.pid + +ExecStartPre=/bin/rm -f %t/shc/%i.pid +ExecStart=/usr/bin/podman start %i +ExecStop=/usr/bin/podman stop --ignore %i + +RuntimeDirectory=shc +RuntimeDirectoryPreserve=yes + +[Install] +WantedBy=default.target diff --git a/debian/rules b/debian/rules index d3dc1cc..c6a735f 100755 --- a/debian/rules +++ b/debian/rules @@ -16,3 +16,6 @@ execute_after_dh_auto_install: override_dh_fixperms: dh_fixperms --exclude usr/bin/shc + +override_dh_installsystemd: + dh_installsystemd --name shc@ shc@.service -- GitLab