chrony.initd 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/openrc-run
  2. # Copyright 1999-2007 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: /var/cvsroot/gentoo-x86/net-misc/chrony/files/chronyd.rc,v 1.8 2007/03/22 14:32:09 tove Exp $
  5. command="/usr/bin/chronyd"
  6. description="NTP daemon"
  7. pidfile="/run/chrony/chronyd.pid"
  8. depend() {
  9. need net
  10. after firewall
  11. provide ntp-client ntp-server
  12. use dns
  13. }
  14. checkconfig() {
  15. # Note that /etc/chrony/chrony.keys is *NOT* checked. This
  16. # is because the user may have specified another key
  17. # file, and we don't want to force the user to use that
  18. # exact name for the key file.
  19. if [ ! -f "${CFGFILE}" ] ; then
  20. eerror "Please create ${CFGFILE} and the"
  21. eerror "chrony key file (usually /etc/chrony/chrony.keys)"
  22. eerror "by using the"
  23. eerror ""
  24. eerror " chrony.conf.example"
  25. eerror " chrony.keys.example"
  26. eerror ""
  27. eerror "files (from the documentation directory)"
  28. eerror "as templates."
  29. return 1
  30. else
  31. # Actually, I tried it, and chrony seems to ignore the pidfile
  32. # option. I'm going to leave it here anyway, since you never
  33. # know if it might be handy
  34. _cfg_pidfile=`awk '/^ *pidfile/{print $2}' "${CFGFILE}"`
  35. if [ -n "$_cfg_pidfile" ] ; then
  36. pidfile="$_cfg_pidfile"
  37. fi
  38. fi
  39. return 0
  40. }
  41. setxtrarg() {
  42. if [ -c /dev/rtc ]; then
  43. grep -q '^rtcfile' "${CFGFILE}" && ARGS="${ARGS} -s"
  44. fi
  45. grep -q '^dumponexit$' "${CFGFILE}" && ARGS="${ARGS} -r"
  46. return 0
  47. }
  48. start() {
  49. checkconfig || return $?
  50. setxtrarg
  51. local daemon_args=
  52. if yesno "$FAST_STARTUP"; then
  53. ARGS="${ARGS} -n"
  54. daemon_args="--background"
  55. fi
  56. ebegin "Starting chronyd"
  57. start-stop-daemon $daemon_args --start --quiet \
  58. --exec "${command}" \
  59. --pidfile "${pidfile}" \
  60. -- -f "${CFGFILE}" ${ARGS}
  61. eend $? "Failed to start chronyd"
  62. }
  63. stop() {
  64. checkconfig || return $?
  65. ebegin "Stopping chronyd"
  66. start-stop-daemon --stop --quiet \
  67. --pidfile "${pidfile}"
  68. eend $? "Failed to stop chronyd"
  69. }