[Koha-cvs] CVS: koha installer.pl,1.2.2.61,1.2.2.62 Install.pm,1.1.2.2,1.1.2.3

Steve Tonnesen tonnesen at users.sourceforge.net
Thu Jul 25 00:23:15 CEST 2002


Update of /cvsroot/koha/koha
In directory usw-pr-cvs1:/tmp/cvs-serv15356

Modified Files:
      Tag: rel-1-2
	installer.pl Install.pm 
Log Message:
A bit further on modularizing intaller.pl


Index: installer.pl
===================================================================
RCS file: /cvsroot/koha/koha/installer.pl,v
retrieving revision 1.2.2.61
retrieving revision 1.2.2.62
diff -C2 -r1.2.2.61 -r1.2.2.62
*** installer.pl	24 Jul 2002 17:37:26 -0000	1.2.2.61
--- installer.pl	24 Jul 2002 22:23:13 -0000	1.2.2.62
***************
*** 73,282 ****
  # Ask for installation directories
  
! my ($opacdir, $intranetdir) = getinstallationdirectories();
! 
! 
! 
  
  $::etcdir = '/etc';
  
- 
- 
- $::dbname = 'Koha';
- $::hostname = 'localhost';
- $::user = 'kohaadmin';
- $::pass = '';
- 
- 
  getdatabaseinfo();
  
- 
- 
  getapacheinfo();
  
- 
- print "user: $::httpduser\n";
- print "conf:  $::realhttpdconf\n";
- exit;
- 
  getapachevhostinfo();
  
