xcat-core/xCAT/postscripts/setupntp
lissav fca5b3fcb9 fix to work for sles
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2461 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
2008-11-04 13:41:32 +00:00

92 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#
#---------------------------------------------------------------------------
# setup NTP configuration on the compute nodes
#
#---------------------------------------------------------------------------
master=$MASTER
setup=0
sitemaster=$SITEMASTER
conf_file="/etc/ntp.conf"
conf_file_org="/etc/ntp.conf.org"
conf_file_backup="/etc/ntp.conf.postbackup"
logger -t xcat "Install: Setup NTP"
# 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
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
if [[ $OSTYPE = linux* ]]; then
mkdir -p /var/lib/ntp
chown ntp /var/lib/ntp
echo "driftfile /var/lib/ntp/drift
disable auth
restrict 127.0.0.1" >>$conf_file
# default service for redhat/fedora
SERVICE=ntpd
echo $SERVICE
if [[ $OSVER = sles* ]] || [[ $OSVER = suse* ]] || [[ -f /etc/SuSE-release ]]; then
SERVICE=ntp
fi
#service ntpd restart
service $SERVICE stop
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
service $SERVICE start
chkconfig --add $SERVICE
chkconfig --level 345 $SERVICE on
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
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
exit $?