Maurizio4pastebin

OpenRC /usr/local/etc/init.d/ntp-client for TrueOS

Oct 19th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.87 KB | None | 0 0
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2013 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # Source: http://data.gpo.zugaina.org/gentoo/net-misc/ntp/files/ntp-client.rc
  5.  
  6. description="Set the date and time via NTP"
  7.  
  8. depend() {
  9.     before cron
  10.     after net
  11.     use dns logger
  12. }
  13.  
  14. checkconfig() {
  15.     if ! type "${NTPCLIENT_CMD}" >/dev/null 2>&1 ; then
  16.         eerror "Please edit /usr/local/etc/conf.d/ntp-client"
  17.         eerror "Unable to locate the client command ${NTPCLIENT_CMD}!"
  18.         return 1
  19.     fi
  20.     if [ -z "${NTPCLIENT_OPTS}" ] ; then
  21.         eerror "Please edit /usr/local/etc/conf.d/ntp-client"
  22.         eerror "I need to know what server/options to use!"
  23.         return 1
  24.     fi
  25.     return 0
  26. }
  27.  
  28. start() {
  29.     checkconfig || return $?
  30.  
  31.     ebegin "Setting clock via the NTP client '${NTPCLIENT_CMD}'"
  32.     "${NTPCLIENT_CMD}" ${NTPCLIENT_OPTS}
  33.     eend $? "Failed to set clock"
  34. }
Add Comment
Please, Sign In to add comment