aboutsummaryrefslogtreecommitdiff
path: root/system/haveged/rc.haveged
blob: 7f6f5e4fc270cd4884acdc03581bea6f36135580 (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
39
40
41
42
43
44
45
46
47
#!/bin/sh
# Start/stop/restart haveged.

PIDFILE=/var/run/haveged.pid
HAVEGED_OPTS="-w 1024 -v 1 -p $PIDFILE"

# Start haveged:
haveged_start() {
  if [ -f $PIDFILE ]; then
    echo "HAVEGE daemon is already running as PID $(cat  $PIDFILE) " >&2
    exit 3
  elif [ -x /usr/sbin/haveged ]; then
    echo "Starting HAVEGE daemon:  /usr/sbin/haveged"
    /usr/sbin/haveged $HAVEGED_OPTS
  fi
}

# Stop haveged:
haveged_stop() {
  if [ -r /var/run/haveged.pid ]; then
    kill $(cat /var/run/haveged.pid)
  else
    killall haveged
  fi
}

# Restart haveged:
haveged_restart() {
  haveged_stop
  sleep 1
  haveged_start
}

case "$1" in
'start')
  haveged_start
  ;;
'stop')
  haveged_stop
  ;;
'restart')
  haveged_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
  exit 2
esac