2008-05-14 16:43:41 +00:00
|
|
|
#!/bin/sh
|
2007-10-26 22:44:33 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#
|
2008-05-14 16:43:41 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# setup NTP configuration on the compute nodes
|
|
|
|
#
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
master=$MASTER
|
2008-05-28 16:38:49 +00:00
|
|
|
setup=0
|
|
|
|
sitemaster=$SITEMASTER
|
2008-05-14 16:43:41 +00:00
|
|
|
conf_file="/etc/ntp.conf"
|
2008-05-28 16:38:49 +00:00
|
|
|
conf_file_org="/etc/ntp.conf.org"
|
2008-05-14 16:43:41 +00:00
|
|
|
conf_file_backup="/etc/ntp.conf.postbackup"
|
2007-10-26 22:44:33 +00:00
|
|
|
logger -t xcat "Install: Setup NTP"
|
2008-05-28 16:38:49 +00:00
|
|
|
# if master is the sitemaster, then use the ntpservers defined in the site
|
|
|
|
# table, if they exist. If they don't exist, do not setup ntp
|
|
|
|
# else use the master which should be a service node
|
|
|
|
if [ "$master" == "$sitemaster" ]; then
|
|
|
|
if [ $NTPSERVERS ]; then
|
|
|
|
if [ ! -f $conf_file_org ]; then
|
|
|
|
mv -f $conf_file $conf_file_org
|
|
|
|
else
|
|
|
|
mv -f $conf_file $conf_file_backup
|
|
|
|
fi
|
|
|
|
for i in $(echo $NTPSERVERS | tr ',' ' ')
|
|
|
|
do
|
|
|
|
echo "server $i" >>$conf_file
|
|
|
|
master=$i
|
|
|
|
done
|
|
|
|
else
|
2010-04-06 08:17:04 +00:00
|
|
|
logger -t xcat "Install: $NTPSERVERS don't exist"
|
2008-05-28 16:38:49 +00:00
|
|
|
exit 0
|
|
|
|
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ ! -f $conf_file_org ]; then
|
|
|
|
mv -f $conf_file $conf_file_org
|
|
|
|
else
|
|
|
|
mv -f $conf_file $conf_file_backup
|
|
|
|
fi
|
|
|
|
echo "server $master" >$conf_file
|
|
|
|
|
|
|
|
fi
|
2007-10-26 22:44:33 +00:00
|
|
|
|
|
|
|
|
2008-06-13 12:22:20 +00:00
|
|
|
if [[ $OSTYPE = linux* ]]; then
|
|
|
|
mkdir -p /var/lib/ntp
|
|
|
|
chown ntp /var/lib/ntp
|
|
|
|
echo "driftfile /var/lib/ntp/drift
|
2008-06-02 16:45:22 +00:00
|
|
|
disable auth
|
2008-05-28 18:51:33 +00:00
|
|
|
restrict 127.0.0.1" >>$conf_file
|
2008-11-04 13:41:32 +00:00
|
|
|
# default service for redhat/fedora
|
|
|
|
SERVICE=ntpd
|
|
|
|
echo $SERVICE
|
|
|
|
if [[ $OSVER = sles* ]] || [[ $OSVER = suse* ]] || [[ -f /etc/SuSE-release ]]; then
|
|
|
|
SERVICE=ntp
|
|
|
|
fi
|
2008-05-27 13:33:14 +00:00
|
|
|
|
2008-05-28 16:38:49 +00:00
|
|
|
#service ntpd restart
|
2008-11-04 13:41:32 +00:00
|
|
|
service $SERVICE stop
|
2010-02-08 05:41:42 +00:00
|
|
|
#ntpdate program is deprecated on SuSE
|
|
|
|
if [[ $OSVER = sles* ]] || [[ $OSVER = suse* ]] || [[ -f /etc/SuSE-release ]]; then
|
|
|
|
logger -t xcat "ntpd -q -g"
|
|
|
|
ntpd -q -g
|
|
|
|
if [ "$?" != "0" ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo " ntpd -q -g failed"
|
|
|
|
logger -t xcat "ntpd -q -g failed"
|
|
|
|
fi
|
|
|
|
else
|
2008-06-13 12:22:20 +00:00
|
|
|
logger -t xcat "ntpdate -t5 $master "
|
|
|
|
ntpdate -t5 $master
|
|
|
|
if [ "$?" != "0" ]
|
2008-05-28 16:38:49 +00:00
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo " ntpdate -t5 $master failed"
|
2008-05-30 13:52:38 +00:00
|
|
|
logger -t xcat "ntpdate -t5 $master failed"
|
2008-06-13 12:22:20 +00:00
|
|
|
fi
|
2010-02-08 05:41:42 +00:00
|
|
|
fi
|
2008-06-13 12:22:20 +00:00
|
|
|
|
2008-11-04 13:41:32 +00:00
|
|
|
service $SERVICE start
|
2010-02-08 05:41:42 +00:00
|
|
|
chkconfig --add $SERVICE >/dev/null 2>&1
|
|
|
|
chkconfig --level 345 $SERVICE on >/dev/null 2>&1
|
2008-06-13 12:22:20 +00:00
|
|
|
else
|
|
|
|
# stop and start AIX ntp
|
|
|
|
echo "driftfile /etc/ntp.drift
|
|
|
|
tracefile /etc/ntp.trace
|
|
|
|
disable auth
|
|
|
|
broadcastclient
|
|
|
|
restrict 127.0.0.1" >>$conf_file
|
2008-05-28 16:38:49 +00:00
|
|
|
|
2008-06-13 12:22:20 +00:00
|
|
|
stopsrc -s xntpd
|
|
|
|
logger -t xcat "ntpdate -t5 $master "
|
|
|
|
ntpdate -t5 $master
|
|
|
|
if [ "$?" != "0" ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo " ntpdate -t5 $master failed "
|
|
|
|
logger -t xcat "ntpdate -t5 $master failed"
|
|
|
|
fi
|
|
|
|
startsrc -s xntpd
|
|
|
|
fi
|
2008-05-28 16:38:49 +00:00
|
|
|
exit $?
|