summaryrefslogtreecommitdiffstats
path: root/projectroot
diff options
context:
space:
mode:
authorAlexander Dahl <post@lespocky.de>2017-07-06 13:54:45 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2017-07-17 08:56:50 +0200
commit6597a67ea5d5f9ad584aa52b70e69ceb1d216aa9 (patch)
tree52fa6f8b468685bc721238ba3f1ba09f3a0449a4 /projectroot
parenta95a80c7b2d8339ead5226e9345dddd6f80f78e0 (diff)
downloadptxdist-6597a67ea5d5f9ad584aa52b70e69ceb1d216aa9.tar.gz
ptxdist-6597a67ea5d5f9ad584aa52b70e69ceb1d216aa9.tar.xz
haveged: Introduce bbinit startup
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> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'projectroot')
-rwxr-xr-xprojectroot/etc/init.d/haveged114
1 files changed, 114 insertions, 0 deletions
diff --git a/projectroot/etc/init.d/haveged b/projectroot/etc/init.d/haveged
new file mode 100755
index 000000000..1a4fc62a2
--- /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
+
+: