diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index cf004dd61..b55d916bb 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -1020,44 +1020,6 @@ sub genSSHNodeHostKey } -# is_lsb_ubuntu return value indicates whether system appears to be Ubuntu. -# Using required /etc/lsb-release file, instead of optional lsb_release command. - -sub is_lsb_ubuntu -{ - if (open(my $relfile, "<", "/etc/lsb-release")) { - my @text = <$relfile>; - close($relfile); - chomp(@text); - my $distrib_id = ''; - - foreach (@text) { - if ( $_ =~ /^\s*DISTRIB_ID=(.*)$/ ) { - $distrib_id = $1; # last DISTRIB_ID value in file used - } - } - - if ( $distrib_id =~ /^(Ubuntu|"Ubuntu")\s*$/ ) { - return 1; # return "true" - } - } - - return 0; # return "false" -} - -sub is_debian -{ - if ( -e "/etc/debian_version" && -e "/etc/issue"){ - open(my $relfile, "<", "/etc/issue"); - my $line = <$relfile>; - close($relfile); - if ( $line =~ /debian.*/i ){ - return 1; - } - } - return 0; -} - sub is_redhat6sp4 { if( -e "/etc/redhat-release" ){ @@ -1072,21 +1034,6 @@ sub is_redhat6sp4 } -# on Ubuntu need to painstakingly compare /etc/localtime with files under -# /usr/share/zoneinfo since /etc/localtime # isn't always a symbolic link -sub discover_timezone_ubuntu -{ - my $localtime = "/etc/localtime"; - my $zoneinfo = "/usr/share/zoneinfo"; - - my $zone_result = `find $zoneinfo -type f -exec cmp -s $localtime {} \\; -print | grep -v posix | grep -v SystemV`; - - my @zones = split /\n/, $zone_result; - - $zones[0] =~ s/$zoneinfo\///; - - return $zones[0]; -} #----------------------------------------------------------------------------- @@ -1158,6 +1105,7 @@ sub initDB # set value based on OS my ($domain, $timezone); + my $timezone = xCAT::Utils->gettimezone(); if ($::osname eq 'AIX') { my ($name, $rest) = split('\.', $hname); @@ -1170,35 +1118,10 @@ sub initDB $domain = ""; } - $timezone = $ENV{'TZ'}; } else # linux { $domain = `hostname -d`; - my $tz; - if (-f "/etc/redhat-release") - { - - # on Redhat look for "ZONE" - $tz = - `grep ^ZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`; - } - elsif ( is_lsb_ubuntu() || is_debian() ) - { - $tz = discover_timezone_ubuntu; - if (!$tz){ - $tz = `cat /etc/timezone`; - chomp $tz; - } - } - else - { - - # on SuSE look for "TIMEZONE" - $tz = - `grep ^TIMEZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`; - } - $timezone = $tz; } chomp $timezone; @@ -1973,6 +1896,7 @@ sub setuphttp { my $cmd; + my $distro = xCAT::Utils->osver(); # restart httpd if (-e "/etc/init.d/apache2") { #for sles/ubuntu @@ -2000,8 +1924,7 @@ sub setuphttp # enable httpd if (-e "/etc/init.d/apache2") { - if (is_lsb_ubuntu() || is_debian() ) - { # for ubuntu + if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { $cmd = "/usr/sbin/update-rc.d apache2 enable"; } else @@ -2009,18 +1932,6 @@ sub setuphttp $cmd = "/sbin/chkconfig apache2 on"; } } -# elsif (-e "/sbin/chkconfig") -# { -# $cmd = "/sbin/chkconfig httpd on"; -# } -# elsif (-e "/usr/sbin/chkconfig") -# { -# $cmd = "/usr/sbin/chkconfig httpd on"; -# } -# else -# { -# $cmd = "chkconfig httpd on"; -# } else { my $CHKCONFIG = xCAT::Utils->fullpathbin("chkconfig"); @@ -2253,6 +2164,7 @@ sub setupMNinDB sub startnamedonboot { # start named on boot + my $distro = xCAT::Utils->osver(); if (xCAT::Utils->isAIX()) { #/etc/inittab @@ -2272,7 +2184,7 @@ sub startnamedonboot #chkconfig my $serv = "named"; my $cmd = "/sbin/chkconfig $serv on"; - if ( is_lsb_ubuntu() || is_debian() ){ + if ( $distro =~ /ubuntu.*/ || $distro =~ /debian.*/i) { $serv = "bind9"; $cmd = "update-rc.d $serv enable"; }