Diff for /loncom/debugging_tools/modify_config_files.pl between versions 1.16 and 1.20

version 1.16, 2019/10/02 22:28:24 version 1.20, 2021/03/25 13:23:07
Line 202  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 240  if ($dist =~ /^fedora(\d+)$/) { Line 244  if ($dist =~ /^fedora(\d+)$/) {
     }      }
 }  }
   
 my $mysql_global_status =  my $mysqlfile = '/etc/my.cnf';
     &update_file('/etc/my.cnf',  my $mysqlconf = [{section =>'mysqld',
              [{section =>'mysqld',                    key     =>'wait_timeout=',
                key     =>'wait_timeout=',                    value   =>'31536000'}];
                value   =>'31536000', }]);  if ($dist =~ /^ubuntu(\d+)$/) {
       my $version = $1;
       $mysqlfile = '/etc/mysql/my.cnf';
       if ($version > 14) {
           $mysqlfile = '/etc/mysql/mysql.conf.d/mysqld.cnf';
           if ($version < 20) {
               push(@{$mysqlconf},
                    {section =>'mysqld',
                     key     =>'sql_mode=',
                     value   =>'"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"'});
           } else {
               push(@{$mysqlconf},
                    {section =>'mysqld',
                     key     =>'sql_mode=',
                     value   =>'"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'});
           }
       }
   }
   
   my $mysql_global_status = &update_file($mysqlfile,$mysqlconf);
   
 my $local_my_cnf = '/home/www/.my.cnf';  my $local_my_cnf = '/home/www/.my.cnf';
 if (! -e $local_my_cnf) {  if (! -e $local_my_cnf) {
Line 372  sub write_config_file { Line 395  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 515  sub update_rhn_source { Line 538  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 537  sub update_rhn_source { Line 560  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 592  sub update_apt_source { Line 615  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 603  sub update_apt_source { Line 626  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.16  
changed lines
  Added in v.1.20


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