Diff for /doc/install/linux/install.pl between versions 1.2 and 1.4

version 1.2, 2011/03/18 17:01:15 version 1.4, 2011/03/21 13:32:44
Line 362  sub check_mysql_running { Line 362  sub check_mysql_running {
     if ($distro =~ /^(suse|sles|debian|ubuntu)/) {      if ($distro =~ /^(suse|sles|debian|ubuntu)/) {
         $mysqldaemon = 'mysql';          $mysqldaemon = 'mysql';
     }      }
     if (open(PIPE,"/etc/init.d/$mysqldaemon status 2>&1 |")) {      if (open(PIPE,"ps -ef |grep mysqld_safe |grep -v grep 2>&1 |")) {
         my $status = <PIPE>;          my $status = <PIPE>;
         close(PIPE);          close(PIPE);
         chomp($status);          chomp($status);
         if ($status =~ /\(pid\s+\d+\)/) {          if ($status =~ /^root\s+\d+\s+/) {
             print_and_log(&mt('MySQL is running.')."\n");              print_and_log(&mt('MySQL is running.')."\n");
             return 1;              return 1;
         } else {          } else {
Line 614  sub need_download { Line 614  sub need_download {
                 if ($version eq 'current') {                  if ($version eq 'current') {
                     my @stats = stat("$rootdir/$file");                      my @stats = stat("$rootdir/$file");
                     $localcurrent = $stats[7];                      $localcurrent = $stats[7];
                     if ($localcurrent eq $stdsizes->{$production}) {                      if ($localcurrent == $stdsizes->{$production}) {
                         $needs_download = 0;                          $needs_download = 0;
                         $filetouse = $file;                          $filetouse = $file;
                     }                      }
                 } elsif ($version eq 'testing') {                  } elsif ($version eq 'testing') {
                     my @stats = stat("$rootdir/$file");                      my @stats = stat("$rootdir/$file");
                     $localtesting = $stats[7];                      $localtesting = $stats[7];
                     if ($localtesting eq $stdsizes->{$testing}) {                      if ($localtesting == $stdsizes->{$testing}) {
                         $needs_download = 0;                          $needs_download = 0;
                         $filetouse = $file;                          $filetouse = $file;
                     }                      }
Line 918  print " Line 918  print "
   
 ".&mt('The following actions are available:')."  ".&mt('The following actions are available:')."
   
 1. ".&mt('Create the www user/group.')."  ".&mt('1.')." ".&mt('Create the www user/group.')."
    ".&mt('This is the user/group ownership under which Apache child processes run.')."     ".&mt('This is the user/group ownership under which Apache child processes run.')."
    ".&mt('It also owns most directories within the /home/httpd directory.')."      ".&mt('It also owns most directories within the /home/httpd directory.')." 
    ".&mt('This directory is where most LON-CAPA files and directories are stored.')."     ".&mt('This directory is where most LON-CAPA files and directories are stored.')."
 2. ".&mt('Install the package LON-CAPA uses to authenticate users.')."  ".&mt('2.')." ".&mt('Install the package LON-CAPA uses to authenticate users.')."
 3. ".&mt('Set-up the MySQL database.')."  ".&mt('3.')." ".&mt('Set-up the MySQL database.')."
 4. ".&mt('Set-up MySQL permissions.')."  ".&mt('4.')." ".&mt('Set-up MySQL permissions.')."
 5. ".&mt('Configure Apache web server.')."  ".&mt('5.')." ".&mt('Configure Apache web server.')."
 6. ".&mt('Configure start-up of services.')."  ".&mt('6.')." ".&mt('Configure start-up of services.')."
 7. ".&mt('Check firewall settings.')."  ".&mt('7.')." ".&mt('Check firewall settings.')."
 8. ".&mt('Stop services not used by LON-CAPA,')."  ".&mt('8.')." ".&mt('Stop services not used by LON-CAPA,')."
    ".&mt('i.e., services for a print server: [_1] daemon.',"'cups'")."     ".&mt('i.e., services for a print server: [_1] daemon.',"'cups'")."
 9. ".&mt('Download LON-CAPA source code in readiness for installation.')."  ".&mt('9.')." ".&mt('Download LON-CAPA source code in readiness for installation.')."
   
 ".&mt('Typically, you will run this script only once, when you first install LON-CAPA.')."   ".&mt('Typically, you will run this script only once, when you first install LON-CAPA.')." 
   
Line 1032  foreach my $action (@actions) { Line 1032  foreach my $action (@actions) {
     $num ++;      $num ++;
     my ($yesno,$defaultrun);      my ($yesno,$defaultrun);
     if (ref($recommended) eq 'HASH') {      if (ref($recommended) eq 'HASH') {
         if (($action eq 'runlevels') || ($action eq 'services')) {          if (($action eq 'runlevels') || ($action eq 'stopsrvcs')) {
             $yesno = '[y/N]';              $yesno = '[y/N]';
             if (ref($recommended->{$action}) eq 'HASH') {              if (ref($recommended->{$action}) eq 'HASH') {
                 if (keys(%{$recommended->{$action}}) > 0) {                  if (keys(%{$recommended->{$action}}) > 0) {
Line 1065  if ($callsub{'download'}) { Line 1065  if ($callsub{'download'}) {
     if ($production && $testing) {      if ($production && $testing) {
         if ($production ne $testing) {          if ($production ne $testing) {
             print &mt('Two recent LON-CAPA releases are available: ')."\n".              print &mt('Two recent LON-CAPA releases are available: ')."\n".
                   &mt('1. A production release - version: [_1].',$production)."\n".                    &mt('1.').' '.&mt('A production release - version: [_1].',$production)."\n".
                   &mt('2. A testing release - version: [_1].',$testing)."\n\n".                    &mt('2.').' '.&mt('A testing release - version: [_1].',$testing)."\n\n".
                   &mt('Download the production release? ~[Y/n~]');                    &mt('Download the production release? ~[Y/n~]');
             if (&get_user_selection(1)) {              if (&get_user_selection(1)) {
                 $sourcetarball = $production.'tar.gz';                  $sourcetarball = 'loncapa-'.$production.'.tar.gz';
             } else {              } else {
                 print "\n".&mt('Download the testing release? ~[Y/n~]');                  print "\n".&mt('Download the testing release? ~[Y/n~]');
                 if (&get_user_selection(1)) {                  if (&get_user_selection(1)) {
                     $sourcetarball = $testing.'.tar.gz';                      $sourcetarball = 'loncapa-'.$testing.'.tar.gz';
                 }                  }
             }              }
         }          }
Line 1098  if ($callsub{'wwwuser'}) { Line 1098  if ($callsub{'wwwuser'}) {
 }  }
   
 if ($callsub{'pwauth'}) {  if ($callsub{'pwauth'}) {
     &build_and_install_mod_auth_external();      &build_and_install_mod_auth_external($instdir);
 } else {  } else {
     &print_and_log(&mt('Skipping [_1] installation.',"'pwauth'")."\n");      &print_and_log(&mt('Skipping [_1] installation.',"'pwauth'")."\n");
 }  }
Line 1167  if ($callsub{'runlevels'}) { Line 1167  if ($callsub{'runlevels'}) {
 if ($callsub{'firewall'}) {  if ($callsub{'firewall'}) {
     if ($distro =~ /^(suse|sles)/) {      if ($distro =~ /^(suse|sles)/) {
         print &mt('Use [_1].','yast')."\n";          print &mt('Use [_1].','yast')."\n";
     } elsif ($distro = /^(debian|ubuntu)/) {      } elsif ($distro =~ /^(debian|ubuntu)/) {
         print &mt('Use [_1].','ufw')."\n";          print &mt('Use [_1].','ufw')."\n";
     } else {      } else {
         print &mt('Use [_1].','setup')."\n";          print &mt('Use [_1].','setup')."\n";
Line 1381  sub kill_extra_services { Line 1381  sub kill_extra_services {
                     if ($daemon eq 'cupsd') {                      if ($daemon eq 'cupsd') {
                         $service = 'cups';                          $service = 'cups';
                     }                      }
                     if ($distro =~ /^(debian|ubuntu)$/) {                      if ($distro =~ /^(debian|ubuntu)/) {
                         &print_and_log(`/usr/sbin/sysv-rc-conf $service off`);                          &print_and_log(`/usr/sbin/sysv-rc-conf $service off`);
                     } else {                      } else {
                 &print_and_log(`chkconfig --del $service`);                  &print_and_log(`chkconfig --del $service`);
Line 1395  sub kill_extra_services { Line 1395  sub kill_extra_services {
   
 sub setup_mysql {  sub setup_mysql {
     my ($setup_mysql_permissions,$distro,$dbh,$has_pass,$has_lcdb) = @_;      my ($setup_mysql_permissions,$distro,$dbh,$has_pass,$has_lcdb) = @_;
     my $mysql_lc_command = "\n";      my @mysql_lc_commands;
     unless ($has_lcdb) {      unless ($has_lcdb) {
         $mysql_lc_command .= "CREATE DATABASE loncapa;\n";          push(@mysql_lc_commands,"CREATE DATABASE loncapa");
     }      }
     $mysql_lc_command .= <<"ENDMYSQL";      push(@mysql_lc_commands,"USE loncapa");
 USE loncapa;      push(@mysql_lc_commands,qq{
 CREATE TABLE IF NOT EXISTS metadata (title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, creationdate DATETIME, lastrevisiondate DATETIME, owner TEXT, copyright TEXT, FULLTEXT idx_title (title), FULLTEXT idx_author (author), FULLTEXT idx_subject (subject), FULLTEXT idx_url (url), FULLTEXT idx_keywords (keywords), FULLTEXT idx_version (version), FULLTEXT idx_notes (notes), FULLTEXT idx_abstract (abstract), FULLTEXT idx_mime (mime), FULLTEXT idx_language (language), FULLTEXT idx_owner (owner), FULLTEXT idx_copyright (copyright)) TYPE=MYISAM;  CREATE TABLE IF NOT EXISTS metadata (title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, creationdate DATETIME, lastrevisiondate DATETIME, owner TEXT, copyright TEXT, FULLTEXT idx_title (title), FULLTEXT idx_author (author), FULLTEXT idx_subject (subject), FULLTEXT idx_url (url), FULLTEXT idx_keywords (keywords), FULLTEXT idx_version (version), FULLTEXT idx_notes (notes), FULLTEXT idx_abstract (abstract), FULLTEXT idx_mime (mime), FULLTEXT idx_language (language), FULLTEXT idx_owner (owner), FULLTEXT idx_copyright (copyright)) TYPE=MYISAM
 EXIT  });
 ENDMYSQL  
     if ($setup_mysql_permissions) {      if ($setup_mysql_permissions) {
         &setup_mysql_permissions($dbh,$has_pass,$mysql_lc_command);          &setup_mysql_permissions($dbh,$has_pass,@mysql_lc_commands);
     } else {      } else {
         print_and_log(&mt('Skipping MySQL permissions setup.')."\n");          print_and_log(&mt('Skipping MySQL permissions setup.')."\n");
         if ($dbh) {          if ($dbh) {
             $dbh->do($mysql_lc_command);              if (@mysql_lc_commands) {
                   foreach my $lccmd (@mysql_lc_commands) { 
                       $dbh->do($lccmd) || print $dbh->errstr."\n";
                   }
               }
             print_and_log(&mt('MySQL database set up complete.')."\n");              print_and_log(&mt('MySQL database set up complete.')."\n");
         } else {          } else {
             print_and_log(&mt('Problem accessing MySQL.')."\n");              print_and_log(&mt('Problem accessing MySQL.')."\n");
Line 1418  ENDMYSQL Line 1421  ENDMYSQL
 }  }
   
 sub setup_mysql_permissions {  sub setup_mysql_permissions {
     my ($dbh,$has_pass,$mysql_lc_command) = @_;      my ($dbh,$has_pass,@mysql_lc_commands) = @_;
     my $mysqlversion = &get_mysql_version();      my $mysqlversion = &get_mysql_version();
     my $mysql_commands = <<"BLOCKONE";      my @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));");
 INSERT INTO user (Host, User, Password)  
 VALUES ('localhost','www',password('localhostkey'));  
 BLOCKONE  
     if ($mysqlversion < 4) {      if ($mysqlversion < 4) {
         $mysql_commands .= <<"BLOCKTWO";          push (@mysql_commands,"
 INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES ('localhost','loncapa','www','Y','Y','Y','Y','Y','Y','N','Y','Y','Y');  INSERT db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv) VALUES('localhost','loncapa','www','Y','Y','Y','Y','Y','Y','N','Y','Y','Y')");
 BLOCKTWO  
     } else {      } else {
         $mysql_commands .= <<"BLOCKTHREE";          push (@mysql_commands,"
 INSERT INTO db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Create_tmp_table_priv,Lock_tables_priv) VALUES ('localhost','loncapa','www','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');  INSERT db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Grant_priv,References_priv,Index_priv,Alter_priv,Create_tmp_table_priv,Lock_tables_priv) VALUES('localhost','loncapa','www','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y')");
 BLOCKTHREE  
     }      }
     $mysql_commands .= <<"END";      push(@mysql_commands,"DELETE FROM user WHERE host<>'localhost'");
 DELETE FROM user WHERE host<>'localhost';  
 END  
     if ($has_pass) {      if ($has_pass) {
         if ($dbh) {          if ($dbh) {
             $mysql_commands .= <<"END";              push(@mysql_commands,"FLUSH PRIVILEGES");
 FLUSH PRIVILEGES;              if (@mysql_commands) {
 END                  foreach my $cmd (@mysql_commands) {
             $dbh->do($mysql_commands.$mysql_lc_command);                      $dbh->do($cmd) || print $dbh->errstr."\n";
                   }
               }
               if (@mysql_lc_commands) {
                   foreach my $lccmd (@mysql_lc_commands) {
                       $dbh->do($lccmd) || print $dbh->errstr."\n";
                   }
               }
             print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1]',"'www'")."\n");              print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1]',"'www'")."\n");
         } else {          } else {
             print_and_log(&mt('Problem accessing MySQL.')."\n".              print_and_log(&mt('Problem accessing MySQL.')."\n".
Line 1470  END Line 1473  END
             }              }
         }          }
         if ($got_passwd) {          if ($got_passwd) {
             $mysql_commands .= &new_mysqlrootpasswd($newmysqlpass);              my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass);
               push(@mysql_commands,@newpass_cmds);
         } else {          } else {
             print_and_log(&mt('Failed to get MySQL root password from user input.')."\n");              print_and_log(&mt('Failed to get MySQL root password from user input.')."\n");
         }          }
         if ($dbh) {          if ($dbh) {
             $dbh->do($mysql_commands.$mysql_lc_command);              if (@mysql_commands) {
                   foreach my $cmd (@mysql_commands) {
                       $dbh->do($cmd) || print $dbh->errstr."\n";
   
                   }
               }
               if (@mysql_lc_commands) {
                   foreach my $lccmd (@mysql_lc_commands) {
                       $dbh->do($lccmd) || print $dbh->errstr."\n";
                   }
               }
             if ($got_passwd) {              if ($got_passwd) {
                 print_and_log(&mt('MySQL root password stored.')."\n".                  print_and_log(&mt('MySQL root password stored.')."\n".
                               &mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n");                                &mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n");
Line 1491  END Line 1505  END
   
 sub new_mysql_rootpasswd {  sub new_mysql_rootpasswd {
     my ($currmysqlpass) = @_;      my ($currmysqlpass) = @_;
     return <<"END";      return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')",
 SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass');              "FLUSH PRIVILEGES;");
 FLUSH PRIVILEGES;  
 END  
 }  }
   
 sub get_mysql_version {  sub get_mysql_version {
Line 1537  sub copy_httpd_conf { Line 1549  sub copy_httpd_conf {
   
 sub copy_apache2_debconf {  sub copy_apache2_debconf {
     my ($instdir) = @_;      my ($instdir) = @_;
     print_and_log(&mt('Copying loncapa [_1] config file to [_2] and pointing [_3] to it from sites-enabled.',"'apache2'","'/etc/apache2/sites-available'","']000-default symlink'")."\n");      print_and_log(&mt('Copying loncapa [_1] config file to [_2] and pointing [_3] to it from sites-enabled.',"'apache2'","'/etc/apache2/sites-available'","'000-default symlink'")."\n");
     my $apache2_enabled_dir = '/etc/apache2/sites-enabled';      my $apache2_enabled_dir = '/etc/apache2/sites-enabled';
     my $apache2_available_dir = '/etc/apache2/sites-available';      my $apache2_available_dir = '/etc/apache2/sites-available';
     if (-l "$apache2_enabled_dir/000-default") {      if (-l "$apache2_enabled_dir/000-default") {

Removed from v.1.2  
changed lines
  Added in v.1.4


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