From: Alexander Dahl <post@lespocky.de>
To: ptxdist@pengutronix.de
Cc: Alexander Dahl <post@lespocky.de>
Subject: [ptxdist] [PATCH 2/2] haveged: Introduce bbinit startup
Date: Thu, 6 Jul 2017 13:54:45 +0200 [thread overview]
Message-ID: <1499342085-13101-3-git-send-email-post@lespocky.de> (raw)
In-Reply-To: <1499342085-13101-1-git-send-email-post@lespocky.de>
Added a startup script inspired by upstream, debian, buildroot and the
lldpd startup script already present in ptxdist. Also added the usual
ptxdist menu stuff for daemons started with bbinit method.
Signed-off-by: Alexander Dahl <post@lespocky.de>
---
projectroot/etc/init.d/haveged | 114 +++++++++++++++++++++++++++++++++++++++++
rules/haveged-bbinit.in | 9 ++++
rules/haveged.in | 14 ++++-
rules/haveged.make | 11 ++++
4 files changed, 146 insertions(+), 2 deletions(-)
create mode 100755 projectroot/etc/init.d/haveged
create mode 100644 rules/haveged-bbinit.in
diff --git a/projectroot/etc/init.d/haveged b/projectroot/etc/init.d/haveged
new file mode 100755
index 0000000..1a4fc62
--- /dev/null
+++ b/projectroot/etc/init.d/haveged
@@ -0,0 +1,114 @@
+#!/bin/sh
+
+PATH='/sbin:/usr/sbin:/bin:/usr/bin'
+DESC='haveged entropy daemon'
+NAME='haveged'
+DAEMON="/usr/sbin/$NAME"
+DAEMON_ARGS='-w 1024 -r 0 -v 1'
+PIDFILE="/var/run/${NAME}.pid"
+SCRIPTNAME="/etc/init.d/$NAME"
+
+# exit if binary is missing
+[ -x "$DAEMON" ] || exit 0
+
+is_running() {
+ start-stop-daemon -K --quiet --test --exec $DAEMON --pidfile $PIDFILE
+}
+
+do_start() {
+ is_running && return 1
+ start-stop-daemon -S --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2
+}
+
+do_stop() {
+ is_running || return 0
+ start-stop-daemon -K --quiet --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+
+ # wait up to 30 seconds until daemon stopped
+ for i in $(seq 30)
+ do
+ sleep 1
+ echo -n '.'
+ if ! is_running
+ then
+ break
+ fi
+ done
+
+ # see if it's still running
+ if is_running
+ then
+ start-stop-daemon -K --quiet --signal KILL --pidfile $PIDFILE --name $NAME
+
+ for i in $(seq 5)
+ do
+ sleep 1
+ echo -n '.'
+ if ! is_running
+ then
+ break
+ fi
+ done
+
+ if is_running
+ then
+ return 2
+ fi
+ fi
+
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC ..."
+ do_start
+ case "$?" in
+ 0|1) echo " Done." ;;
+ 2) echo " Failed." ;;
+ esac
+ ;;
+ stop)
+ echo -n "Stopping $DESC ."
+ do_stop
+ case "$?" in
+ 0|1) echo " Done." ;;
+ 2) echo " Failed." ;;
+ esac
+ ;;
+ restart)
+ echo -n "Restarting $DESC .."
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) echo " Done." ;;
+ 1) echo " Failed." ;; # Old process still running
+ *) echo " Failed." ;; # Failed to start
+ esac
+ ;;
+ *)
+ echo " Failed." # Failed to stop
+ ;;
+ esac
+ ;;
+ status)
+ if is_running
+ then
+ echo "$NAME is running with PID $(cat $PIDFILE) ..."
+ else
+ echo "$NAME is not running"
+ fi
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/rules/haveged-bbinit.in b/rules/haveged-bbinit.in
new file mode 100644
index 0000000..b6aee22
--- /dev/null
+++ b/rules/haveged-bbinit.in
@@ -0,0 +1,9 @@
+## SECTION=initmethod_bbinit
+
+config HAVEGED_BBINIT_LINK
+ string
+ depends on HAVEGED_STARTSCRIPT
+ prompt "haveged"
+ default "S21haveged"
+
+# vim: ft=kconfig noet tw=72
diff --git a/rules/haveged.in b/rules/haveged.in
index 9a8a597..f048327 100644
--- a/rules/haveged.in
+++ b/rules/haveged.in
@@ -1,7 +1,17 @@
## SECTION=networking
-config HAVEGED
+menuconfig HAVEGED
tristate
- prompt "haveged"
+ prompt "haveged "
+ select BUSYBOX_START_STOP_DAEMON if HAVEGED_STARTSCRIPT
+ select BUSYBOX_FEATURE_START_STOP_DAEMON_LONG_OPTIONS if HAVEGED_STARTSCRIPT
help
haveged is a simple entropy daemon
+
+if HAVEGED
+
+config HAVEGED_STARTSCRIPT
+ bool
+ prompt "install /etc/init.d/haveged"
+
+endif
diff --git a/rules/haveged.make b/rules/haveged.make
index b05b0f6..af5fa0b 100644
--- a/rules/haveged.make
+++ b/rules/haveged.make
@@ -63,6 +63,17 @@ $(STATEDIR)/haveged.targetinstall:
@$(call install_lib, haveged, 0, 0, 0644, libhavege)
@$(call install_copy, haveged, 0, 0, 0755, -, /usr/sbin/haveged)
+ifdef PTXCONF_INITMETHOD_BBINIT
+ifdef PTXCONF_HAVEGED_STARTSCRIPT
+ @$(call install_alternative, haveged, 0, 0, 0755, /etc/init.d/haveged)
+
+ifneq ($(call remove_quotes,$(PTXCONF_HAVEGED_BBINIT_LINK)),)
+ @$(call install_link, haveged, ../init.d/haveged, \
+ /etc/rc.d/$(PTXCONF_HAVEGED_BBINIT_LINK))
+endif
+endif
+endif
+
ifdef PTXCONF_INITMETHOD_SYSTEMD
@$(call install_copy, haveged, 0, 0, 0644, -, /usr/lib/systemd/system/haveged.service)
@$(call install_link, haveged, ../haveged.service, \
--
2.1.4
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
next prev parent reply other threads:[~2017-07-06 11:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 21:49 [ptxdist] [PATCH] haveged: add entropy daemon Robert Schwebel
2017-06-30 7:19 ` Alexander Dahl
2017-06-30 12:16 ` Michael Olbrich
2017-07-02 15:37 ` Robert Schwebel
2017-07-06 9:13 ` Alexander Dahl
2017-07-02 15:36 ` Robert Schwebel
2017-07-04 10:48 ` Alexander Dahl
2017-07-06 11:54 ` [ptxdist] [PATCH 0/2] haveged: bbinit startup and more download URLs Alexander Dahl
2017-07-06 11:54 ` [ptxdist] [PATCH 1/2] haveged: Add URL for upstream tarball archive Alexander Dahl
2017-07-06 11:54 ` Alexander Dahl [this message]
2017-06-30 8:19 ` [ptxdist] [PATCH] haveged: add entropy daemon Michael Olbrich
2017-06-30 8:32 ` Robert Schwebel
2017-07-02 15:26 ` Robert Schwebel
2017-06-30 12:12 ` Michael Olbrich
2017-07-02 15:27 ` Robert Schwebel
2017-07-02 15:35 ` [ptxdist] [PATCHv2] " Robert Schwebel
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=1499342085-13101-3-git-send-email-post@lespocky.de \
--to=post@lespocky.de \
--cc=ptxdist@pengutronix.de \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox