git: d5c22b1552d6 - main - sysutils/containerd: Add rc.d script

From: Bernhard Froehlich <decke_at_FreeBSD.org>
Date: Sun, 17 Apr 2022 10:47:57 UTC
The branch main has been updated by decke:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d5c22b1552d65b9c9e291cb94e45b0ebcd8ee12c

commit d5c22b1552d65b9c9e291cb94e45b0ebcd8ee12c
Author:     Bernhard Froehlich <decke@FreeBSD.org>
AuthorDate: 2022-04-17 10:45:24 +0000
Commit:     Bernhard Froehlich <decke@FreeBSD.org>
CommitDate: 2022-04-17 10:45:24 +0000

    sysutils/containerd: Add rc.d script
    
    PR:             263236
    Submitted by:   Mateusz Kwiatkowski <kwiat3k@panic.pl> (based on)
---
 sysutils/containerd/Makefile            |  3 +++
 sysutils/containerd/files/containerd.in | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/sysutils/containerd/Makefile b/sysutils/containerd/Makefile
index bc30877121a1..9820300a8428 100644
--- a/sysutils/containerd/Makefile
+++ b/sysutils/containerd/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	containerd
 DISTVERSIONPREFIX=v
 DISTVERSION=	1.6.2
+PORTREVISION=	1
 CATEGORIES=	sysutils
 
 MAINTAINER=	decke@FreeBSD.org
@@ -18,6 +19,8 @@ GH_SUBDIR=	src/github.com/containerd/containerd
 
 CPE_VENDOR=	linuxfoundation
 
+USE_RC_SUBR=	containerd
+
 MAKE_ENV=	${GO_ENV} \
 		GOFLAGS="${GO_BUILDFLAGS}" \
 		VERSION="${DISTVERSION}"
diff --git a/sysutils/containerd/files/containerd.in b/sysutils/containerd/files/containerd.in
new file mode 100644
index 000000000000..634a3d5b6db4
--- /dev/null
+++ b/sysutils/containerd/files/containerd.in
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# PROVIDE: containerd
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+# Add the following lines to /etc/rc.conf to enable containerd:
+#
+# containerd_enable="YES"
+
+. /etc/rc.subr
+
+name="containerd"
+rcvar="containerd_enable"
+
+pidfile="/var/run/${name}.pid"
+command="/usr/sbin/daemon"
+command_args="-P ${pidfile} -r -S -t ${name} -T ${name} %%LOCALBASE%%/bin/containerd"
+
+load_rc_config $name
+: ${containerd_enable:=no}
+
+# containerd needs to execute a runtime (eg. runj)
+PATH="${PATH}:%%PREFIX%%/sbin:%%PREFIX%%/bin"
+
+run_rc_command "$1"