#!/bin/bash . `dirname $0`/functions option config standard_option /etc/ntp/ntp.conf option keys standard_option /etc/ntp/ntp.keys option pidfile reserved_option /var/run/ntp.pid option hard_sync boolean_option # not used anymore option force_sync boolean_option option sync_servers long_option option procname reserved_option ntpd option bin reserved_option /usr/sbin/ntpd option cmdline reserved_option '$bin -c $opt_config -p $pidfile -k $opt_keys' # assign values after all the options have been read function fct_end_section { if [ -z "$opt_sync_servers" ]; then valueof $opt_config server > /dev/null opt_sync_servers=$REPLY fi } # perform a forced synchronisation before starting the daemon function fct_pre_start { local driftfile valueof $opt_config driftfile > /dev/null 2>&1 ; driftfile=$REPLY if [ -n "$driftfile" -a ! -e "${driftfile%/*}" ] ; then mkdir -p ${driftfile%/*} fi if [ "$opt_force_sync" = "1" -a "$opt_sync_servers" ]; then ntpdate -u -t 2 $opt_sync_servers fi } # execute a forced resynchronisation to sync servers function do_update { if [ "$opt_sync_servers" ]; then ntpdate -t 2 -u $opt_sync_servers fi } load_config