summaryrefslogtreecommitdiffstats
path: root/network/chrony/rc.chrony
blob: fc74d34ae251392f7afd3829db0317fb037dada6 (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
#!/bin/sh

################################################################################
chronyd_start() {
################################################################################
  if [ -n "$(pidof chronyd)" ]; then
    echo "chronyd seems to be already running."
  else
    echo "Starting chronyd:  /usr/sbin/chronyd -u @NTP_USER@"
    /usr/sbin/chronyd -u @NTP_USER@
  fi
}

################################################################################
chronyd_stop() {
################################################################################
  if [ -z "$(pidof chronyd)" ]; then
    echo "chronyd does not seem to be running."
  else
    echo "Stopping chronyd..."
    kill $(cat /var/run/chrony/chronyd.pid)
  fi
}

################################################################################
chronyd_restart() {
################################################################################
  if [ -n "$(pidof chronyd)" ]; then
    chronyd_stop
    sleep 1
  fi

  chronyd_start
}

case "$1" in
  'start')
    chronyd_start ;;
  'stop')
    chronyd_stop ;;
  'restart')
    chronyd_restart ;;
  *)
    echo "usage: $0 start|stop|restart" ;;
esac