1
0

urandom_seed 398 B

1234567891011121314151617181920
  1. #!/bin/sh
  2. set -e
  3. trap '[ "$?" -eq 0 ] || echo "An error occured" >&2' EXIT
  4. save() {
  5. touch "$1.tmp"
  6. chown root:root "$1.tmp"
  7. chmod 600 "$1.tmp"
  8. getrandom 512 > "$1.tmp"
  9. mv "$1.tmp" "$1"
  10. echo "Seed saved ($1)"
  11. }
  12. SEED="$(uci -q get system.@system[0].urandom_seed || true)"
  13. [ "${SEED:0:1}" == "/" ] && save "$SEED"
  14. SEED=/etc/urandom.seed
  15. [ ! -f $SEED ] && save "$SEED"
  16. true