From 921213ea9e474b2be89d0149bf8e670bbe2cbfc3 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 16 Dec 2016 16:09:56 -0500 Subject: [PATCH 1/5] File /etc/sysconfig/ntpd doesn't exists in the SLES --- xCAT-server/lib/xcat/plugins/makentp.pm | 24 +++++++++++++++++++----- xCAT/postscripts/setupntp | 21 +++++++++++++++------ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/makentp.pm b/xCAT-server/lib/xcat/plugins/makentp.pm index 9f404ae1c..f60a73c55 100755 --- a/xCAT-server/lib/xcat/plugins/makentp.pm +++ b/xCAT-server/lib/xcat/plugins/makentp.pm @@ -309,11 +309,15 @@ sub process_request { } } + #for sles, /var/lib/ntp/drift is a dir if (xCAT::Utils->isAIX()) { print CFGFILE "driftfile /etc/ntp.drift\n"; print CFGFILE "tracefile /etc/ntp.trace\n"; print CFGFILE "disable auth\n"; print CFGFILE "broadcastclient\n"; + } elsif ($os =~ /sles/) { + print CFGFILE "driftfile /etc/ntp.drift\n"; + print CFGFILE "disable auth\n"; } else { print CFGFILE "driftfile /var/lib/ntp/drift\n"; print CFGFILE "disable auth\n"; @@ -384,14 +388,20 @@ sub process_request { #setup the RTC is UTC format, which will be used by os if ($os =~ /sles/) { - `sed -i 's/.*HWCLOCK.*/HWCLOCK="-u"/' /etc/sysconfig/clock`; + $grep_cmd = "grep -i HWCLOCK /etc/sysconfig/clock"; + $rc = xCAT::Utils->runcmd($grep_cmd, 0); + if ($::RUNCMD_RC == 0) { + `sed -i 's/.*HWCLOCK.*/HWCLOCK=\"-u\"/' /etc/sysconfig/clock`; + } else { + `echo HWCLOCK=\"-u\" >> /etc/sysconfig/clock`; + } } elsif (-f "/etc/debian_version") { `sed -i "s/.*UTC.*/UTC=yes/" /etc/default/rcS`; } else { if (-f "/etc/sysconfig/clock") { $grep_cmd = "grep -i utc /etc/sysconfig/clock"; $rc = xCAT::Utils->runcmd($grep_cmd, 0); - if ($::RUNCMD_RC != 0) { + if ($::RUNCMD_RC == 0) { `sed -i 's/.*UTC.*/UTC=yes/' /etc/sysconfig/clock`; } else { `echo "UTC=yes" >> /etc/sysconfig/clock`; @@ -406,11 +416,15 @@ sub process_request { if (-f "/etc/sysconfig/ntpd") { $grep_cmd = "grep -i SYNC_HWCLOCK /etc/sysconfig/ntpd"; $rc = xCAT::Utils->runcmd($grep_cmd, 0); - if ($::RUNCMD_RC != 0) { - `sed -i "s/.*SYNC_HWCLOCK.*/SYNC_HWCLOCK=yes/" /etc/sysconfig/ntpd`; + if ($::RUNCMD_RC == 0) { + `sed -i 's/.*SYNC_HWCLOCK.*/SYNC_HWCLOCK=\"yes\"/' /etc/sysconfig/ntpd`; } else { - `echo "SYNC_HWCLOCK=yes" >> /etc/sysconfig/ntpd`; + `echo SYNC_HWCLOCK=\"yes\" >> /etc/sysconfig/ntpd`; } + } elsif (-f "/etc/sysconfig/ntp") { + `sed -i "s/.*SYNC_HWCLOCK.*/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP=yes/" /etc/sysconfig/ntp`; + `sed -i "s/^NTPD_FORCE_SYNC_ON.*/NTPD_FORCE_SYNC_ON_STARTUP=yes/" /etc/sysconfig/ntp`; + `sed -i "s/.*RUN_CHROOTED.*/NTPD_RUN_CHROOTED=yes/" /etc/sysconfig/ntp`; } else { my $cron_file = "/etc/cron.daily/xcatsethwclock"; if (!-f "$cron_file") { diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index b45372705..8e6c71e9c 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -99,9 +99,13 @@ OS_TYPE=`uname` if [ $OS_TYPE = 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 + if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then + echo "driftfile /etc/ntp.drift" >>$conf_file + else + echo "driftfile /var/lib/ntp/drift" >>$conf_file + fi + echo "disable auth" >>$conf_file + echo "restrict 127.0.0.1" >>$conf_file #ntpdate/sntp conflict with ntpd, stop the service first checkservicestatus ntpserver @@ -140,7 +144,12 @@ restrict 127.0.0.1" >>$conf_file #setup the RTC is UTC format, which will be used by os if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then - sed -i 's/.*HWCLOCK.*/HWCLOCK="-u"/' /etc/sysconfig/clock + grep -i "HWCLOCK" /etc/sysconfig/clock + if [ $? -eq 0 ];then + sed -i 's/.*HWCLOCK.*/HWCLOCK=\"-u\"/' /etc/sysconfig/clock + else + echo "HWCLOCK=\"-u\"" >> /etc/sysconfig/clock + fi elif [ -f "/etc/debian_version" ];then sed -i 's/.*UTC.*/UTC=yes/' /etc/default/rcS else @@ -160,9 +169,9 @@ restrict 127.0.0.1" >>$conf_file if [ -f "/etc/sysconfig/ntpd" ];then grep -i "SYNC_HWCLOCK" /etc/sysconfig/ntpd if [ $? -eq 0 ];then - sed -i 's/.*SYNC_HWCLOCK.*/SYNC_HWCLOCK=yes/' /etc/sysconfig/ntpd + sed -i 's/.*SYNC_HWCLOCK.*/SYNC_HWCLOCK=\"yes\"/' /etc/sysconfig/ntpd else - echo "SYNC_HWCLOCK=yes" >> /etc/sysconfig/ntpd + echo "SYNC_HWCLOCK=\"yes\"" >> /etc/sysconfig/ntpd fi elif [ -f /etc/sysconfig/ntp ];then grep -i "NTPD_FORCE_SYNC_ON_STARTUP" /etc/sysconfig/ntp From f08b804e7490f6d238f8fd744c25df99fc4f0a9c Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 16 Dec 2016 16:44:21 -0500 Subject: [PATCH 2/5] modifed --- xCAT-server/lib/xcat/plugins/makentp.pm | 15 ++++++++------- xCAT/postscripts/setupntp | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/makentp.pm b/xCAT-server/lib/xcat/plugins/makentp.pm index f60a73c55..91afe08f8 100755 --- a/xCAT-server/lib/xcat/plugins/makentp.pm +++ b/xCAT-server/lib/xcat/plugins/makentp.pm @@ -309,6 +309,8 @@ sub process_request { } } + my $os = xCAT::Utils->osver("all"); + #for sles, /var/lib/ntp/drift is a dir if (xCAT::Utils->isAIX()) { print CFGFILE "driftfile /etc/ntp.drift\n"; @@ -329,7 +331,6 @@ sub process_request { close CFGFILE; - my $os = xCAT::Utils->osver("all"); my $ntp_service = "ntpserver"; #stop ntpd @@ -396,15 +397,15 @@ sub process_request { `echo HWCLOCK=\"-u\" >> /etc/sysconfig/clock`; } } elsif (-f "/etc/debian_version") { - `sed -i "s/.*UTC.*/UTC=yes/" /etc/default/rcS`; + `sed -i 's/.*UTC.*/UTC=\"yes\"/' /etc/default/rcS`; } else { if (-f "/etc/sysconfig/clock") { $grep_cmd = "grep -i utc /etc/sysconfig/clock"; $rc = xCAT::Utils->runcmd($grep_cmd, 0); if ($::RUNCMD_RC == 0) { - `sed -i 's/.*UTC.*/UTC=yes/' /etc/sysconfig/clock`; + `sed -i 's/.*UTC.*/UTC=\"yes\"/' /etc/sysconfig/clock`; } else { - `echo "UTC=yes" >> /etc/sysconfig/clock`; + `echo UTC=\"yes\" >> /etc/sysconfig/clock`; } } else { `type -P timedatectl >/dev/null 2>&1`; @@ -422,9 +423,9 @@ sub process_request { `echo SYNC_HWCLOCK=\"yes\" >> /etc/sysconfig/ntpd`; } } elsif (-f "/etc/sysconfig/ntp") { - `sed -i "s/.*SYNC_HWCLOCK.*/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP=yes/" /etc/sysconfig/ntp`; - `sed -i "s/^NTPD_FORCE_SYNC_ON.*/NTPD_FORCE_SYNC_ON_STARTUP=yes/" /etc/sysconfig/ntp`; - `sed -i "s/.*RUN_CHROOTED.*/NTPD_RUN_CHROOTED=yes/" /etc/sysconfig/ntp`; + `sed -i 's/.*SYNC_HWCLOCK.*/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP=\"yes\"/' /etc/sysconfig/ntp`; + `sed -i 's/^NTPD_FORCE_SYNC_ON.*/NTPD_FORCE_SYNC_ON_STARTUP=\"yes\"/' /etc/sysconfig/ntp`; + `sed -i 's/.*RUN_CHROOTED.*/NTPD_RUN_CHROOTED=\"yes\"/' /etc/sysconfig/ntp`; } else { my $cron_file = "/etc/cron.daily/xcatsethwclock"; if (!-f "$cron_file") { diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index 8e6c71e9c..f2a95994e 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -148,17 +148,17 @@ if [ $OS_TYPE = Linux ]; then if [ $? -eq 0 ];then sed -i 's/.*HWCLOCK.*/HWCLOCK=\"-u\"/' /etc/sysconfig/clock else - echo "HWCLOCK=\"-u\"" >> /etc/sysconfig/clock + echo HWCLOCK=\"-u\" >> /etc/sysconfig/clock fi elif [ -f "/etc/debian_version" ];then - sed -i 's/.*UTC.*/UTC=yes/' /etc/default/rcS + sed -i 's/.*UTC.*/UTC=\"yes\"/' /etc/default/rcS else if [ -f "/etc/sysconfig/clock" ];then grep -i "utc" /etc/sysconfig/clock if [ $? -eq 0 ];then - sed -i 's/.*UTC.*/UTC=yes/' /etc/sysconfig/clock + sed -i 's/.*UTC.*/UTC=\"yes\"/' /etc/sysconfig/clock else - echo "UTC=yes" >> /etc/sysconfig/clock + echo UTC=\"yes\" >> /etc/sysconfig/clock fi elif type -P timedatectl >/dev/null 2>&1 ;then timedatectl set-local-rtc 0 @@ -176,11 +176,11 @@ if [ $OS_TYPE = Linux ]; then elif [ -f /etc/sysconfig/ntp ];then grep -i "NTPD_FORCE_SYNC_ON_STARTUP" /etc/sysconfig/ntp if [ $? -eq 0 ];then - sed -i 's/NTPD_FORCE_SYNC_ON_STARTUP="no"/NTPD_FORCE_SYNC_ON_STARTUP="yes"/' /etc/sysconfig/ntp + sed -i 's/NTPD_FORCE_SYNC_ON_STARTUP=\"no\"/NTPD_FORCE_SYNC_ON_STARTUP=\"yes\"/' /etc/sysconfig/ntp fi grep -i "NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP" /etc/sysconfig/ntp if [ $? -eq 0 ];then - sed -i 's/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP="no"/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP="yes"/' /etc/sysconfig/ntp + sed -i 's/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP=\"no\"/NTPD_FORCE_SYNC_HWCLOCK_ON_STARTUP=\"yes\"/' /etc/sysconfig/ntp fi else cron_file="/etc/cron.daily/xcatsethwclock" From 179f8211e373c0fb028dadc5f940cf97b880b826 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 3 Jan 2017 14:50:00 -0500 Subject: [PATCH 3/5] change drift file to /var/lib/ntp/drift/ntp.drift --- xCAT-server/lib/xcat/plugins/makentp.pm | 2 +- xCAT/postscripts/setupntp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/makentp.pm b/xCAT-server/lib/xcat/plugins/makentp.pm index 91afe08f8..7d7466f8b 100755 --- a/xCAT-server/lib/xcat/plugins/makentp.pm +++ b/xCAT-server/lib/xcat/plugins/makentp.pm @@ -318,7 +318,7 @@ sub process_request { print CFGFILE "disable auth\n"; print CFGFILE "broadcastclient\n"; } elsif ($os =~ /sles/) { - print CFGFILE "driftfile /etc/ntp.drift\n"; + print CFGFILE "driftfile /var/lib/ntp/drift/ntp.drift\n"; print CFGFILE "disable auth\n"; } else { print CFGFILE "driftfile /var/lib/ntp/drift\n"; diff --git a/xCAT/postscripts/setupntp b/xCAT/postscripts/setupntp index f2a95994e..882a6161a 100755 --- a/xCAT/postscripts/setupntp +++ b/xCAT/postscripts/setupntp @@ -100,7 +100,7 @@ if [ $OS_TYPE = Linux ]; then mkdir -p /var/lib/ntp chown ntp /var/lib/ntp if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ];then - echo "driftfile /etc/ntp.drift" >>$conf_file + echo "driftfile /var/lib/ntp/drift/ntp.drift" >>$conf_file else echo "driftfile /var/lib/ntp/drift" >>$conf_file fi From 9c1d637829df29f81df26db14493de83935ecf41 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 10 Jan 2017 09:45:06 -0500 Subject: [PATCH 4/5] Fix the issue with restoring the Release file because at the end of the buildcore.sh script, the CWD is not the git repo. Use full path Add the Release.save* file into the .gitignore in order to not track this temporary file during the build --- .gitignore | 2 ++ buildcore.sh | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index e5d06cdf0..893951706 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # ignore the documentation build files docs/build +# Ignore the temporary file for creating the Release version +Release.save* diff --git a/buildcore.sh b/buildcore.sh index 9ea023521..bff025def 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -35,6 +35,9 @@ # The following environment variables can be modified if you need # +SCRIPT=$(readlink -f $0) +SCRIPTPATH=`dirname $SCRIPT` + UPLOADUSER=litingt USER=xcat SERVER=xcat.org @@ -190,7 +193,7 @@ function setversionvars { echo "$XCAT_RELEASE" >Release } -RELEASE_FILE="Release" +RELEASE_FILE="${SCRIPTPATH}/Release" RELEASE_FILE_SAVE="${RELEASE_FILE}.save.998" function internal_backup() @@ -240,7 +243,6 @@ else echo "Error: Could not determine rpmbuild's root directory." exit 2 fi - #echo "source=$source" fi # From e090a4e9a155cec980489679486cd931f6204a0c Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 10 Jan 2017 11:30:33 -0500 Subject: [PATCH 5/5] Remove the error checking in buildcore.sh. In our autobuild environment, the build does a new git clone each time, so it's no longer necessary. Keep the warning message --- buildcore.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/buildcore.sh b/buildcore.sh index bff025def..77b44068b 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -255,20 +255,15 @@ if [ "$GIT" = "1" ]; then # To enable local sandbox build, GITPULL is disabled by default. # if [ "$GITPULL" = "1" ] || [ ${PWD} == *"autobuild"* ]; then - # TODO: This is really not necessary since the autobuild scripts - # are building the xcat code in a new directory each time + # Do some checking for modified files MODIFIED_FILES=`git ls-files --modified | tr '\n' ', '` if [ $MODIFIED_FILES ]; then - echo "The following files have been modified in the local repository: $MODIFIED_FILES..." - echo "Not a clean build, aborting..." - exit 3 + echo "WARNING: The following files have been modified in the local repository: $MODIFIED_FILES..." fi - # check if there's any modifications to git current repo + # Do some checking for untracked files UNTRACKED_FILES=`git ls-files --others | tr '\n' ', '` if [ -n "$UNTRACKED_FILES" ]; then - echo "The following files are not tracked in git: $UNTRACKED_FILES..." - echo "Not a clean build, aborting..." - exit 3 + echo "WARNING: The following files are not tracked in git: $UNTRACKED_FILES..." fi if [ -z "$GITUP" ]; then if [ ! -z "$COMMITID" ]; then