diff options
author | Marius Bakke <mbakke@fastmail.com> | 2020-03-11 22:58:11 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2020-03-11 22:58:11 +0100 |
commit | 41c6e4f2b40f41cdbf4e8c7ade29845709f9cdf4 (patch) | |
tree | f496dcc2b11819f691cfe6063c52894f2ca76823 /etc | |
parent | 4510aeb91ce6267a14c9cead768869553b3a2279 (diff) | |
parent | 58363ee50096fd02743ff6d62ee1125fc440625f (diff) | |
download | guix-patches-41c6e4f2b40f41cdbf4e8c7ade29845709f9cdf4.tar guix-patches-41c6e4f2b40f41cdbf4e8c7ade29845709f9cdf4.tar.gz |
Merge branch 'master' into staging
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/guix-install.sh | 11 | ||||
-rw-r--r-- | etc/init.d/guix-daemon.in | 78 |
2 files changed, 89 insertions, 0 deletions
diff --git a/etc/guix-install.sh b/etc/guix-install.sh index bfd3842933..e7f4d2cd59 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -361,6 +361,17 @@ sys_enable_guix_daemon() systemctl enable guix-daemon; } && _msg "${PAS}enabled Guix daemon via systemd" ;; + sysv-init) + { mkdir -p /etc/init.d; + cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \ + /etc/init.d/guix-daemon; + chmod 775 /etc/init.d/guix-daemon; + + update-rc.d guix-daemon defaults && + update-rc.d guix-daemon enable && + service guix-daemon start; } && + _msg "${PAS}enabled Guix daemon via sysv" + ;; NA|*) _msg "${ERR}unsupported init system; run the daemon manually:" echo " ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild" diff --git a/etc/init.d/guix-daemon.in b/etc/init.d/guix-daemon.in new file mode 100644 index 0000000000..1cc49fed89 --- /dev/null +++ b/etc/init.d/guix-daemon.in @@ -0,0 +1,78 @@ +#!/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 +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 + if pgrep -F "/var/run/guix-daemon.pid" 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 + pkill -F "/var/run/guix-daemon.pid" guix-daemon || { + exit 1 + } + rm -f "/var/run/guix-daemon.pid" + exit 0 + else + exit 0 + fi + ;; +status) + if [ -f "/var/run/guix-daemon.pid" ] + then + if pgrep -F "/var/run/guix-daemon.pid" 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 |