2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 03:32:04 +00:00

File /etc/sysconfig/ntpd doesn't exists in the SLES

This commit is contained in:
Casandra Qiu 2016-12-16 16:09:56 -05:00
parent 9a3f08e28e
commit 921213ea9e
2 changed files with 34 additions and 11 deletions

View File

@ -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") {

View File

@ -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