all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Danny Milosavljevic <dannym@scratchpost.org>
To: 39329@debbugs.gnu.org
Cc: Danny Milosavljevic <dannym@scratchpost.org>
Subject: [bug#39329] [PATCH 1/2] Add system start-up files for guix-daemon.
Date: Tue, 28 Jan 2020 16:58:59 +0100	[thread overview]
Message-ID: <20200128155900.12137-1-dannym@scratchpost.org> (raw)
In-Reply-To: <20200128155529.12071-1-dannym@scratchpost.org>

* etc/init.d/guix-daemon.in: New file.
* nix/local.mk (etc/init.d/guix-daemon): New rule.
(nodist_sysvinitservice_DATA): Add etc/init.d/guix-daemon.in .
(CLEANFILES): Add etc/init.d/guix-daemon .
* .gitignore: Add etc/init.d/guix-daemon .
---
 .gitignore                |  1 +
 etc/init.d/guix-daemon.in | 88 +++++++++++++++++++++++++++++++++++++++
 nix/local.mk              | 16 ++++++-
 3 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 etc/init.d/guix-daemon.in

diff --git a/.gitignore b/.gitignore
index df59a9176e..de058dda5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,6 +71,7 @@
 /etc/guix-daemon.service
 /etc/guix-publish.conf
 /etc/guix-publish.service
+/etc/init.d/guix-daemon
 /guix-daemon
 /guix/config.scm
 /libformat.a
diff --git a/etc/init.d/guix-daemon.in b/etc/init.d/guix-daemon.in
new file mode 100644
index 0000000000..8974a5d215
--- /dev/null
+++ b/etc/init.d/guix-daemon.in
@@ -0,0 +1,88 @@
+#!/bin/bash
+### BEGIN INIT INFO
+# Provides:          guix-daemon
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Guix build daemon
+# Description:       Provides a daemon that does builds for Guix
+### END INIT INFO
+
+set -e
+set -o pipefail
+mkdir -p "/var/run"
+if [ ! -f "@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon" ]
+then
+  exit 5
+fi
+
+case "$1" in
+start)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pid="`cat /var/run/guix-daemon.pid`"
+    if ps www "${pid}" |grep -qa guix-daemon
+    then
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file" >&2
+      exit 1
+    fi
+  else
+    daemonize \
+      -a \
+      -e /var/log/guix-daemon-stderr.log \
+      -o /var/log/guix-daemon-stdout.log \
+      -E GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale \
+      -E LC_ALL=en_US.utf8 \
+      -p /var/run/guix-daemon.pid \
+      @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
+      --build-users-group=guixbuild
+  fi
+  ;;
+stop)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pid="`cat /var/run/guix-daemon.pid`"
+    if ps www "${pid}" |grep -qa guix-daemon
+    then
+      kill "${pid}"
+      sleep 10
+      kill -9 "${pid}" || true
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file" >&2
+      exit 1
+    fi
+  else
+    exit 0
+  fi
+  ;;
+status)
+  if [ -f "/var/run/guix-daemon.pid" ]
+  then
+    pid="`cat /var/run/guix-daemon.pid`"
+    if ps www "${pid}" |grep -qa guix-daemon
+    then
+      echo "guix-daemon is running"
+      exit 0
+    else
+      echo "guix-daemon has a stale pid file"
+      exit 1
+    fi
+  else
+    echo "guix-daemon is not running"
+    exit 3
+  fi
+  ;;
+restart)
+force-reload)
+  "$0" stop
+  "$0" start
+  ;;
+*)
+  echo "Usage: $0 (start|stop|status|restart|force-reload)"
+  exit 3
+  ;;
+esac
diff --git a/nix/local.mk b/nix/local.mk
index dc5a8398b2..a64bdd2137 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -164,6 +164,16 @@ etc/guix-%.service: etc/guix-%.service.in	\
 	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+sysvinitservicedir = $(sysconfdir)/init.d
+nodist_sysvinitservice_DATA = etc/init.d/guix-daemon
+
+etc/init.d/guix-daemon: etc/init.d/guix-daemon.in	\
+			 $(top_builddir)/config.status
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''localstatedir''@|$(localstatedir)|' <	\
+	       "$<" > "$@.tmp";		\
+	mv "$@.tmp" "$@"
+
 # The '.conf' jobs for Upstart.
 upstartjobdir = $(libdir)/upstart/system
 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -177,7 +187,8 @@ etc/guix-%.conf: etc/guix-%.conf.in	\
 
 CLEANFILES +=					\
   $(nodist_systemdservice_DATA)			\
-  $(nodist_upstartjob_DATA)
+  $(nodist_upstartjob_DATA)			\
+  $(nodist_sysvinitservice_DATA)
 
 EXTRA_DIST +=					\
   %D%/AUTHORS					\
@@ -185,7 +196,8 @@ EXTRA_DIST +=					\
   etc/guix-daemon.service.in			\
   etc/guix-daemon.conf.in			\
   etc/guix-publish.service.in			\
-  etc/guix-publish.conf.in
+  etc/guix-publish.conf.in			\
+  etc/init.d/guix-daemon.in
 
 if CAN_RUN_TESTS
 

  reply	other threads:[~2020-01-28 16:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-28 15:55 [bug#39329] [PATCH 0/2] Start guix-daemon in SysV Danny Milosavljevic
2020-01-28 15:58 ` Danny Milosavljevic [this message]
2020-01-28 15:59   ` [bug#39329] [PATCH 2/2] guix-install.sh: Install sysv init script Danny Milosavljevic
2020-01-28 16:01     ` Danny Milosavljevic
2020-01-28 16:01   ` [bug#39329] [PATCH 1/2] Add system start-up files for guix-daemon Danny Milosavljevic
2020-01-28 16:29 ` [bug#39329] [PATCH v3 0/2] Start guix-daemon on SysV Danny Milosavljevic
2020-01-28 16:29   ` [bug#39329] [PATCH v3 1/2] Add system start-up files for guix-daemon Danny Milosavljevic
2020-01-28 16:29   ` [bug#39329] [PATCH v3 2/2] guix-install.sh: Install sysv init script Danny Milosavljevic
2020-01-28 17:38 ` [bug#39329] [PATCH v4 0/2] Start guix-daemon on SysV Danny Milosavljevic
2020-01-28 17:38   ` [bug#39329] [PATCH v4 1/2] Add system start-up files for guix-daemon Danny Milosavljevic
2020-02-14  8:43     ` Ludovic Courtès
2020-01-28 17:38   ` [bug#39329] [PATCH v4 2/2] guix-install.sh: Install SysV init script Danny Milosavljevic
2020-02-14  8:44     ` Ludovic Courtès
2020-03-11  1:49   ` [bug#39329] [PATCH v4 0/2] Start guix-daemon on SysV Danny Milosavljevic
2020-04-13 17:02 ` Vincent Legoll
2020-04-13 17:46   ` bug#39329: " Leo Famulari
2020-04-13 18:08   ` [bug#39329] " Danny Milosavljevic
2020-04-13 18:21     ` Leo Famulari
2020-04-14 10:40       ` [bug#40601] " Vincent Legoll

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200128155900.12137-1-dannym@scratchpost.org \
    --to=dannym@scratchpost.org \
    --cc=39329@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.