Fix for defect 3419745: Fix Method to Determine if System is Ubuntu

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10710 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
ericagar 2011-10-06 17:45:08 +00:00
parent 5ef85a9a27
commit cede69d8d7
9 changed files with 163 additions and 40 deletions

View File

@ -4925,17 +4925,35 @@ sub osver
$ver =~ tr/\.//;
$ver =~ s/[^0-9]*([0-9]+).*/$1/;
}
elsif (-f "/etc/lsb-release")#ubuntu
elsif (-f "/etc/lsb-release") # Possibly Ubuntu
{
$os = "ubuntu";
open($relfile,"<","/etc/lsb-release");
my @text = <$relfile>;
close($relfile);
foreach (@text){
if ( $_ =~ /DISTRIB_RELEASE=(\S+)/ ) {
$ver = $1;
}
if (open($relfile,"<","/etc/lsb-release")) {
my @text = <$relfile>;
close($relfile);
chomp(@text);
my $distrib_id = '';
my $distrib_rel = '';
foreach (@text) {
if ( $_ =~ /^\s*DISTRIB_ID=(.*)$/ ) {
$distrib_id = $1; # last DISTRIB_ID value in file used
} elsif ( $_ =~ /^\s*DISTRIB_RELEASE=(.*)$/ ) {
$distrib_rel = $1; # last DISTRIB_RELEASE value in file used
}
}
if ( $distrib_id =~ /^(Ubuntu|"Ubuntu")\s*$/ ) {
$os = "ubuntu";
if ( $distrib_rel =~ /^(.*?)\s*$/ ) { # eliminate trailing blanks, if any
$distrib_rel = $1;
}
if ( $distrib_rel =~ /^"(.*?)"$/ ) { # eliminate enclosing quotes, if any
$distrib_rel = $1;
}
$ver = $distrib_rel;
}
}
}
$os = "$os" . "$ver";

View File

@ -654,12 +654,12 @@ sub setup_DHCP
${"xCAT_plugin::" . $modname . "::"}{process_request}
->($cmdref, \&xCAT::Client::handle_response);
my $distro = xCAT::Utils->osver();
my $serv = "dhcpd";
if ( $distro =~ /ubuntu.*/ ){
$serv = "dhcp3-server";
}
my $distro = xCAT::Utils->osver();
my $serv = "dhcpd";
if ( $distro =~ /ubuntu*/ ){
$serv = "dhcp3-server";
}
my $rc = xCAT::Utils->startService($serv);
if ($rc != 0)
{
@ -781,13 +781,13 @@ sub setup_DNS
system("$XCATROOT/sbin/makenamed.conf");
# turn DNS on
my $distro = xCAT::Utils->osver();
my $serv = "named";
if ( $distro =~ /ubuntu*/ ){
$serv = "bind9";
}
my $distro = xCAT::Utils->osver();
my $serv = "named";
if ( $distro =~ /ubuntu.*/ ){
$serv = "bind9";
}
my $rc = xCAT::Utils->startService($serv);
if ($rc != 0)
{

View File

@ -19,8 +19,8 @@ my $distro = xCAT::Utils->osver();
my $service="named";
# is this ubuntu ?
if ( $distro =~ /ubuntu*/ ){
$service = "bind9";
if ( $distro =~ /ubuntu.*/ ){
$service = "bind9";
}
sub handled_commands
@ -547,11 +547,11 @@ sub get_zonesdir {
sub get_conf {
my $conf="/etc/named.conf";
# is this ubuntu ?
if ( $distro =~ /ubuntu*/ ){
$conf="/etc/bind/named.conf";
}
# is this ubuntu ?
if ( $distro =~ /ubuntu.*/ ){
$conf="/etc/bind/named.conf";
}
my $sitetab = xCAT::Table->new('site');
unless ($sitetab)

View File

@ -62,8 +62,8 @@ if ( $^O ne 'aix' and -d "/etc/dhcp" ) {
my $usingipv6;
# is this ubuntu ?
if ( $distro =~ /ubuntu*/ ){
$dhcpconffile = '/etc/dhcp3/dhcpd.conf';
if ( $distro =~ /ubuntu.*/ ){
$dhcpconffile = '/etc/dhcp3/dhcpd.conf';
}
sub check_uefi_support {
@ -1402,9 +1402,9 @@ sub process_request
{
restart_dhcpd_aix();
}
elsif ( $distro =~ /ubuntu*/)
elsif ( $distro =~ /ubuntu.*/)
{
#ubuntu config
#ubuntu config
system("chmod a+r /etc/dhcp3/dhcpd.conf");
system("/etc/init.d/dhcp3-server restart");
}

View File

@ -1,5 +1,32 @@
#!/bin/sh
# 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 ()
{
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.
}
DIRECTORY=/var/named
@ -8,7 +35,7 @@ if [ -f /etc/SuSE-release ]; then
fi
FILE=/etc/named.conf
if [ -f /etc/lsb-release ]; then
if ( is_lsb_ubuntu ); then
FILE=/etc/bind/named.conf
fi

View File

@ -831,6 +831,31 @@ 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"
}
# 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
@ -942,7 +967,7 @@ sub initDB
$tz =
`grep ^ZONE /etc/sysconfig/clock|cut -d= -f 2|sed -e 's/"//g'`;
}
elsif (-f "/etc/lsb-release")
elsif ( is_lsb_ubuntu() )
{
$tz = discover_timezone_ubuntu;
}

View File

@ -146,8 +146,7 @@ fi
# start up the sshd for syncfiles postscript to do the sync work
logger -t xCAT "start up sshd"
DISTRO=`lsb_release -si`
if [ $DISTRO = "Ubuntu" ]
if [[ $OSVER == ubuntu* ]]
then
if [ ! -d /var/run/sshd ]
then

View File

@ -23,6 +23,33 @@ 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 ()
{
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.
}
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
@ -73,7 +100,7 @@ restrict 127.0.0.1" >>$conf_file
# default service for redhat/fedora
SERVICE=ntpd
echo $SERVICE
if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ] || ( pmatch $OSVER "ubuntu*" ); then
if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ] || ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ); then
SERVICE=ntp
fi

View File

@ -35,6 +35,33 @@ 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 ()
{
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.
}
config_Rsyslog_C3()
{
isReceiving=0
@ -85,7 +112,7 @@ if [ $NTYPE = service ]; then
fi
if [ "$(uname -s)" = "Linux" ]; then
if ( pmatch $OSVER "fedora*" ) || ( pmatch $OSVER "rhels5*" ) || ( pmatch $OSVER "rhel6*" ) || ( pmatch $OSVER "rhels6*" ) || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ] || ( pmatch $OSVER "ubuntu*" ); then
if ( pmatch $OSVER "fedora*" ) || ( pmatch $OSVER "rhels5*" ) || ( pmatch $OSVER "rhel6*" ) || ( pmatch $OSVER "rhels6*" ) || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ] || ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ); then
if [ -e /etc/rsyslog.conf ]; then
conf_file="/etc/rsyslog.conf"
sysconfig="/etc/sysconfig/rsyslog"
@ -207,7 +234,7 @@ else
#Ubuntu doesn't have sysconfig
# so configuring the MN to receive UDP connections here.
if ( pmatch $OSVER "ubuntu*" ); then
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ); then
egrep \('^\$UDPServerRun 514'\|'^\$ModLoad imudp'\) $conf_file > /dev/null 2>&1;
if [ $? -eq 1 ]; then
echo "\$ModLoad imudp" >> $conf_file;
@ -238,7 +265,7 @@ else
if [ $isLinux -eq 0 ]; then
echo "*.debug @$master" >> $conf_file
else
if ( pmatch $OSVER "ubuntu*" ); then
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ); then
echo "\$ModLoad imuxsock" >> $conf_file
echo "*.* @$master" >> $conf_file
else