aboutsummaryrefslogtreecommitdiff
path: root/efi-sync/files/rc.efi-sync.new
blob: 727c93b84a2735e7d77756055171b640e5e5e2ad (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
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
#
# Startup/shutdown script for GNU Taler's exchange.
#

# Seconds to wait for daemon to shutdown.
SHUTDOWN_WAIT=60

mkdir -p /run/efi-sync

start() {
  echo "Starting EFI Sync"

  daemon \
    --name=efi-sync \
    --pidfiles=/run/efi-sync \
    --output=/var/log/efi-sync.log \
    -- efi-sync watch
}

stop() {
  echo "Stopping EFI Sync"

  if /usr/bin/daemon --pidfiles=/run/efi-sync --name=efi-sync --running ; then
  	/usr/bin/daemon --pidfiles=/run/efi-sync --name=efi-sync --stop
  fi

  # Wait for daemon to politely shutdown.
  sleep 1
  if /usr/bin/daemon --pidfiles=/run/efi-sync --name=efi-sync --running; then
    echo "Waiting up to ${SHUTDOWN_WAIT} to stop..."

    let "count = 0"
    while /usr/bin/daemon --pidfiles=/run/efi-sync --name=efi-sync --running && [[ $count -lt 60 ]]; do
      sleep 1
      let "count = $count + 1"
    done
  fi
}

status() {
  if /usr/bin/daemon --pidfiles=/run/efi-sync --name=efi-sync --running ; then
  	/usr/bin/daemon --pidfiles=/run/efi-sync --name=efi-sync --running --verbose
  fi
}

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
status)
	status
	;;
*)
	echo $"Usage: $0 {start|stop|status}"
	exit 1
esac