Forráskód Böngészése

contrib/init: add daemon config for darkwikid

ghassmo 4 éve
szülő
commit
11623335eb
2 módosított fájl, 36 hozzáadás és 0 törlés
  1. 1 0
      contrib/init/wikid.confd
  2. 35 0
      contrib/init/wikid.initd

+ 1 - 0
contrib/init/wikid.confd

@@ -0,0 +1 @@
+USER="wiki"

+ 35 - 0
contrib/init/wikid.initd

@@ -0,0 +1,35 @@
+#!/sbin/openrc-run
+# Copyright 1999-2022 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+	use net
+}
+
+start() {
+	PWHOME="$(getent passwd $USER | awk -F: '{ print $6 }')"
+
+	ebegin "Starting darkwikid"
+	env TERM="xterm" \
+		start-stop-daemon \
+			--start \
+			--make-pidfile \
+			--pidfile /var/run/darkwikid.pid \
+			--background \
+			--user $USER \
+			--env HOME="${PWHOME:-/home/$USER}" \
+			--name darkwikid \
+			--exec /usr/bin/screen -- -D -m -S darkwikid /usr/local/bin/darkwikid
+	eend $?
+}
+
+stop() {
+	ebegin "Stopping darkwikid"
+	# Because we've daemonized with screen, we need to replace the PID file
+	# with the real PID of the program
+	pgrep -P $(cat /var/run/darkwikid.pid) > /var/run/darkwikid.pid
+
+	start-stop-daemon --stop --signal 15 \
+		--pidfile /var/run/darkwikid.pid
+	eend $?
+}