aboutsummaryrefslogtreecommitdiff
path: root/system/bit-babbler/rc.seedd.new
blob: 0843b8c2144e97a92dac1388c9e95677a8848bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
#
# /etc/rc.d/rc.seedd: start and stop BitBabbler TRNG(s).

BBOPTS="--daemon --config=/etc/bit-babbler/seedd.conf"
BBSOCKET=/run/bit-babbler/seedd.socket

seedd_start() {
  if [ -S $BBSOCKET ]; then
    echo 'seedd appears to be already running!'
    exit 1
  else
    echo 'Checking for BitBabbler...'
    /usr/bin/seedd --scan 
    echo "Starting seedd:  /usr/bin/seedd $BBOPTS"
    /usr/bin/seedd $BBOPTS 
  fi
}

seedd_stop() {
  echo 'Stopping seedd...'
  killall -w seedd
  # daemon doesn't clean up lock on termination.
  rm -f $BBSOCKET.lock
}

seedd_restart() {
  seedd_stop
  sleep 2  # ...take a breath...
  seedd_start
}

case "$1" in
    'start') seedd_start;;
  'restart') seedd_restart;;
     'stop') seedd_stop;;
          *) echo "usage $0 start|restart|stop";;
esac