! #
! # Update Apache Conf File.
! #
! #
! 
! my $logfiledir=`grep ^ErrorLog $$::realhttpdconf`;
! chomp $logfiledir;
! 
! if ($logfiledir) {
!     $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
!     $logfiledir=$1;
! }
! 
! unless ($logfiledir) {
!     $logfiledir='logs';
! }
! print qq|
! 
! UPDATING APACHE.CONF
! ====================
! 
! |;
! 
! 
! print "Checking for modules that need to be loaded...\n";
! my $httpdconf='';
! my $envmodule=0;
! my $includesmodule=0;
! open HC, $$::realhttpdconf;
! while (<HC>) {
!     if (/^\s*#\s*LoadModule env_module /) {
! 	s/^\s*#\s*//;
! 	print "  Loading env_module in httpd.conf\n";
! 	$envmodule=1;
!     }
!     if (/^\s*#\s*LoadModule includes_module /) {
! 	s/^\s*#\s*//;
! 	print "  Loading includes_module in httpd.conf\n";
!     }
!     if (/\s*LoadModule includes_module / ) {
! 	$includesmodule=1;
!     }
!     $httpdconf.=$_;
! }
! 
! my $apachebackupmade=0;
! if ($envmodule || $includesmodule) {
!     system("mv -f $$::realhttpdconf $$::realhttpdconf\.prekoha");
!     $apachebackupmade=1;
!     open HC, ">$$::realhttpdconf";
!     print HC $httpdconf;
!     close HC;
! }
  
  
! if (0) {
! #if (`grep 'VirtualHost $servername' $$::realhttpdconf`) {
! #    print qq|
! #$$::realhttpdconf appears to already have an entry for Koha
! #Virtual Hosts.  You may need to edit $$::realhttpdconf
! #if anything has changed since it was last set up.  This
! #script will not attempt to modify an existing Koha apache
! #configuration.
! #
! #|;
!     print "Press <ENTER> to continue...";
!     <STDIN>;
!     print "\n";
! } else {
!     unless ($apachebackupmade) {
! 	system("cp -f $$::realhttpdconf $$::realhttpdconf\.prekoha");
!     }
!     my $includesdirectives='';
!     if ($includesmodule) {
! 	$includesdirectives.="Options +Includes\n";
! 	$includesdirectives.="   AddHandler server-parsed .html\n";
!     }
!     open(SITE,">>$$::realhttpdconf") or warn "Insufficient priveleges to open $$::realhttpdconf for writing.\n";
! #    print SITE <<EOP
! #
! #
! ## Ports to listen to for Koha
! #Listen $opacport
! #Listen $kohaport
! #
! ## NameVirtualHost is used by one of the optional configurations detailed below
! #
! ##NameVirtualHost 11.22.33.44
! #
! ## KOHA's OPAC Configuration
! #<VirtualHost $servername\:$opacport>
! #   ServerAdmin $svr_admin
! #   DocumentRoot $opacdir/htdocs
! #   ServerName $servername
! #   ScriptAlias /cgi-bin/koha/ $opacdir/cgi-bin/
! #   ErrorLog $logfiledir/opac-error_log
! #   TransferLog $logfiledir/opac-access_log
! #   SetEnv PERL5LIB "$intranetdir/modules"
! #   $includesdirectives
! #</VirtualHost>
! #
! ## KOHA's INTRANET Configuration
! #<VirtualHost $servername\:$kohaport>
! #   ServerAdmin $svr_admin
! #   DocumentRoot $intranetdir/htdocs
! #   ServerName $servername
! #   ScriptAlias /cgi-bin/koha/ "$intranetdir/cgi-bin/"
! #   ErrorLog $logfiledir/koha-error_log
! #   TransferLog $logfiledir/koha-access_log
! #   SetEnv PERL5LIB "$intranetdir/modules"
! #   $includesdirectives
! #</VirtualHost>
! #
! ## If you want to use name based Virtual Hosting:
! ##   1. remove the two Listen lines
! ##   2. replace $servername\:$opacport wih your.opac.domain.name
! ##   3. replace ServerName $servername wih ServerName your.opac.domain.name
! ##   4. replace $servername\:$kohaport wih your intranet domain name
! ##   5. replace ServerName $servername wih ServerName your.intranet.domain.name
! ##
! ## If you want to use NameVirtualHost'ing (using two names on one ip address):
! ##   1.  Follow steps 1-5 above
! ##   2.  Uncomment the NameVirtualHost line and set the correct ip address
! #
! #EOP
! #;
  
  
!     print qq|
! 
! Intranet Authentication
! =======================
! 
! I can set it up so that the Intranet/Librarian site is password protected.
! |;
! print "Would you like to do this? ([Y]/N): ";
! chomp($input = <STDIN>);
! 
! my $apacheauthusername='librarian';
! my $apacheauthpassword='';
! unless ($input=~/^n/i) {
!     print "\nEnter a userid to login with [$apacheauthusername]: ";
!     chomp ($input = <STDIN>);
!     if ($input) {
! 	$apacheauthusername=$input;
! 	$apacheauthusername=~s/[^a-zA-Z0-9]//g;
!     }
!     while (! $apacheauthpassword) {
! 	print "\nEnter a password for the $apacheauthusername user: ";
! 	chomp ($input = <STDIN>);
! 	if ($input) {
! 	    $apacheauthpassword=$input;
! 	}
! 	if (!$apacheauthpassword) {
! 	    print "\nPlease enter a password.\n";
! 	}
!     }
!     open AUTH, ">/etc/kohaintranet.pass";
!     my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
!     my $salt=substr($chars, int(rand(length($chars))),1);
!     $salt.=substr($chars, int(rand(length($chars))),1);
!     print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
!     close AUTH;
!     print SITE <<EOP
! 
! <Directory $intranetdir>
!     AuthUserFile /etc/kohaintranet.pass
!     AuthType Basic
!     AuthName "Koha Intranet (for librarians only)"
!     Require  valid-user
! </Directory>
! EOP
! }
! 
!     close(SITE);
  
-     print "Successfully updated Apache Configuration file.\n";
- }
  
  print qq|
--- 73,94 ----
  # Ask for installation directories
  
! getinstallationdirectories();
  
  $::etcdir = '/etc';
  
  getdatabaseinfo();
  
  getapacheinfo();
  
  getapachevhostinfo();
  
! updateapacheconf();
  
  
! basicauthentication();
  
  
! exit;
  
  
  print qq|
