Diff for /loncom/debugging_tools/modify_config_files.pl between versions 1.14 and 1.19

version 1.14, 2018/10/26 21:39:44 version 1.19, 2021/03/22 21:15:53
Line 37  B<modify_config_files.pl> Line 37  B<modify_config_files.pl>
 =head1 SYNOPSIS  =head1 SYNOPSIS
   
 This script modifies /etc/my.cnf and one of: /etc/yum.conf   This script modifies /etc/my.cnf and one of: /etc/yum.conf 
 (for CentOS/Scientific Linux/RHEL >=5), /etc/apt/sources.list  (for CentOS/Scientific Linux/RHEL >=5 and <8), /etc/apt/sources.list
 (for Debian/Ubuntu), /etc/sysconfig/rhn/sources (for RHEL4),  (for Debian/Ubuntu), /etc/sysconfig/rhn/sources (for RHEL4),
 and /etc/yum.repos.d/loncapa.repo (Fedora >= 21).  and /etc/yum.repos.d/loncapa.repo (Fedora >= 21; Oracle Linux; 
   CentOS/RHEL >= 8).
   
 =head1 DESCRIPTION  =head1 DESCRIPTION
   
Line 112  if ($dist =~ /^fedora(\d+)$/) { Line 113  if ($dist =~ /^fedora(\d+)$/) {
                key     => 'gpgkey=',                 key     => 'gpgkey=',
                value   => $gpg,                 value   => $gpg,
            }],$nobackup);             }],$nobackup);
 } elsif ($dist =~ /^(rhes|centos|scientific)(\d+)$/) {  } elsif ($dist =~ /^(rhes|centos|scientific|oracle)(\d+)$/) {
     my $type = $1;      my $type = $1;
     my $ver = $2;      my $ver = $2;
     my $longver = $ver;      my $longver = $ver;
       my $nobackup;
     if ($type eq 'rhes') {      if ($type eq 'rhes') {
         if ($ver == 4) {          if ($ver == 4) {
             $longver = '4ES';              $longver = '4ES';
Line 142  if ($dist =~ /^fedora(\d+)$/) { Line 144  if ($dist =~ /^fedora(\d+)$/) {
                                  gpg => 'versions/scientific/RPM-GPG-KEY-loncapa',                                   gpg => 'versions/scientific/RPM-GPG-KEY-loncapa',
                                  gpgchk => 1,                                   gpgchk => 1,
                                },                                 },
                    oracle => {
                                title => 'Oracle Linux',
                                path => 'oracle/loncapa',
                                gpg => 'versions/oracle/RPM-GPG-KEY-loncapa',
                                gpgchk => 1,
                              },
                );                 );
     if (ref($info{$type}) eq 'HASH') {      if (ref($info{$type}) eq 'HASH') {
         if ($ver > 4) {          if ($ver > 4) {
               my $file = '/etc/yum.conf';
               if (($ver > 7) || ($type eq 'oracle')) {
                   $file = '/etc/yum.repos.d/loncapa.repo';
                   $nobackup = 1;
               }
             $yum_status =              $yum_status =
                 &update_file('/etc/yum.conf',                  &update_file($file,
                      [{section => 'loncapa-updates-basearch',                       [{section => 'loncapa-updates-basearch',
                        key     => 'name=',                         key     => 'name=',
                        value   => $info{$type}{title}.' $releasever LON-CAPA $basearch Updates',                         value   => $info{$type}{title}.' $releasever LON-CAPA $basearch Updates',
Line 171  if ($dist =~ /^fedora(\d+)$/) { Line 184  if ($dist =~ /^fedora(\d+)$/) {
                       }, {section => 'loncapa-updates-noarch',                        }, {section => 'loncapa-updates-noarch',
                           key     => 'gpgkey=',                            key     => 'gpgkey=',
                           value   => "$loninst/$info{$type}{gpg}",                            value   => "$loninst/$info{$type}{gpg}",
                       }]);                        }],$nobackup);
         } elsif (($type eq 'rhes') && ($ver == 4)) {          } elsif (($type eq 'rhes') && ($ver == 4)) {
             my %rhn = (              my %rhn = (
                         basearch => {                           basearch => { 
Line 189  if ($dist =~ /^fedora(\d+)$/) { Line 202  if ($dist =~ /^fedora(\d+)$/) {
 } elsif ($dist =~ /^(debian|ubuntu)\d+$/) {  } elsif ($dist =~ /^(debian|ubuntu)\d+$/) {
     my %apt_get_source = (      my %apt_get_source = (
                            debian5 => {                             debian5 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/debian/\s+lenny\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/debian/?\s+lenny\s+main',
                                         text   => "deb $loninst/debian/ lenny main",                                          text   => "deb $loninst/debian lenny main",
                                       },                                        },
                            ubuntu6 => {                             ubuntu6 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+dapper\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+dapper\s+main',
                                         text   => "deb $loninst/ubuntu/ dapper main",                                          text   => "deb $loninst/ubuntu dapper main",
                                       },                                        },
                            ubuntu8 => {                             ubuntu8 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+hardy\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+hardy\s+main',
                                         text   => "deb $loninst/ubuntu/ hardy main",                                          text   => "deb $loninst/ubuntu hardy main",
                                       },                                        },
                            ubuntu10 => {                             ubuntu10 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+lucid\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+lucid\s+main',
                                         text   => "deb $loninst/ubuntu/ lucid main",                                          text   => "deb $loninst/ubuntu lucid main",
                                        },                                         },
                            ubuntu12 => {                             ubuntu12 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+precise\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+precise\s+main',
                                         text   => "deb $loninst/ubuntu/ precise main",                                          text   => "deb $loninst/ubuntu precise main",
                                        },                                         },
                            ubuntu14 => {                             ubuntu14 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+trusty\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+trusty\s+main',
                                         text   => "deb $loninst/ubuntu/ trusty main",                                          text   => "deb $loninst/ubuntu trusty main",
                                        },                                         },
                            ubuntu16 => {                             ubuntu16 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+xenial\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+xenial\s+main',
                                         text   => "deb $loninst/ubuntu/ xenial main",                                          text   => "deb $loninst/ubuntu xenial main",
                                        },                                         },
                            ubuntu18 => {                             ubuntu18 => {
                                         regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/\s+bionic\s+main',                                          regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+bionic\s+main',
                                         text   => "deb $loninst/ubuntu/ bionic main",                                          text   => "deb $loninst/ubuntu bionic main",
                                          },
                              ubuntu20 => {
                                           regexp => '\s*deb\s+'.$loninst_re.'/ubuntu/?\s+focal\s+main',
                                           text   => "deb $loninst/ubuntu focal main",
                                        },                                         },
                          );                           );
     my $apt_status;      my $apt_status;
Line 227  if ($dist =~ /^fedora(\d+)$/) { Line 244  if ($dist =~ /^fedora(\d+)$/) {
     }      }
 }  }
   
   my $mysqlfile = '/etc/my.cnf';
   if ($dist =~ /^ubuntu(\d+)$/) {
       my $version = $1;
       $mysqlfile = '/etc/mysql/my.cnf';
       if ($version > 14) {
           $mysqlfile = '/etc/mysql/mysql.conf.d/mysqld.cnf';
       }
   }
   
 my $mysql_global_status =  my $mysql_global_status =
     &update_file('/etc/my.cnf',      &update_file($mysqlfile,
              [{section =>'mysqld',               [{section =>'mysqld',
                key     =>'wait_timeout=',                 key     =>'wait_timeout=',
                value   =>'31536000', }]);                 value   =>'31536000', }]);
Line 359  sub write_config_file { Line 385  sub write_config_file {
     if (! defined($structure) || ! ref($structure)) {      if (! defined($structure) || ! ref($structure)) {
         return 'Bad subroutine inputs';          return 'Bad subroutine inputs';
     }      }
     open(OUTPUT,'>'.$file) || return('Unable to open '.$file.' for writing');      open(OUTPUT,'>',$file) || return('Unable to open '.$file.' for writing');
     for (my $i=0;$i<scalar(@$structure);$i++) {      for (my $i=0;$i<scalar(@$structure);$i++) {
         my $line = $structure->[$i];          my $line = $structure->[$i];
         chomp($line);          chomp($line);
Line 502  sub update_rhn_source { Line 528  sub update_rhn_source {
     }      }
     my $result = 0;      my $result = 0;
     my $fh;      my $fh;
     if (open($fh,"<$file")) {      if (open($fh,'<',$file)) {
         my $total = 0;          my $total = 0;
         my %found;          my %found;
         foreach my $item (keys(%{$rhn_items})) {          foreach my $item (keys(%{$rhn_items})) {
Line 524  sub update_rhn_source { Line 550  sub update_rhn_source {
         }          }
         close($fh);          close($fh);
         if ($total < 2) {          if ($total < 2) {
             if (open($fh,">>$file")) {              if (open($fh,'>>',$file)) {
                 foreach my $item (keys(%{$rhn_items})) {                  foreach my $item (keys(%{$rhn_items})) {
                     unless ($found{$item}) {                      unless ($found{$item}) {
                         if (ref($rhn_items->{$item}) eq 'HASH') {                          if (ref($rhn_items->{$item}) eq 'HASH') {
Line 579  sub update_apt_source { Line 605  sub update_apt_source {
     }      }
     my $result = 0;      my $result = 0;
     my $fh;      my $fh;
     if (open($fh,"<$file")) {      if (open($fh,'<',$file)) {
         my $found = 0;          my $found = 0;
         my $pattern = $deb_row->{regexp};          my $pattern = $deb_row->{regexp};
         while(<$fh>) {          while(<$fh>) {
Line 590  sub update_apt_source { Line 616  sub update_apt_source {
         }          }
         close($fh);          close($fh);
         if (!$found) {          if (!$found) {
             if (open($fh,">>$file")) {              if (open($fh,'>>',$file)) {
                 print $fh "\n".$deb_row->{text}."\n";                  print $fh "\n".$deb_row->{text}."\n";
                 close($fh);                  close($fh);
                 $result = 1;                  $result = 1;

Removed from v.1.14  
changed lines
  Added in v.1.19


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>