--- doc/install/linux/install.pl 2011/03/18 17:53:34 1.3 +++ doc/install/linux/install.pl 2011/03/21 13:32:44 1.4 @@ -72,7 +72,7 @@ if (!open(LOG,">>loncapa_install.log")) &mt('Stopping execution.')."\n"; exit; } else { - print LOG '$Id: install.pl,v 1.3 2011/03/18 17:53:34 raeburn Exp $'."\n"; + print LOG '$Id: install.pl,v 1.4 2011/03/21 13:32:44 raeburn Exp $'."\n"; } # @@ -362,11 +362,11 @@ sub check_mysql_running { if ($distro =~ /^(suse|sles|debian|ubuntu)/) { $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 = ; close(PIPE); chomp($status); - if ($status =~ /\(pid\s+\d+\)/) { + if ($status =~ /^root\s+\d+\s+/) { print_and_log(&mt('MySQL is running.')."\n"); return 1; } else { @@ -614,14 +614,14 @@ sub need_download { if ($version eq 'current') { my @stats = stat("$rootdir/$file"); $localcurrent = $stats[7]; - if ($localcurrent eq $stdsizes->{$production}) { + if ($localcurrent == $stdsizes->{$production}) { $needs_download = 0; $filetouse = $file; } } elsif ($version eq 'testing') { my @stats = stat("$rootdir/$file"); $localtesting = $stats[7]; - if ($localtesting eq $stdsizes->{$testing}) { + if ($localtesting == $stdsizes->{$testing}) { $needs_download = 0; $filetouse = $file; } @@ -918,19 +918,19 @@ print " ".&mt('The following actions are available:')." -&mt('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('It also owns most directories within the /home/httpd directory.')." ".&mt('This directory is where most LON-CAPA files and directories are stored.')." -&mt('2.')." ".&mt('Install the package LON-CAPA uses to authenticate users.')." -&mt('3.')." ".&mt('Set-up the MySQL database.')." -&mt('4.')." ".&mt('Set-up MySQL permissions.')." -&mt('5.')." ".&mt('Configure Apache web server.')." -&mt('6.')." ".&mt('Configure start-up of services.')." -&mt('7.')." ".&mt('Check firewall settings.')." -&mt('8.')." ".&mt('Stop services not used by LON-CAPA,')." +".&mt('2.')." ".&mt('Install the package LON-CAPA uses to authenticate users.')." +".&mt('3.')." ".&mt('Set-up the MySQL database.')." +".&mt('4.')." ".&mt('Set-up MySQL permissions.')." +".&mt('5.')." ".&mt('Configure Apache web server.')." +".&mt('6.')." ".&mt('Configure start-up of services.')." +".&mt('7.')." ".&mt('Check firewall settings.')." +".&mt('8.')." ".&mt('Stop services not used by LON-CAPA,')." ".&mt('i.e., services for a print server: [_1] daemon.',"'cups'")." -&mt('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.')." @@ -1032,7 +1032,7 @@ foreach my $action (@actions) { $num ++; my ($yesno,$defaultrun); if (ref($recommended) eq 'HASH') { - if (($action eq 'runlevels') || ($action eq 'services')) { + if (($action eq 'runlevels') || ($action eq 'stopsrvcs')) { $yesno = '[y/N]'; if (ref($recommended->{$action}) eq 'HASH') { if (keys(%{$recommended->{$action}}) > 0) { @@ -1069,11 +1069,11 @@ if ($callsub{'download'}) { &mt('2.').' '.&mt('A testing release - version: [_1].',$testing)."\n\n". &mt('Download the production release? ~[Y/n~]'); if (&get_user_selection(1)) { - $sourcetarball = $production.'tar.gz'; + $sourcetarball = 'loncapa-'.$production.'.tar.gz'; } else { print "\n".&mt('Download the testing release? ~[Y/n~]'); if (&get_user_selection(1)) { - $sourcetarball = $testing.'.tar.gz'; + $sourcetarball = 'loncapa-'.$testing.'.tar.gz'; } } } @@ -1098,7 +1098,7 @@ if ($callsub{'wwwuser'}) { } if ($callsub{'pwauth'}) { - &build_and_install_mod_auth_external(); + &build_and_install_mod_auth_external($instdir); } else { &print_and_log(&mt('Skipping [_1] installation.',"'pwauth'")."\n"); } @@ -1167,7 +1167,7 @@ if ($callsub{'runlevels'}) { if ($callsub{'firewall'}) { if ($distro =~ /^(suse|sles)/) { print &mt('Use [_1].','yast')."\n"; - } elsif ($distro = /^(debian|ubuntu)/) { + } elsif ($distro =~ /^(debian|ubuntu)/) { print &mt('Use [_1].','ufw')."\n"; } else { print &mt('Use [_1].','setup')."\n"; @@ -1381,7 +1381,7 @@ sub kill_extra_services { if ($daemon eq 'cupsd') { $service = 'cups'; } - if ($distro =~ /^(debian|ubuntu)$/) { + if ($distro =~ /^(debian|ubuntu)/) { &print_and_log(`/usr/sbin/sysv-rc-conf $service off`); } else { &print_and_log(`chkconfig --del $service`); @@ -1395,21 +1395,24 @@ sub kill_extra_services { sub setup_mysql { my ($setup_mysql_permissions,$distro,$dbh,$has_pass,$has_lcdb) = @_; - my $mysql_lc_command = "\n"; + my @mysql_lc_commands; unless ($has_lcdb) { - $mysql_lc_command .= "CREATE DATABASE loncapa;\n"; + push(@mysql_lc_commands,"CREATE DATABASE loncapa"); } - $mysql_lc_command .= <<"ENDMYSQL"; -USE loncapa; -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 + push(@mysql_lc_commands,"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 +}); if ($setup_mysql_permissions) { - &setup_mysql_permissions($dbh,$has_pass,$mysql_lc_command); + &setup_mysql_permissions($dbh,$has_pass,@mysql_lc_commands); } else { print_and_log(&mt('Skipping MySQL permissions setup.')."\n"); 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"); } else { print_and_log(&mt('Problem accessing MySQL.')."\n"); @@ -1418,30 +1421,30 @@ ENDMYSQL } sub setup_mysql_permissions { - my ($dbh,$has_pass,$mysql_lc_command) = @_; + my ($dbh,$has_pass,@mysql_lc_commands) = @_; my $mysqlversion = &get_mysql_version(); - my $mysql_commands = <<"BLOCKONE"; -INSERT INTO user (Host, User, Password) -VALUES ('localhost','www',password('localhostkey')); -BLOCKONE + my @mysql_commands = ("INSERT user (Host, User, Password) VALUES('localhost','www',password('localhostkey'));"); if ($mysqlversion < 4) { - $mysql_commands .= <<"BLOCKTWO"; -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'); -BLOCKTWO - } else { - $mysql_commands .= <<"BLOCKTHREE"; -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'); -BLOCKTHREE + push (@mysql_commands," +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')"); + } else { + push (@mysql_commands," +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')"); } - $mysql_commands .= <<"END"; -DELETE FROM user WHERE host<>'localhost'; -END + push(@mysql_commands,"DELETE FROM user WHERE host<>'localhost'"); if ($has_pass) { if ($dbh) { - $mysql_commands .= <<"END"; -FLUSH PRIVILEGES; -END - $dbh->do($mysql_commands.$mysql_lc_command); + push(@mysql_commands,"FLUSH PRIVILEGES"); + 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"; + } + } print_and_log(&mt('Permissions set for LON-CAPA MySQL user: [_1]',"'www'")."\n"); } else { print_and_log(&mt('Problem accessing MySQL.')."\n". @@ -1470,12 +1473,23 @@ END } } if ($got_passwd) { - $mysql_commands .= &new_mysqlrootpasswd($newmysqlpass); + my (@newpass_cmds) = &new_mysql_rootpasswd($newmysqlpass); + push(@mysql_commands,@newpass_cmds); } else { print_and_log(&mt('Failed to get MySQL root password from user input.')."\n"); } 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) { print_and_log(&mt('MySQL root password stored.')."\n". &mt('Permissions set for LON-CAPA MySQL user: [_1].',"'www'")."\n"); @@ -1491,10 +1505,8 @@ END sub new_mysql_rootpasswd { my ($currmysqlpass) = @_; - return <<"END"; -SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass'); -FLUSH PRIVILEGES; -END + return ("SET PASSWORD FOR 'root'\@'localhost'=PASSWORD('$currmysqlpass')", + "FLUSH PRIVILEGES;"); } sub get_mysql_version { @@ -1537,7 +1549,7 @@ sub copy_httpd_conf { sub copy_apache2_debconf { 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_available_dir = '/etc/apache2/sites-available'; if (-l "$apache2_enabled_dir/000-default") {