***************
*** 318,326 ****
  
  
! unless ( -d $intranetdir ) {
!    print "Creating $intranetdir...\n";
!    my $result=mkdir ($intranetdir, oct(770));
     if ($result==0) {
!        my @dirs = split(m#/#, $intranetdir);
  	my $checkdir='';
  	foreach (@dirs) {
--- 130,138 ----
  
  
! unless ( -d $::intranetdir ) {
!    print "Creating $::intranetdir...\n";
!    my $result=mkdir ($::intranetdir, oct(770));
     if ($result==0) {
!        my @dirs = split(m#/#, $::intranetdir);
  	my $checkdir='';
  	foreach (@dirs) {
***************
*** 331,358 ****
  	}
     }
!    chown (oct(0), (getgrnam($::httpduser))[2], "$intranetdir");
!    chmod (oct(770), "$intranetdir");
  }
! unless ( -d "$intranetdir/htdocs" ) {
!    print "Creating $intranetdir/htdocs...\n";
!    mkdir ("$intranetdir/htdocs", oct(750));
! }
! unless ( -d "$intranetdir/cgi-bin" ) {
!    print "Creating $intranetdir/cgi-bin...\n";
!    mkdir ("$intranetdir/cgi-bin", oct(750));
! }
! unless ( -d "$intranetdir/modules" ) {
!    print "Creating $intranetdir/modules...\n";
!    mkdir ("$intranetdir/modules", oct(750));
! }
! unless ( -d "$intranetdir/scripts" ) {
!    print "Creating $intranetdir/scripts...\n";
!    mkdir ("$intranetdir/scripts", oct(750));
! }
! unless ( -d $opacdir ) {
!    print "Creating $opacdir...\n";
!    my $result=mkdir ($opacdir, oct(770));
     if ($result==0) {
!        my @dirs = split(m#/#, $opacdir);
  	my $checkdir='';
  	foreach (@dirs) {
--- 143,170 ----
  	}
     }
!    chown (oct(0), (getgrnam($::httpduser))[2], "$::intranetdir");
!    chmod (oct(770), "$::intranetdir");
  }
! unless ( -d "$::intranetdir/htdocs" ) {
!    print "Creating $::intranetdir/htdocs...\n";
!    mkdir ("$::intranetdir/htdocs", oct(750));
! }
! unless ( -d "$::intranetdir/cgi-bin" ) {
!    print "Creating $::intranetdir/cgi-bin...\n";
!    mkdir ("$::intranetdir/cgi-bin", oct(750));
! }
! unless ( -d "$::intranetdir/modules" ) {
!    print "Creating $::intranetdir/modules...\n";
!    mkdir ("$::intranetdir/modules", oct(750));
! }
! unless ( -d "$::intranetdir/scripts" ) {
!    print "Creating $::intranetdir/scripts...\n";
!    mkdir ("$::intranetdir/scripts", oct(750));
! }
! unless ( -d $::opacdir ) {
!    print "Creating $::opacdir...\n";
!    my $result=mkdir ($::opacdir, oct(770));
     if ($result==0) {
!        my @dirs = split(m#/#, $::opacdir);
  	my $checkdir='';
  	foreach (@dirs) {
***************
*** 363,376 ****
  	}
     }
!    chown (oct(0), (getgrnam($::httpduser))[2], "$opacdir");
!    chmod (oct(770), "$opacdir");
  }
! unless ( -d "$opacdir/htdocs" ) {
!    print "Creating $opacdir/htdocs...\n";
!    mkdir ("$opacdir/htdocs", oct(750));
! }
! unless ( -d "$opacdir/cgi-bin" ) {
!    print "Creating $opacdir/cgi-bin...\n";
!    mkdir ("$opacdir/cgi-bin", oct(750));
  }
  
--- 175,188 ----
  	}
     }
!    chown (oct(0), (getgrnam($::httpduser))[2], "$::opacdir");
!    chmod (oct(770), "$::opacdir");
  }
! unless ( -d "$::opacdir/htdocs" ) {
!    print "Creating $::opacdir/htdocs...\n";
!    mkdir ("$::opacdir/htdocs", oct(750));
! }
! unless ( -d "$::opacdir/cgi-bin" ) {
!    print "Creating $::opacdir/cgi-bin...\n";
!    mkdir ("$::opacdir/cgi-bin", oct(750));
  }
  
***************
*** 379,397 ****
  print "\n\nINSTALLING KOHA...\n";
  print "\n\n==================\n";
! print "Copying internet-html files to $intranetdir/htdocs...\n";
! system("cp -R intranet-html/* $intranetdir/htdocs/");
! print "Copying intranet-cgi files to $intranetdir/cgi-bin...\n";
! system("cp -R intranet-cgi/* $intranetdir/cgi-bin/");
! print "Copying script files to $intranetdir/scripts...\n";
! system("cp -R scripts/* $intranetdir/scripts/");
! print "Copying module files to $intranetdir/modules...\n";
! system("cp -R modules/* $intranetdir/modules/");
! print "Copying opac-html files to $opacdir/htdocs...\n";
! system("cp -R opac-html/* $opacdir/htdocs/");
! print "Copying opac-cgi files to $opacdir/cgi-bin...\n";
! system("cp -R opac-cgi/* $opacdir/cgi-bin/");
  
! system("chown -R root.$::httpduser $opacdir");
! system("chown -R root.$::httpduser $intranetdir");
  
  
--- 191,209 ----
  print "\n\nINSTALLING KOHA...\n";
  print "\n\n==================\n";
! print "Copying internet-html files to $::intranetdir/htdocs...\n";
! system("cp -R intranet-html/* $::intranetdir/htdocs/");
! print "Copying intranet-cgi files to $::intranetdir/cgi-bin...\n";
! system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
! print "Copying script files to $::intranetdir/scripts...\n";
! system("cp -R scripts/* $::intranetdir/scripts/");
! print "Copying module files to $::intranetdir/modules...\n";
! system("cp -R modules/* $::intranetdir/modules/");
! print "Copying opac-html files to $::opacdir/htdocs...\n";
! system("cp -R opac-html/* $::opacdir/htdocs/");
! print "Copying opac-cgi files to $::opacdir/cgi-bin...\n";
! system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
  
! system("chown -R root.$::httpduser $::opacdir");
! system("chown -R root.$::httpduser $::intranetdir");
  
  
***************
*** 413,419 ****
  user=$::user
  pass=$::pass
! includes=$intranetdir/htdocs/includes
! intranetdir=$intranetdir
! opacdir=$opacdir
  kohalogdir=$kohalogdir
  kohaversion=$::kohaversion
--- 225,231 ----
  user=$::user
  pass=$::pass
! includes=$::intranetdir/htdocs/includes
! intranetdir=$::intranetdir
! opacdir=$::opacdir
  kohalogdir=$kohalogdir
  kohaversion=$::kohaversion
***************
*** 489,493 ****
      system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass reload");
  
!     system ("perl -I $intranetdir/modules scripts/updater/updatedatabase");
  
  
--- 301,305 ----
      system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass reload");
  
!     system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
  
  
***************
*** 581,590 ****
  print "Modifying Z39.50 daemon launch script...\n";
  my $newfile='';
! open (L, "$intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh");
  while (<L>) {
      if (/^RunAsUser=/) {
  	$newfile.="RunAsUser=$::httpduser\n";
      } elsif (/^KohaZ3950Dir=/) {
! 	$newfile.="KohaZ3950Dir=$intranetdir/scripts/z3950daemon\n";
      } else {
  	$newfile.=$_;
--- 393,402 ----
  print "Modifying Z39.50 daemon launch script...\n";
  my $newfile='';
! open (L, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh");
  while (<L>) {
      if (/^RunAsUser=/) {
  	$newfile.="RunAsUser=$::httpduser\n";
      } elsif (/^KohaZ3950Dir=/) {
! 	$newfile.="KohaZ3950Dir=$::intranetdir/scripts/z3950daemon\n";
      } else {
  	$newfile.=$_;
***************
*** 592,597 ****
  }
  close L;
! system("mv $intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh $intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh.orig");
! open L, ">$intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
  print L $newfile;
  close L;
--- 404,409 ----
  }
  close L;
! system("mv $::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh $::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh.orig");
! open L, ">$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
  print L $newfile;
  close L;
***************
*** 601,610 ****
  print "Modifying Z39.50 daemon wrapper script...\n";
  $newfile='';
! open (S, "$intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh");
  while (<S>) {
      if (/^KohaModuleDir=/) {
! 	$newfile.="KohaModuleDir=$intranetdir/modules\n";
      } elsif (/^KohaZ3950Dir=/) {
! 	$newfile.="KohaZ3950Dir=$intranetdir/scripts/z3950daemon\n";
      } elsif (/^LogDir=/) {
  	$newfile.="LogDir=$kohalogdir\n";
--- 413,422 ----
  print "Modifying Z39.50 daemon wrapper script...\n";
  $newfile='';
! open (S, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh");
  while (<S>) {
      if (/^KohaModuleDir=/) {
! 	$newfile.="KohaModuleDir=$::intranetdir/modules\n";
      } elsif (/^KohaZ3950Dir=/) {
! 	$newfile.="KohaZ3950Dir=$::intranetdir/scripts/z3950daemon\n";
      } elsif (/^LogDir=/) {
  	$newfile.="LogDir=$kohalogdir\n";
***************
*** 615,627 ****
  close S;
  
! system("mv $intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh $intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh.orig");
! open S, ">$intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
  print S $newfile;
  close S;
! chmod 0750, "$intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
! chmod 0750, "$intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
! chmod 0750, "$intranetdir/scripts/z3950daemon/processz3950queue";
! chown(0, (getpwnam($::httpduser)) [3], "$intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
! chown(0, (getpwnam($::httpduser)) [3], "$intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $intranetdir/scripts/z3950daemon/processz3950queue: $!";
  
  print qq|
--- 427,439 ----
  close S;
  
! system("mv $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh.orig");
! open S, ">$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
  print S $newfile;
  close S;
! chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
! chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
! chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
! chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
! chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
  
  print qq|

Index: Install.pm
===================================================================
RCS file: /cvsroot/koha/koha/Attic/Install.pm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -r1.1.2.2 -r1.1.2.3
*** Install.pm	24 Jul 2002 17:37:26 -0000	1.1.2.2
--- Install.pm	24 Jul 2002 22:23:13 -0000	1.1.2.3
***************
*** 18,21 ****
--- 18,23 ----
  		&getapacheinfo
  		&getapachevhostinfo
+ 		&updateapacheconf
+ 		&basicauthentication
  		);
  
***************
*** 239,242 ****
--- 241,274 ----
  	    return $response;
  	}
+ 	if ($responsetype =~/^numerical$/i) {
+ 	    (defined($defaultresponse)) || ($defaultresponse='');
+ 	    my $response='';
+ 	    until ($response=~/^\d+$/) {
+ 		$response=<STDIN>;
+ 		chomp $response;
+ 		($response) || ($response=$defaultresponse);
+ 		unless ($response=~/^\d+$/) {
+ 		    ($noclear) || (system('clear'));
+ 		    print "Invalid Response ($response).  Response must be a number.\n\n";
+ 		    print $message;
+ 		}
+ 	    }
+ 	    return $response;
+ 	}
+ 	if ($responsetype =~/^email$/i) {
+ 	    (defined($defaultresponse)) || ($defaultresponse='');
+ 	    my $response='';
+ 	    until ($response=~/.*\@.*\..*/) {
+ 		$response=<STDIN>;
+ 		chomp $response;
+ 		($response) || ($response=$defaultresponse);
+ 		unless ($response=~/.*\@.*\..*/) {
+ 		    ($noclear) || (system('clear'));
+ 		    print "Invalid Response ($response).  Response must be a valid email address.\n\n";
+ 		    print $message;
+ 		}
+ 	    }
+ 	    return $response;
+ 	}
  	if ($responsetype =~/^PressEnter$/i) {
  	    <STDIN>;
***************
*** 250,269 ****
  
  sub getinstallationdirectories {
!     my $opacdir = '/usr/local/koha/opac';
!     my $intranetdir = '/usr/local/koha/intranet';
      my $getdirinfo=1;
      while ($getdirinfo) {
  	# Loop until opac directory and koha directory are different
! 	my $message=getmessage('GetOpacDir', [$opacdir]);
! 	$opacdir=showmessage($message, 'free', $opacdir);
  
! 	my $message=getmessage('GetIntranetDir', [$intranetdir]);
! 	$intranetdir=showmessage($message, 'free', $intranetdir);
  
! 	if ($intranetdir eq $opacdir) {
  	    print qq|
  
  You must specify different directories for the OPAC and INTRANET files!
!  :: $intranetdir :: $opacdir ::
  |;
  <STDIN>
--- 282,301 ----
  
  sub getinstallationdirectories {
!     $::opacdir = '/usr/local/koha/opac';
!     $::intranetdir = '/usr/local/koha/intranet';
      my $getdirinfo=1;
      while ($getdirinfo) {
  	# Loop until opac directory and koha directory are different
! 	my $message=getmessage('GetOpacDir', [$::opacdir]);
! 	$::opacdir=showmessage($message, 'free', $::opacdir);
  
! 	$message=getmessage('GetIntranetDir', [$::intranetdir]);
! 	$::intranetdir=showmessage($message, 'free', $::intranetdir);
  
! 	if ($::intranetdir eq $::opacdir) {
  	    print qq|
  
  You must specify different directories for the OPAC and INTRANET files!
!  :: $::intranetdir :: $::opacdir ::
  |;
  <STDIN>
***************
*** 272,276 ****
  	}
      }
!     return ($opacdir, $intranetdir);
  }
  
--- 304,308 ----
  	}
      }
!     return ($::opacdir, $::intranetdir);
  }
  
***************
*** 326,329 ****
--- 358,367 ----
  
  sub getdatabaseinfo {
+ 
+     $::dbname = 'Koha';
+     $::hostname = 'localhost';
+     $::user = 'kohaadmin';
+     $::pass = '';
+ 
  #Get the database name
  
***************
*** 473,492 ****
  	print "AU: $::httpduser\n";
      }
-     exit;
  }
  
  
! sub getapachevhostinfo {
! 
!     my $svr_admin = "webmaster\@$::domainname";
!     my $servername=`hostname -f`;
!     chomp $servername;
!     my $opacport=80;
!     my $kohaport=8080;
! 
!     print qq|
  
- OPAC and KOHA/LIBRARIAN CONFIGURATION
- =====================================
  Koha needs to setup your Apache configuration file for the
  OPAC and LIBRARIAN virtual hosts.  By default this installer
--- 511,522 ----
  	print "AU: $::httpduser\n";
      }
  }
  
  
! $messages->{'ApacheConfigIntroduction'}->{en}=qq|
! ========================
! = APACHE CONFIGURATION =
! ========================
  
  Koha needs to setup your Apache configuration file for the
  OPAC and LIBRARIAN virtual hosts.  By default this installer
***************
*** 496,530 ****
  what these other options are.
  
- Please enter the e-mail address for your webserver admin.
- Usually $svr_admin
- |;
  
!     print "Enter e-mail address [$svr_admin]:";
!       #$svr_admin = $input;
  
  
!     print qq|
  
  
! Please enter the domain name or ip address of your computer.
! |;
!       #$servername = $input;
  
!     print qq|
  
- Please enter the port for your OPAC interface.
- |;
-     print "Enter OPAC port [$opacport]:";
-       #$opacport = $input;
  
!     print qq|
  
! Please enter the port for your Intranet/Librarian interface.
  |;
-       #$kohaport = $input;
  
  
  
  }
  
  
--- 526,796 ----
  what these other options are.
  
  
! Press <ENTER> to continue: |;
  
+ $messages->{'GetVirtualHostEmail'}->{en}=qq|
+ =============================
+ = WEB SERVER E-MAIL CONTACT =
+ =============================
+ 
+ Enter the e-mail address to be used as a contact for the virtual hosts (this
+ address is displayed if any errors are encountered).
+ 
+ E-mail contact [%s]: |;
+ 
+ $messages->{'GetServerName'}->{en}=qq|
+ ======================================
+ = WEB SERVER HOST NAME OR IP ADDRESS =
+ ======================================
  
! Please enter the domain name or ip address of your computer.
  
+ Host name or IP Address [%s]: |;
  
! $messages->{'GetOpacPort'}->{en}=qq|
! ==========================
! = OPAC VIRTUAL HOST PORT =
! ==========================
  
! Please enter the port for your OPAC interface.  This defaults to port 80, but
! if you are already serving web content from this server, you should change it
! to a different port (8000 might be a good choice).
! 
! Enter the OPAC Port [%s]: |;
! 
! $messages->{'GetIntranetPort'}->{en}=qq|
! ==============================
! = INTRANET VIRTUAL HOST PORT =
! ==============================
! 
! Please enter the port for your Intranet interface.  This must be different from
! the OPAC port (%s).
! 
! Enter the Intranet Port [%s]: |;
! 
! 
! sub getapachevhostinfo {
! 
!     $::svr_admin = "webmaster\@$::domainname";
!     $::servername=`hostname -f`;
!     chomp $::servername;
!     $::opacport=80;
!     $::intranetport=8080;
! 
!     showmessage(getmessage('ApacheConfigIntroduction'), 'PressEnter');
! 
!     $::svr_admin=showmessage(getmessage('GetVirtualHostEmail', [$::svr_admin]), 'email', $::svr_admin);
!     $::servername=showmessage(getmessage('GetServerName', [$::servername]), 'free', $::servername);
  
  
!     $::opacport=showmessage(getmessage('GetOpacPort', [$::opacport]), 'numerical', $::opacport);
!     $::intranetport=showmessage(getmessage('GetIntranetPort', [$::opacport, $::intranetport]), 'numerical', $::intranetport);
  
! }
! 
! $messages->{'StartUpdateApache'}->{en}=qq|
! =================================
! = UPDATING APACHE CONFIGURATION =
! =================================
! 
! Checking for modules that need to be loaded...
  |;
  
+ $messages->{'LoadingApacheModuleModEnv'}->{en}="Loading SetEnv Apache module.\n";
+ 
+ $messages->{'LoadingApacheModuleModInc'}->{en}="Loading Includes Apache module.\n";
+ 
+ $messages->{'ApacheConfigBackupFailed'}->{en}=qq|
+ ======================================
+ = APACHE CONFIGURATION BACKUP FAILED =
+ ======================================
+ 
+ An error occurred while trying to make a backup copy of %s.
+ 
+   %s
+ 
+ No changes will be made to the apache configuration file at this time.
+ 
+ Press <ENTER> to continue: |;
  
  
+ $messages->{'ApacheAlreadyConfigured'}->{en}=qq|
+ $::realhttpdconf appears to already have an entry for Koha
+ Virtual Hosts.  You may need to edit $::realhttpdconf
+ f anything has changed since it was last set up.  This
+ script will not attempt to modify an existing Koha apache
+ configuration.
+ 
+ Press <ENTER> to continue: |;
+ 
+ sub updateapacheconf {
+     my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
+     chomp $logfiledir;
+ 
+     if ($logfiledir) {
+ 	$logfiledir=~m#ErrorLog (.*)/[^/]*$#;
+ 	$logfiledir=$1;
+     }
+ 
+     unless ($logfiledir) {
+ 	$logfiledir='logs';
+     }
+ 
+     showmessage(getmessage('StartUpdateApache'), 'none');
+ 
+     my $httpdconf;
+     my $envmodule=0;
+     my $includesmodule=0;
+     open HC, $::realhttpdconf;
+     while (<HC>) {
+ 	if (/^\s*#\s*LoadModule env_module /) {
+ 	    s/^\s*#\s*//;
+ 	    showmessage(getmessage('LoadingApacheModuleModEnv'));
+ 	    $envmodule=1;
+ 	}
+ 	if (/^\s*#\s*LoadModule includes_module /) {
+ 	    s/^\s*#\s*//;
+ 	    showmessage(getmessage('LoadingApacheModuleModInc'));
+ 	}
+ 	if (/\s*LoadModule includes_module / ) {
+ 	    $includesmodule=1;
+ 	}
+ 	$httpdconf.=$_;
+     }
+ 
+     my $backupfailed=0;
+     $backupfailed=`cp -f $::realhttpdconf $::realhttpdconf\.prekoha`;
+     if ($backupfailed) {
+ 	showmessage(getmessage('ApacheConfigBackupFailed', [$::realhttpdconf,$backupfailed ]), 'PressEnter');
+ 	return;
+     }
+ 
+     if ($envmodule || $includesmodule) {
+ 	open HC, ">$::realhttpdconf";
+ 	print HC $httpdconf;
+ 	close HC;
+     }
+ 
+ 
+     
+     if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
+ 	showmessage(getmessage('ApacheAlreadyConfigured'), 'PressEnter');
+ 	return;
+     } else {
+ 	my $includesdirectives='';
+ 	if ($includesmodule) {
+ 	    $includesdirectives.="Options +Includes\n";
+ 	    $includesdirectives.="   AddHandler server-parsed .html\n";
+ 	}
+ 	open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
+ 	my $opaclisten = '';
+ 	if ($::opacport != 80) {
+ 	    $opaclisten="Listen $::opacport";
+ 	}
+ 	my $intranetlisten = '';
+ 	if ($::intranetport != 80) {
+ 	    $intranetlisten="Listen $::intranetport";
+ 	}
+ 	print SITE <<EOP
+ 
+ # Ports to listen to for Koha
+ $opaclisten
+ $intranetlisten
+ 
+ # NameVirtualHost is used by one of the optional configurations detailed below
+ 
+ #NameVirtualHost 11.22.33.44
+ 
+ # KOHA's OPAC Configuration
+ <VirtualHost $::servername\:$::opacport>
+    ServerAdmin $::svr_admin
+    DocumentRoot $::opacdir/htdocs
+    ServerName $::servername
+    ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
+    ErrorLog $logfiledir/opac-error_log
+    TransferLog $logfiledir/opac-access_log
+    SetEnv PERL5LIB "$::intranetdir/modules"
+    $includesdirectives
+ </VirtualHost>
+ 
+ # KOHA's INTRANET Configuration
+ <VirtualHost $::servername\:$::intranetport>
+    ServerAdmin $::svr_admin
+    DocumentRoot $::intranetdir/htdocs
+    ServerName $::servername
+    ScriptAlias /cgi-bin/koha/ "$::intranetdir/cgi-bin/"
+    ErrorLog $logfiledir/koha-error_log
+    TransferLog $logfiledir/koha-access_log
+    SetEnv PERL5LIB "$::intranetdir/modules"
+    $includesdirectives
+ </VirtualHost>
+ 
+ # If you want to use name based Virtual Hosting:
+ #   1. remove the two Listen lines
+ #   2. replace $::servername\:$::opacport wih your.opac.domain.name
+ #   3. replace ServerName $::servername wih ServerName your.opac.domain.name
+ #   4. replace $::servername\:$::intranetport wih your intranet domain name
+ #   5. replace ServerName $::servername wih ServerName your.intranet.domain.name
+ #
+ # If you want to use NameVirtualHost'ing (using two names on one ip address):
+ #   1.  Follow steps 1-5 above
+ #   2.  Uncomment the NameVirtualHost line and set the correct ip address
+ 
+ EOP
+ 
+ 
+     }
  }
+ 
+ $messages->{'IntranetAuthenticationQuestion'}->{en}=qq|
+ ===========================
+ = INTRANET AUTHENTICATION =
+ ===========================
+ 
+ I can set it up so that the Intranet/Librarian site is password protected using
+ Apache's Basic Authorization.
+ 
+ Would you like to do this ([Y]/N): |;
+ 
+ $messages->{'BasicAuthUsername'}->{en}="Please enter a userid for intranet access [%s]: ";
+ $messages->{'BasicAuthPassword'}->{en}="Please enter a password for %s: ";
+ $messages->{'BasicAuthPasswordWasBlank'}->{en}="\nYou cannot use a blank password!\n\n";
+ 
+ sub basicauthentication {
+     my $message=getmessage('IntranetAuthenticationQuestion');
+     my $answer=showmessage($message, 'yn', 'y');
+ 
+     my $apacheauthusername='librarian';
+     my $apacheauthpassword='';
+     if ($answer=~/^y/i) {
+ 	($apacheauthusername) = showmessage(getmessage('BasicAuthUsername', [ $apacheauthusername]), 'free', $apacheauthusername, 1);
+ 	$apacheauthusername=~s/[^a-zA-Z0-9]//g;
+ 	while (! $apacheauthpassword) {
+ 	    ($apacheauthpassword) = showmessage(getmessage('BasicAuthPassword', [ $apacheauthusername]), 'free', 1);
+ 	    if (!$apacheauthpassword) {
+ 		($apacheauthpassword) = showmessage(getmessage('BasicAuthPasswordWasBlank'), 'none', '', 1);
+ 	    }
+ 	}
+ 	open AUTH, ">/etc/kohaintranet.pass";
+ 	my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+ 	my $salt=substr($chars, int(rand(length($chars))),1);
+ 	$salt.=substr($chars, int(rand(length($chars))),1);
+ 	print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
+ 	close AUTH;
+ 	open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
+ 	print SITE <<EOP
+ 
+ <Directory $::intranetdir>
+     AuthUserFile /etc/kohaintranet.pass
+     AuthType Basic
+     AuthName "Koha Intranet (for librarians only)"
+     Require  valid-user
+ </Directory>
+ EOP
+     }
+     close(SITE);
+ }
+ 
+ 
  
  





More information about the Koha-cvs mailing list