diff --git a/xCAT/postscripts/cumulusztp b/xCAT/postscripts/cumulusztp index bc4b40d9a..20534f7cc 100755 --- a/xCAT/postscripts/cumulusztp +++ b/xCAT/postscripts/cumulusztp @@ -128,6 +128,8 @@ if [ "$rc" != "0" ]; then exit 1 fi +#setup ntp +echo './setupntp' >> ./mypostscript #enable snmp echo './enablesnmp' >> ./mypostscript #config base interface diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index 9fc3cff86..841ffed10 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -40,31 +40,10 @@ pmatch () return 1 # non-zero return code means string not matched by pattern } -# is_lsb_ubuntu exit status indicates whether system appears to be Ubuntu. -# Using required /etc/lsb-release file, instead of optional lsb_release command. - -is_lsb_ubuntu () +is_lsb_cumulus () { - awk ' - (match($0, "^[ \t]*DISTRIB_ID=") == 1) { # A DISTRIB_ID line - id = substr($0, RLENGTH + 1) # Save its value - } - - END { - # Examine last DISTRIB_ID value to see if Ubuntu indicated - - if (match(id, "^(Ubuntu|\"Ubuntu\")[ \t]*$") == 1) { - exit 0 # Ubuntu - } - exit 1 # Not Ubuntu - } - - ' /etc/lsb-release >/dev/null 2>&1 - - # Routine exit status is exit status of the last command -- the awk script. - # - # Note: if /etc/lsb-release does not exist, the exit status indicates - # failure (not Ubuntu), which is the correct outcome. + grep -qs Cumulus /etc/lsb-release + return $? } logger -t xcat "Install: Setup NTP" @@ -97,6 +76,14 @@ fi OS_TYPE=`uname` if [ $OS_TYPE = Linux ]; then + # Set the timezone + if [ -n $TIMEZONE ]; then + echo $TIMEZONE > /etc/timezone + if which timedatectl > /dev/null; then + timedatectl set-timezone $(cat /etc/timezone) + fi + fi + mkdir -p /var/lib/ntp chown ntp /var/lib/ntp if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then @@ -107,40 +94,19 @@ if [ $OS_TYPE = Linux ]; then echo "disable auth" >>$conf_file echo "restrict 127.0.0.1" >>$conf_file - #ntpdate/sntp conflict with ntpd, stop the service first + if ( pmatch $OSVER "Cumulus*" ) || is_lsb_cumulus; then + # Do not listen on Cumulus switch ports + echo "interface listen eth0" >>$conf_file + fi + + #ntpd/ntpdate/sntp conflict with ntpd, stop the service first checkservicestatus ntpserver if [ $? -eq 0 ];then stopservice ntpserver fi - #ntpdate program is deprecated on SuSE - if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ]; then - if [ -f /usr/sbin/rcntpd ]; then - cmd="/usr/sbin/rcntpd ntptimeset" - elif [ -f /usr/sbin/rcntp ]; then - cmd="/usr/sbin/rcntp ntptimeset" - else - cmd="sntp -P no -r $ntp_master" - fi - echo "$cmd" - logger -t xcat "$cmd" - output=`eval $cmd 2>&1` - rc=$? - if [ "$rc" != "0" ] || (pmatch "$output" "*Time could not*");then - echo "WARNING: " - echo " $cmd failed, NTP may not be synchronized on NTP server " - echo " please wait for NTP synchronized, may take at least 15 mins" - echo " use 'ntpq -p' command (output has "*" or "+" sign) to validate the NTP server" - echo " run 'updatenode nodename -P setupntp' if NTP is synced on NTP server but nodename is not synced" - logger -t xcat "$cmd failed" - fi - else - logger -t xcat "ntpdate -t5 $master " - ntpdate -t5 $master - if [ "$?" != "0" ];then - echo " ntpdate -t5 $master failed" - logger -t xcat "ntpdate -t5 $master failed" - fi - fi + + logger -t xcat "setting current time" + ntpd -gq > /dev/null 2>&1 || ntpdate -t5 $master > /dev/null 2>&1 || echo "WARNING: NTP Sync Failed!!" #setup the hardware clock hwclock --systohc --utc