Blame SOURCES/ntpdate.wrapper

2b78f7
#!/bin/bash
2b78f7
2b78f7
ntpconf=/etc/ntp.conf
2b78f7
ntpstep=/etc/ntp/step-tickers
2b78f7
2b78f7
[ "$EUID" != "0" ] && exit 4
2b78f7
[ -x /usr/sbin/ntpdate ] || exit 5
2b78f7
[ -f /etc/sysconfig/ntpdate ] || exit 6
2b78f7
. /etc/sysconfig/ntpdate
2b78f7
2b78f7
[ -f $ntpstep ] && tickers=$(sed 's/#.*//' $ntpstep) || tickers=
2b78f7
2b78f7
if ! echo "$tickers" | grep -qi '[a-z0-9]' && [ -f $ntpconf ]; then
2b78f7
	# the step-tickers file doesn't specify a server,
2b78f7
	# use servers from ntp.conf instead
2b78f7
	tickers=$(awk '$1=="peer"||$1=="server"{print $2}' $ntpconf | \
2b78f7
		grep -Ev '127\.127\.[0-9]+\.[0-9]+')
2b78f7
fi
2b78f7
2b78f7
if ! echo "$tickers" | grep -qi '[a-z0-9]'; then
2b78f7
	echo "NTP server not specified in $ntpstep or $ntpconf"
2b78f7
	exit 6
2b78f7
fi
2b78f7
2b78f7
/usr/sbin/ntpdate -U ntp -s -b $OPTIONS $tickers &> /dev/null
2b78f7
RETVAL=$?
2b78f7
2b78f7
[ $RETVAL -eq 0 ] && [ "$SYNC_HWCLOCK" = "yes" ] && /sbin/hwclock --systohc
2b78f7
exit $RETVAL