--- loncom/debugging_tools/modify_config_files.pl 2024/06/28 12:46:47 1.24 +++ loncom/debugging_tools/modify_config_files.pl 2024/07/08 23:46:06 1.25 @@ -2,7 +2,7 @@ # # The LearningOnline Network # -# $Id: modify_config_files.pl,v 1.24 2024/06/28 12:46:47 raeburn Exp $ +# $Id: modify_config_files.pl,v 1.25 2024/07/08 23:46:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -49,6 +49,10 @@ Linux distro/version being used. The fi /etc/sysconfig/rhn/sources (for RHEL4), or /etc/yum.repos.d/loncapa.repo (for Fedora >= 21; Oracle Linux; AlmaLinux; RockyLinux; CentOS/RHEL >= 8). +The script also modifies /home/www/.inputrc on Linux distros which have +readline 8.1 or newer, i.e., CentOS/Scientific Linux/RHEL >= 9, +Ubuntu >= 22, Debian >= 12, and Fedora >= 34. + =head1 DESCRIPTION This script will modify /etc/my.cnf, /etc/mysql/my.cnf, @@ -56,7 +60,8 @@ This script will modify /etc/my.cnf, /et /etc/mysql/mariadb.conf.d/50-server.cnf, and /etc/yum.conf, /etc/yum.repos.d/loncapa.repo, /etc/apt/sources.list, /etc/apt/sources.list.d/loncapa.list or -/etc/sysconfig/rhn/sources to ensure certain parameters are set properly. +/etc/sysconfig/rhn/sources and /home/www/.inputrc to ensure +certain parameters are set properly. The LON-CAPA yum repositories are added to /etc/yum.conf, /etc/yum.repos.d/loncapa.repo, or /etc/sysconfig/rhn/sources @@ -359,6 +364,68 @@ my $mysql_www_status = key =>'password=', value =>$loncapa_config->{'lonSqlAccess'}},]); +my $needs_inputrc_check; +if ($dist =~ /^debian(\d+)$/) { + if ($1 >= 12) { + $needs_inputrc_check = 1; + } +} elsif ($dist =~ /^ubuntu(\d+)$/) { + if ($1 >= 22) { + $needs_inputrc_check = 1; + } +} elsif ($dist =~ /^(?:redhat|oracle|alma|rocky|centos-stream)(\d+)$/) { + if ($1 >= 9) { + $needs_inputrc_check = 1; + } +} elsif ($dist =~ /^fedora(\d+)$/) { + if ($1 >= 34) { + $needs_inputrc_check = 1; + } +} + +if ($needs_inputrc_check) { + my $bash_www_cnf = '/home/www/.inputrc'; + if (!-e $bash_www_cnf) { + system("touch $bash_www_cnf"); + if (open(my $fh,'>',$bash_www_cnf)) { + print $fh "set enable-bracketed-paste off\n"; + close($fh); + } else { + warn "**** Error: could not open $bash_www_cnf to add 'set enable-bracketed-paste to off'"; + } + } else { + my ($bracketed_paste_on,$bracketed_paste_off,@preserve); + if (open(my $fh,'<',$bash_www_cnf)) { + while (my $line=<$fh>) { + chomp($line); + if ($line =~ /^\s*set\s+enable\-bracketed\-paste\s+(off|on)\s*$/) { + if ($1 eq 'off') { + $bracketed_paste_off = 1; + } else { + $bracketed_paste_on = 1; + } + } else { + push(@preserve,$line); + } + } + close($fh); + } + if ($bracketed_paste_on || !$bracketed_paste_off) { + if (open(my $fh,'>',$bash_www_cnf)) { + print $fh "set enable-bracketed-paste off\n"; + if (@preserve) { + foreach my $entry (@preserve) { + print $fh "$entry\n"; + } + } + close($fh); + } else { + warn "**** Error: could not open $bash_www_cnf to add 'set enable-bracketed-paste to off'"; + } + } + } +} + my $exitvalue = 0; if ($mysql_global_status) { $exitvalue = 1; }