summarylogtreecommitdiffstats
path: root/10-chrony
blob: eb5fad14914864b868968738337ab8afc8dff082 (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
#!/bin/sh

INTERFACE=$1
STATUS=$2

# Make sure we're always getting the standard response strings
LANG='C'

CHRONY=$(which chronyc)

chrony_cmd() {
  echo "Chrony going $1."
  exec $CHRONY -a $1
}

nm_connected() {
  [ "$(nmcli -t --fields STATE g)" = 'connected' ]
}

case "$STATUS" in
  up)
    chrony_cmd online
  ;;
  vpn-up)
    chrony_cmd online
  ;;
  down)
    # Check for active interface, take offline if none is active
    nm_connected || chrony_cmd offline
  ;;
  vpn-down)
    # Check for active interface, take offline if none is active
    nm_connected || chrony_cmd offline
  ;;
esac