From: Danny Milosavljevic <dannym@scratchpost.org>
To: Jan <tona_kosmicznego_smiecia@interia.pl>
Cc: guix-devel@gnu.org
Subject: Re: Install script supporting sysV init?
Date: Tue, 28 Jan 2020 16:25:22 +0100 [thread overview]
Message-ID: <20200128162522.4c493020@scratchpost.org> (raw)
In-Reply-To: <20200128155234.2ca6b419@scratchpost.org>
[-- Attachment #1.1: Type: text/plain, Size: 346 bytes --]
> (1) Try to start it twice. The second start attempt should fail and $? should reflect that
Nope, according to https://refspecs.linuxfoundation.org/LSB_2.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html the second attempt should do nothing and indicate success.
Attached a new version (moved pid file from /var/lock to /var/run ).
[-- Attachment #1.2: guix-daemon --]
[-- Type: application/octet-stream, Size: 1688 bytes --]
#!/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"
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
exit 1
fi
else
daemonize \
-a \
-e /var/log/guix-daemon-stderr.log \
-o /var/log/guix-daemon-stdout.log \
-E GUIX_LOCPATH=/var/guix/profiles/per-user/root/guix-profile/lib/locale \
-E LC_ALL=en_US.utf8 \
-p /var/run/guix-daemon.pid \
/var/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
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
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-01-28 15:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-26 22:02 Install script supporting sysV init? Jan
2020-01-26 22:38 ` Danny Milosavljevic
2020-01-27 16:09 ` Jan
2020-01-27 18:05 ` Julien Lepiller
2020-01-28 13:06 ` Jan
2020-01-28 14:52 ` Danny Milosavljevic
2020-01-28 15:25 ` Danny Milosavljevic [this message]
2020-01-28 22:54 ` Jan
2020-01-28 22:58 ` Danny Milosavljevic
2020-01-28 23:07 ` Jan
2020-01-28 23:19 ` Danny Milosavljevic
2020-01-30 14:11 ` Jan
2020-01-28 10:34 ` Ludovic Courtès
2020-02-05 19:44 ` Joshua Branson
2020-02-05 20:10 ` Jan
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200128162522.4c493020@scratchpost.org \
--to=dannym@scratchpost.org \
--cc=guix-devel@gnu.org \
--cc=tona_kosmicznego_smiecia@interia.pl \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).