1 | #!/bin/sh |
---|
2 | # |
---|
3 | # Commands to send to chronyd when the link goes online and |
---|
4 | # offline respectively. |
---|
5 | # |
---|
6 | |
---|
7 | Online() |
---|
8 | { |
---|
9 | test -e @PREFIX@/var/run/chrony/chronyd.online && exit 0 |
---|
10 | @PREFIX@/bin/chronyc << EOF |
---|
11 | online |
---|
12 | burst 5/10 |
---|
13 | EOF |
---|
14 | err=$? |
---|
15 | if [ $err -ne 0 ]; then |
---|
16 | logger -is -p user.err -t chrony-netchange "Error switching chronyd on." |
---|
17 | exit $err |
---|
18 | fi |
---|
19 | touch @PREFIX@/var/run/chrony/chronyd.online |
---|
20 | } |
---|
21 | |
---|
22 | Offline() |
---|
23 | { |
---|
24 | test -e @PREFIX@/var/run/chrony/chronyd.online || exit 0 |
---|
25 | @PREFIX@/bin/chronyc -m offline dump |
---|
26 | err=$? |
---|
27 | if [ $err -ne 0 ]; then |
---|
28 | logger -is -p user.err -t chrony-netchange "Error switching chronyd off." |
---|
29 | exit $err |
---|
30 | fi |
---|
31 | rm -f @PREFIX@/var/run/chrony/chronyd.online |
---|
32 | } |
---|
33 | |
---|
34 | Run() |
---|
35 | { |
---|
36 | case $1 in |
---|
37 | online ) Online ;; |
---|
38 | offline) Offline;; |
---|
39 | * ) echo "$0: unknown argument: $1"; exit 1;; |
---|
40 | esac |
---|
41 | } |
---|
42 | |
---|
43 | Run $1 |
---|
44 | exit 0 |
---|