buildroot/package/urandom-scripts/S01seedrng
Peter Korsgaard 11a46002ae package/urandom-scripts: move seedrng init script to S01
We want to initialize the kernel random number generator as soon as
possible, as early init scripts may also need random numbers (E.G.
syslog-ng in S01syslog-ng does).

Seedrng was presumably only using S20 because the previos urandom script
used S20, which (after som moves) dates all the way back to:

commit 8262508fc4
Author: Eric Andersen <andersen@codepoet.org>
Date:   Fri Apr 26 22:01:43 2002 +0000

    With this update, everything now works as expected.
     -Erik

Seedrng needs persistent storage, but mount -a is run before executing the
init scripts, so S01 should be as good as S20 - Atleast with the scripts in
upstream Buildroot.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
2023-09-30 21:00:43 +02:00

41 lines
1.2 KiB
Bash

#! /bin/sh
#
# Preserve the random seed between reboots. See urandom(4).
#
# This script can be called multiple times during operation (e.g. with
# "reload" argument) to refresh the seed.
# The following arguments can be added to SEEDRNG_ARGS in
# /etc/default/seedrng:
# --seed-dir=/path/to/seed/directory
# Path to the directory where the seed and the lock files are stored.
# for optimal operation, this should be a persistent, writeable
# location. Default is /var/lib/seedrng
#
# --skip-credit
# Set this to true only if you do not want seed files to actually
# credit the RNG, for example if you plan to replicate this file
# system image and do not have the wherewithal to first delete the
# contents of /var/lib/seedrng.
#
# Example:
# SEEDRNG_ARGS="--seed-dir=/data/seedrng --skip-credit"
#
DAEMON="seedrng"
SEEDRNG_ARGS=""
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
case "$1" in
start|stop|restart|reload)
# Never fail, as this isn't worth making a fuss
# over if it doesn't go as planned.
# shellcheck disable=SC2086 # we need the word splitting
seedrng $SEEDRNG_ARGS || true;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac