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

NTP_USER=@NTP_USER@

# place local customizations in /etc/default/chrony
[ -r /etc/default/chrony ] && . /etc/default/chrony

################################################################################
chronyd_start() {
################################################################################
  if [ -n "$(pidof chronyd)" ]; then
    echo "chronyd seems to be already running."
  else
    echo "Starting chronyd: /usr/sbin/chronyd -u $NTP_USER $CHRONYD_ARGS"
    /usr/sbin/chronyd -u $NTP_USER $CHRONYD_ARGS
  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