#!/bin/sh /etc/rc.common
# Copyright (C) 2011-2014 OpenWrt.org

START=98

RNGD_FILLWATER=$(uci -q get system.@rngd[0].fill_watermark)
RNGD_DEVICE=$(uci -q get system.@rngd[0].device)
RNGD_ENABLED=$(uci -q get system.@rngd[0].enabled)
RNGD_PRECMD=$(uci -q get system.@rngd[0].precmd)

: ${RNGD_FILLWATER:=4000}

echo PRECMD=\'$RNGD_PRECMD\'

start() {
    [ 1 -eq "$RNGD_ENABLED" ] && {
      [ -z "${RNGD_PRECMD}" ] || ${RNGD_PRECMD} ${RNGD_DEVICE}
      service_start /sbin/rngd -r ${RNGD_DEVICE} -W ${RNGD_FILLWATER}
    }
}

stop() {
	service_stop /sbin/rngd
}
