From 464871dabbc056b5aa267e9297afe9a724d442e1 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Thu, 19 Sep 2002 19:34:26 +0000 Subject: [PATCH] Incorporated A.C.Li's fixes for install script. His patches were against the old installer.pl in the trunk of CVS. His fixes were applied to the new installer.pl and Install.pm in the rel-1-2 branch. These files will eventually replace the old installer in the trunk branch as well when we start distributiong 1.3.x packages. --- Install.pm | 52 ++++++++++++++++++++++++++++++++++++++-------------- installer.pl | 13 +++++++++---- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/Install.pm b/Install.pm index c941f10616..143c667c34 100644 --- a/Install.pm +++ b/Install.pm @@ -1005,9 +1005,9 @@ sub installfiles { # Create /etc/koha.conf - open(KC,">$::etcdir/koha.conf") or warn "Couldn't create file - at $::etcdir. Must have write capability.\n"; - print KC qq| + my $old_umask = umask(027); # make sure koha.conf is never world-readable + open(SITES,">$::etcdir/koha.conf.tmp") or warn "Couldn't create file at $::etcdir. Must have write capability.\n"; + print SITES qq| database=$::dbname hostname=$::hostname user=$::user @@ -1019,10 +1019,11 @@ kohalogdir=$::kohalogdir kohaversion=$::kohaversion httpduser=$::httpduser |; - close(KC); + close(SITES); + umask($old_umask); - chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf") or warn "can't chown koha.conf: $!"; - chmod 0440, "$::etcdir/koha.conf"; + chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf.tmp") or warn "can't chown koha.conf: $!"; + chmod 0440, "$::etcdir/koha.conf.tmp"; chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh"; chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh"; @@ -1113,20 +1114,37 @@ sub databasesetup { foreach my $mysql (qw(/usr/local/mysql /opt/mysql + /usr )) { - if ( -d $mysql ) { - $mysqldir=$mysql; + if ( -d $mysql && -f "$mysql/bin/mysqladmin") { + $mysqldir=$mysql; } } if (!$mysqldir){ - $mysqldir='/usr'; + print "I don't see mysql in the usual places.\n"; + for (;;) { + print "Where have you installed mysql? "; + chomp($mysqldir = ); + last if -f "$mysqldir/bin/mysqladmin"; + print < /dev/null 2>&1"); + $::mysqlpass_quoted = $::mysqlpass; + $::mysqlpass_quoted =~ s/"/\\"/g; + my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p\"$::mysqlpass_quoted\" proc > /dev/null 2>&1"); if ($result) { print getmessage('InvalidMysqlRootPassword'); } else { @@ -1140,10 +1158,12 @@ sub databasesetup { if ($result) { showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1); } else { - system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname < koha.mysql"); - system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;"); - system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass mysql -e \"insert into db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv, index_priv, alter_priv) values ('%','$::dbname','$::user','Y','Y','Y','Y','Y','Y','Y','Y')\""); - system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass reload"); + # Populate the Koha database + system("$mysqldir/bin/mysql -u$::mysqluser -p\"$::mysqlpass_quoted\" $::dbname < koha.mysql"); + # Set up permissions + system("$mysqldir/bin/mysql -u$::mysqluser -p\"$::mysqlpass_quoted\" mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;"); + system("$mysqldir/bin/mysql -u$::mysqluser -p\"$::mysqlpass_quoted\" mysql -e \"insert into db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv, index_priv, alter_priv) values ('%','$::dbname','$::user','Y','Y','Y','Y','Y','Y','Y','Y')\""); + system("$mysqldir/bin/mysqladmin -u$::mysqluser -p\"$::mysqlpass_quoted\" reload"); system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase"); @@ -1226,6 +1246,10 @@ sub restartapache { } +# Installation is complete. Rename the koha.conf.tmp file + +rename "$::etcdir/koha.conf.tmp", "$::etcdir/koha.conf" || warn "Couldn't rename file at $::etcdir. Must have write capability.\n"; + sub loadconfigfile { my %configfile; diff --git a/installer.pl b/installer.pl index 63853bc2cc..dc858733c1 100644 --- a/installer.pl +++ b/installer.pl @@ -8,15 +8,20 @@ use strict; # please develop with the strict pragma $::language='en'; -if ($<) { - print "\n\nYou must run koha.upgrade as root.\n\n"; - exit; -} unless ($< == 0) { print "You must be root to run this script.\n"; exit 1; } + +unless (-d 'intranet-html') { + print <