Ticket #50121: chrony-netchange.in

File chrony-netchange.in, 830 bytes (added by florian@…, 9 years ago)
Line 
1#!/bin/sh
2#
3# Commands to send to chronyd when the link goes online and
4# offline respectively.
5#
6
7Online()
8{
9  test -e @PREFIX@/var/run/chrony/chronyd.online && exit 0
10  @PREFIX@/bin/chronyc << EOF
11online
12burst 5/10
13EOF
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
22Offline()
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
34Run()
35{
36case $1 in
37  online ) Online ;;
38  offline) Offline;;
39  *      ) echo "$0: unknown argument: $1"; exit 1;;
40esac
41}
42
43Run $1
44exit 0