[Koha-cvs] CVS: koha/misc installer.pl,1.8,1.9 Install.pm,1.5,1.6

Paul POULAIN tipaul at users.sourceforge.net
Wed Jan 15 14:05:23 CET 2003


Update of /cvsroot/koha/koha/misc
In directory sc8-pr-cvs1:/tmp/cvs-serv11125

Modified Files:
	installer.pl Install.pm 
Log Message:
ambrose li patch + bugfix for #158

Index: installer.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/installer.pl,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** installer.pl	30 Dec 2002 09:26:33 -0000	1.8
--- installer.pl	15 Jan 2003 13:05:21 -0000	1.9
***************
*** 36,40 ****
  }
  
! #checkabortedinstall();
  
  if (-e "$::etcdir/koha.conf") {
--- 36,40 ----
  }
  
! checkabortedinstall();
  
  if (-e "$::etcdir/koha.conf") {

Index: Install.pm
===================================================================
RCS file: /cvsroot/koha/koha/misc/Install.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** Install.pm	6 Jan 2003 11:11:56 -0000	1.5
--- Install.pm	15 Jan 2003 13:05:21 -0000	1.6
***************
*** 29,32 ****
--- 29,33 ----
  @ISA = qw(Exporter);
  @EXPORT = qw(	&checkperlmodules
+                 &checkabortedinstall
  		&getmessage
  		&showmessage
***************
*** 135,139 ****
  ==========================
  
! It looks like Koha is already installed on your system (/etc/koha.conf exists
  already).  If you would like to upgrade your system to %s, please use
  the koha.upgrade script in this directory.
--- 136,140 ----
  ==========================
  
! It looks like Koha is already installed on your system (%s/koha.conf exists
  already).  If you would like to upgrade your system to %s, please use
  the koha.upgrade script in this directory.
***************
*** 179,183 ****
  using basic authentication on your intranet, you will be required to log in to
  access some of the features of the intranet.  You can log in using the userid
! and password from the /etc/koha.conf configuration file at any time.  Use the
  "Members" module to add passwords for other accounts and set their permissions.
  
--- 180,184 ----
  using basic authentication on your intranet, you will be required to log in to
  access some of the features of the intranet.  You can log in using the userid
! and password from the %s/koha.conf configuration file at any time.  Use the
  "Members" module to add passwords for other accounts and set their permissions.
  
***************
*** 220,223 ****
--- 221,252 ----
  
  #
+ # Assuming that Koha will be installed on a modern Unix with symlinks,
+ # it is possible to code the installer so that aborted installs can be
+ # detected. In case of such an event we can do our best to "roll back"
+ # the aborted install.
+ #
+ # FIXME: The "roll back" is not complete!
+ #
+ 
+ sub checkabortedinstall {
+     if (-l("$::etcdir/koha.conf")
+         && readlink("$::etcdir/koha.conf") =~ /\.tmp$/
+     ) {
+         print qq|
+ I have detected that you tried to install Koha before, but the installation
+ was aborted.  I will try to continue, but there might be problems if the
+ database is already created.
+ 
+ |;
+         print "Please press <ENTER> to continue: ";
+         <STDIN>;
+ 
+         # Remove the symlink after the <STDIN>, so the user can back out
+         unlink "$::etcdir/koha.conf"
+             || die "Failed to remove incomplete $::etcdir/koha.conf: $!\n";
+     }
+ }
+ 
+ #
  # Test for Perl and Modules
  #
***************
*** 508,511 ****
--- 537,542 ----
  to the %s database, when authenticating from %s.
  
+ This user will also be used to access Koha's INTRANET interface.
+ 
  Database user [%s]: |;
  
***************
*** 603,607 ****
  I was not able to determine the user that Apache is running as.  This
  information is necessary in order to set the access privileges correctly on
! /etc/koha.conf.  This user should be set in one of the Apache configuration
  files using the "User" directive.
  
--- 634,638 ----
  I was not able to determine the user that Apache is running as.  This
  information is necessary in order to set the access privileges correctly on
! %s/koha.conf.  This user should be set in one of the Apache configuration
  files using the "User" directive.
  
***************
*** 638,642 ****
  	my $message=getmessage('NoApacheConfFiles');
  	my $choice='';
! 	until (-f $choice) {
  	    $choice=showmessage($message, "free", 1);
  	    if (-f $choice) {
--- 669,673 ----
  	my $message=getmessage('NoApacheConfFiles');
  	my $choice='';
! 	until (-f $::realhttpdconf) {
  	    $choice=showmessage($message, "free", 1);
  	    if (-f $choice) {
***************
*** 661,665 ****
  	$::realhttpdconf=$confpossibilities[0];
      }
!     unless (open (HTTPDCONF, $::realhttpdconf)) {
  	warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
  	sleep 4;
--- 692,696 ----
  	$::realhttpdconf=$confpossibilities[0];
      }
!     unless (open (HTTPDCONF, "<$::realhttpdconf")) {
  	warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
  	sleep 4;
***************
*** 677,681 ****
  
      unless ($::httpduser) {
! 	my $message=getmessage('EnterApacheUser');
  	until (length($::httpduser) && getpwnam($::httpduser)) {
  	    $::httpduser=showmessage($message, "free", '');
--- 708,712 ----
  
      unless ($::httpduser) {
! 	my $message=getmessage('EnterApacheUser', [$::etcdir]);
  	until (length($::httpduser) && getpwnam($::httpduser)) {
  	    $::httpduser=showmessage($message, "free", '');
***************
*** 808,816 ****
  
  sub updateapacheconf {
!     my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
      chomp $logfiledir;
  
      if ($logfiledir) {
! 	$logfiledir=~m#ErrorLog (.*)/[^/]*$#;
  	$logfiledir=$1;
      }
--- 839,848 ----
  
  sub updateapacheconf {
!     my $logfiledir=`grep ^ErrorLog "$::realhttpdconf"`;
      chomp $logfiledir;
  
      if ($logfiledir) {
! 	$logfiledir=~m#ErrorLog (.*)/[^/]*$#
! 	    or die "Can't parse ErrorLog directive\n";
  	$logfiledir=$1;
      }
***************
*** 825,829 ****
      my $envmodule=0;
      my $includesmodule=0;
!     open HC, $::realhttpdconf;
      while (<HC>) {
  	if (/^\s*#\s*LoadModule env_module /) {
--- 857,861 ----
      my $envmodule=0;
      my $includesmodule=0;
!     open HC, "<$::realhttpdconf";
      while (<HC>) {
  	if (/^\s*#\s*LoadModule env_module /) {
***************
*** 857,861 ****
  
      
!     if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
  	showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
  	return;
--- 889,893 ----
  
      
!     if (`grep 'VirtualHost $::servername' "$::realhttpdconf"`) {
  	showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
  	return;
***************
*** 934,937 ****
--- 966,973 ----
  Apache's Basic Authorization.
  
+ This is going to be phased out very soon. However, setting this up can provide
+ an extra layer of security before the new authentication system is completely
+ in place.
+ 
  Would you like to do this ([Y]/N): |;
  
***************
*** 955,959 ****
  	    }
  	}
! 	open AUTH, ">/etc/kohaintranet.pass";
  	my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  	my $salt=substr($chars, int(rand(length($chars))),1);
--- 991,995 ----
  	    }
  	}
! 	open AUTH, ">$::etcdir/kohaintranet.pass";
  	my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  	my $salt=substr($chars, int(rand(length($chars))),1);
***************
*** 965,969 ****
  
  <Directory $::intranetdir>
!     AuthUserFile /etc/kohaintranet.pass
      AuthType Basic
      AuthName "Koha Intranet (for librarians only)"
--- 1001,1005 ----
  
  <Directory $::intranetdir>
!     AuthUserFile $::etcdir/kohaintranet.pass
      AuthType Basic
      AuthName "Koha Intranet (for librarians only)"
***************
*** 1007,1012 ****
      system("touch $::opacdir/cgi-bin/opac");
  
!     system("chown -R root.$::httpduser $::opacdir");
!     system("chown -R root.$::httpduser $::intranetdir");
  
      # Create /etc/koha.conf
--- 1043,1048 ----
      system("touch $::opacdir/cgi-bin/opac");
  
!     system("chown -R root:$::httpduser $::opacdir");
!     system("chown -R root:$::httpduser $::intranetdir");
  
      # Create /etc/koha.conf
***************
*** 1019,1023 ****
  user=$::user
  pass=$::pass
! includes=$::intranetdir/htdocs/includes
  intranetdir=$::intranetdir
  opacdir=$::opacdir
--- 1055,1059 ----
  user=$::user
  pass=$::pass
! includes=$::opacdir/htdocs/includes
  intranetdir=$::intranetdir
  opacdir=$::opacdir
***************
*** 1027,1030 ****
--- 1063,1068 ----
  intrahtdocs=$::intranetdir/htdocs/intranet-tmpl
  opachtdocs=$::opacdir/htdocs/opac-tmpl
+ #XXX I had: intrahtdocs=$::intranetdir/cgi-bin/koha-tmpl/intranet-tmpl
+ #XXX I had: opachtdocs=$::intranetdir/cgi-bin/koha-tmpl/opac-tmpl
  |;
      close(SITES);
***************
*** 1050,1054 ****
  mysql server's root user password:
  
! Enter MySql root user password: |;
  
  $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password.  Please try again.";
--- 1088,1092 ----
  mysql server's root user password:
  
! Enter MySQL root user password: |;
  
  $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password.  Please try again.";
***************
*** 1059,1063 ****
  =====================
  
! Creating the MySql database for Koha...
  
  |;
--- 1097,1101 ----
  =====================
  
! Creating the MySQL database for Koha...
  
  |;
***************
*** 1228,1231 ****
--- 1266,1272 ----
  
  sub updatedatabase {
+     # At this point, $::etcdir/koha.conf must exist, for C4::Context
+     # We must somehow temporarily enable $::etcdir/koha.conf. A symlink can
+     # do this & at the same time facilitate detection of aborted installs.
  	my $result=system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
  	if ($result) {
***************
*** 1237,1245 ****
  
  	if ($response == 1) {
! 		system("cat script/misc/marc_datas/marc21_en/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
  	}
  	if ($response == 2) {
! 		system("cat scripts/misc/marc_datas/unimarc_fr/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
! 		system("cat scripts/misc/lang-datas/fr/stopwords.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
  	}
  
--- 1278,1286 ----
  
  	if ($response == 1) {
! 		system("cat scripts/misc/marc_datas/marc21_en/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
  	}
  	if ($response == 2) {
! 		system("cat scripts/misc/marc_datas/unimarc_fr/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
! 		system("cat scripts/misc/lang-datas/fr/stopwords.sql | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
  	}
  
***************
*** 1250,1254 ****
  	}
  
! 	print "\n\nFinished updating database. Press <ENTER> to continue...";
  	<STDIN>;
  }
--- 1291,1295 ----
  	}
  
! 	print "\n\nFinished basic updating of database. Press <ENTER> to continue...";
  	<STDIN>;
  }
***************
*** 1257,1263 ****
  	my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
  	if ($response =~/^y/i) {
! 		system("gunzip sampledata-1.2.gz");
! 		system("cat sampledata-1.2 | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
! 		system("gzip -9 sampledata-1.2");
  		system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
  		system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
--- 1298,1302 ----
  	my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
  	if ($response =~/^y/i) {
! 		system("gunzip -d < sampledata-1.2.gz | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
  		system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
  		system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
***************
*** 1334,1338 ****
      my %configfile;
  
!     open (KC, "/etc/koha.conf");
      while (<KC>) {
       chomp;
--- 1373,1377 ----
      my %configfile;
  
!     open (KC, "<$::etcdir/koha.conf");
      while (<KC>) {
       chomp;





More information about the Koha-cvs mailing list