1 package Install; #assumes Install.pm
4 # Copyright 2000-2002 Katipo Communications
6 # This file is part of Koha.
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA 02111-1307 USA
24 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
26 # set the version for version checking
30 @EXPORT = qw( &checkperlmodules
33 &releasecandidatewarning
34 &getinstallationdirectories
50 $messages->{'continuing'}->{en}="Great! Continuing setup.\n\n";
51 $messages->{'WelcomeToKohaInstaller'}->{en}=qq|
52 =================================
53 = Welcome to the Koha Installer =
54 =================================
56 Welcome to the Koha install script! This script will prompt you for some
57 basic information about your desired setup, then install Koha according to
58 your specifications. To accept the default value for any question, simply hit
61 Please be sure to read the documentation, or visit the Koha website at
62 http://www.koha.org for more information.
64 Are you ready to begin the installation? (Y/[N]): |;
65 $messages->{'ReleaseCandidateWarning'}->{en}=qq|
70 WARNING WARNING WARNING WARNING WARNING
72 You are about to install Koha version %s. This version of Koha is a
73 release candidate. It is not intended to be installed on production systems.
74 It is being released so that users can test it before we release a final
77 Are you sure you want to install Koha %s? (Y/[N]): |;
78 $messages->{'WatchForReleaseAnnouncements'}->{en}=qq|
80 Watch for announcements of Koha releases on the Koha mailing list or the Koha
81 web site (http://www.koha.org/).
85 $messages->{'NETZ3950Missing'}->{en}=qq|
87 The Net::Z3950 module is missing. This module is necessary if you want to use
88 Koha's Z39.50 client to download bibliographic records from other libraries.
89 To install this module, you will need the yaz client installed from
90 http://www.indexdata.dk/yaz/ and then you can install the perl module with the
93 perl -MCPAN -e 'install Net::Z3950'
95 Press the <ENTER> key to continue: |;
97 $messages->{'CheckingPerlModules'}->{en}=qq|
103 Checking perl modules ...
106 $messages->{'PerlVersionFailure'}->{en}="Sorry, you need at least Perl %s\n";
108 $messages->{'MissingPerlModules'}->{en}=qq|
110 ========================
111 = MISSING PERL MODULES =
112 ========================
114 You are missing some Perl modules which are required by Koha.
115 Once these modules have been installed, rerun this installer.
116 They can be installed by running (as root) the following:
121 $messages->{'AllPerlModulesInstalled'}->{en}=qq|
123 ==============================
124 = ALL PERL MODULES INSTALLED =
125 ==============================
127 All mandatory perl modules are installed.
129 Press <ENTER> to continue: |;
130 $messages->{'KohaVersionInstalled'}->{en}="You currently have Koha %s on your system.";
131 $messages->{'KohaUnknownVersionInstalled'}->{en}="I am not able to determine what version of Koha is installed now.";
132 $messages->{'KohaAlreadyInstalled'}->{en}=qq|
133 ==========================
134 = Koha already installed =
135 ==========================
137 It looks like Koha is already installed on your system (/etc/koha.conf exists
138 already). If you would like to upgrade your system to %s, please use
139 the koha.upgrade script in this directory.
144 $messages->{'GetOpacDir'}->{en}=qq|
149 Please supply the directory you want Koha to store its OPAC files in. This
150 directory will be auto-created for you if it doesn't exist.
152 OPAC Directory [%s]: |;
154 $messages->{'GetIntranetDir'}->{en}=qq|
155 =================================
156 = INTRANET/LIBRARIANS DIRECTORY =
157 =================================
159 Please supply the directory you want Koha to store its Intranet/Librarians
160 files in. This directory will be auto-created for you if it doesn't exist.
162 Intranet Directory [%s]: |;
164 $messages->{'GetKohaLogDir'}->{en}=qq|
165 ======================
166 = KOHA LOG DIRECTORY =
167 ======================
169 Specify a log directory where any Koha daemons can create log files.
171 Koha Log Directory [%s]: |;
173 $messages->{'AuthenticationWarning'}->{en}=qq|
178 This release of Koha has a new authentication module. If you are not already
179 using basic authentication on your intranet, you will be required to log in to
180 access some of the features of the intranet. You can log in using the userid
181 and password from the /etc/koha.conf configuration file at any time. Use the
182 "Members" module to add passwords for other accounts and set their permissions.
184 Press the <ENTER> key to continue: |;
186 $messages->{'Completed'}->{en}=qq|
187 ==============================
188 = KOHA INSTALLATION COMPLETE =
189 ==============================
191 Congratulations ... your Koha installation is complete!
193 You will be able to connect to your Librarian interface at:
197 and the OPAC interface at :
201 Be sure to read the INSTALL, and Hints files.
203 For more information visit http://www.koha.org
205 Press <ENTER> to exit the installer: |;
207 sub releasecandidatewarning {
208 my $message=getmessage('ReleaseCandidateWarning', [$::newversion, $::newversion]);
209 my $answer=showmessage($message, 'yn', 'n');
211 if ($answer =~ /y/i) {
212 print getmessage('continuing');
214 my $message=getmessage('WatchForReleaseAnnouncements');
222 # Test for Perl and Modules
225 sub checkperlmodules {
226 my $message = getmessage('CheckingPerlModules');
227 showmessage($message, 'none');
229 unless (eval "require 5.006_000") {
230 die getmessage('PerlVersionFailure', ['5.6.0']);
234 unless (eval {require DBI}) { push @missing,"DBI" };
235 unless (eval {require Date::Manip}) { push @missing,"Date::Manip" };
236 unless (eval {require DBD::mysql}) { push @missing,"DBD::mysql" };
237 unless (eval {require HTML::Template}) { push @missing,"HTML::Template" };
238 unless (eval {require Set::Scalar}) { push @missing,"Set::Scalar" };
239 unless (eval {require Digest::MD5}) { push @missing,"Digest::MD5" };
240 unless (eval {require MARC::Record}) { push @missing,"MARC::Record" };
241 unless (eval {require Net::Z3950}) {
242 my $message = getmessage('NETZ3950Missing');
243 showmessage($message, 'PressEnter', '', 1);
245 push @missing, "Net::Z3950";
250 # Print out a list of any missing modules
255 foreach my $module (@missing) {
256 $missing.=" perl -MCPAN -e 'install \"$module\"'\n";
258 my $message=getmessage('MissingPerlModules', [$missing]);
259 showmessage($message, 'none');
262 showmessage(getmessage('AllPerlModulesInstalled'), 'PressEnter', '', 1);
266 unless (-x "/usr/bin/perl") {
267 my $realperl=`which perl`;
269 $realperl = showmessage(getmessage('NoUsrBinPerl'), 'none');
270 until (-x $realperl) {
271 $realperl=showmessage(getmessage('AskLocationOfPerlExecutable', $realperl), 'free', $realperl, 1);
273 my $response=showmessage(getmessage('ConfirmPerlExecutableSymlink', $realperl), 'yn', 'y', 1);
274 unless ($response eq 'n') {
275 system("ln -s $realperl /usr/bin/perl");
282 $messages->{'NoUsrBinPerl'}->{en}=qq|
284 ========================================
285 = Perl is not located in /usr/bin/perl =
286 ========================================
288 The Koha perl scripts expect to find the perl executable in the /usr/bin
289 directory. It is not there on your system.
293 $messages->{'AskLocationOfPerlExecutable'}->{en}=qq|Location of Perl Executable: [%s]: |;
294 $messages->{'ConfirmPerlExecutableSymlink'}->{en}=qq|
295 The Koha scripts will _not_ work without a symlink from %s to /usr/bin/perl
297 May I create this symlink? ([Y]/N):
301 my $messagename=shift;
303 my $message=$messages->{$messagename}->{$::language} || $messages->{$messagename}->{en} || "Error: No message named $messagename in Install.pm\n";
304 if (defined($variables)) {
305 $message=sprintf $message, @$variables;
313 my $responsetype=shift;
314 my $defaultresponse=shift;
316 ($noclear) || (system('clear'));
317 if ($responsetype =~ /^yn$/) {
318 $responsetype='restrictchar yn';
322 if ($responsetype =~/^restrictchar (.*)/i) {
325 until ($options=~/$response/) {
326 ($defaultresponse) || ($defaultresponse=substr($options,0,1));
329 (length($response)) || ($response=$defaultresponse);
330 unless ($options=~/$response/) {
331 ($noclear) || (system('clear'));
332 print "Invalid Response. Choose from [$options].\n\n";
338 if ($responsetype =~/^free$/i) {
339 (defined($defaultresponse)) || ($defaultresponse='');
340 my $response=<STDIN>;
342 ($response) || ($response=$defaultresponse);
345 if ($responsetype =~/^numerical$/i) {
346 (defined($defaultresponse)) || ($defaultresponse='');
348 until ($response=~/^\d+$/) {
351 ($response) || ($response=$defaultresponse);
352 unless ($response=~/^\d+$/) {
353 ($noclear) || (system('clear'));
354 print "Invalid Response ($response). Response must be a number.\n\n";
360 if ($responsetype =~/^email$/i) {
361 (defined($defaultresponse)) || ($defaultresponse='');
363 until ($response=~/.*\@.*\..*/) {
366 ($response) || ($response=$defaultresponse);
367 unless ($response=~/.*\@.*\..*/) {
368 ($noclear) || (system('clear'));
369 print "Invalid Response ($response). Response must be a valid email address.\n\n";
375 if ($responsetype =~/^PressEnter$/i) {
379 if ($responsetype =~/^none$/i) {
385 sub getinstallationdirectories {
386 $::opacdir = '/usr/local/koha/opac';
387 $::intranetdir = '/usr/local/koha/intranet';
389 while ($getdirinfo) {
390 # Loop until opac directory and koha directory are different
391 my $message=getmessage('GetOpacDir', [$::opacdir]);
392 $::opacdir=showmessage($message, 'free', $::opacdir);
394 $message=getmessage('GetIntranetDir', [$::intranetdir]);
395 $::intranetdir=showmessage($message, 'free', $::intranetdir);
397 if ($::intranetdir eq $::opacdir) {
400 You must specify different directories for the OPAC and INTRANET files!
401 :: $::intranetdir :: $::opacdir ::
408 $::kohalogdir='/var/log/koha';
409 my $message=getmessage('GetKohaLogDir', [$::kohalogdir]);
410 $::kohalogdir=showmessage($message, 'free', $::kohalogdir);
413 unless ( -d $::intranetdir ) {
414 my $result=mkdir ($::intranetdir, oct(770));
416 my @dirs = split(m#/#, $::intranetdir);
420 unless (-e "$checkdir") {
421 mkdir($checkdir, 0775);
425 chown (oct(0), (getgrnam($::httpduser))[2], "$::intranetdir");
426 chmod (oct(770), "$::intranetdir");
428 unless ( -d "$::intranetdir/htdocs" ) {
429 mkdir ("$::intranetdir/htdocs", oct(750));
431 unless ( -d "$::intranetdir/cgi-bin" ) {
432 mkdir ("$::intranetdir/cgi-bin", oct(750));
434 unless ( -d "$::intranetdir/modules" ) {
435 mkdir ("$::intranetdir/modules", oct(750));
437 unless ( -d "$::intranetdir/scripts" ) {
438 mkdir ("$::intranetdir/scripts", oct(750));
440 unless ( -d $::opacdir ) {
441 my $result=mkdir ($::opacdir, oct(770));
443 my @dirs = split(m#/#, $::opacdir);
447 unless (-e "$checkdir") {
448 mkdir($checkdir, 0775);
452 chown (oct(0), (getgrnam($::httpduser))[2], "$::opacdir");
453 chmod (oct(770), "$::opacdir");
455 unless ( -d "$::opacdir/htdocs" ) {
456 mkdir ("$::opacdir/htdocs", oct(750));
458 unless ( -d "$::opacdir/cgi-bin" ) {
459 mkdir ("$::opacdir/cgi-bin", oct(750));
463 unless ( -d $::kohalogdir ) {
464 my $result=mkdir ($::kohalogdir, oct(770));
466 my @dirs = split(m#/#, $::kohalogdir);
470 unless (-e "$checkdir") {
471 mkdir($checkdir, 0775);
476 chown (oct(0), (getgrnam($::httpduser))[2,3], "$::kohalogdir");
477 chmod (oct(770), "$::kohalogdir");
483 $messages->{'DatabaseName'}->{en}=qq|
484 ==========================
485 = Name of MySQL database =
486 ==========================
488 Please provide the name of the mysql database for your koha installation.
490 Database name [%s]: |;
492 $messages->{'DatabaseHost'}->{en}=qq|
497 Please provide the hostname for mysql. Unless the database is located on
498 another machine this will be "localhost".
500 Database host [%s]: |;
502 $messages->{'DatabaseUser'}->{en}=qq|
507 Please provide the name of the user, who will have full administrative rights
508 to the %s database, when authenticating from %s.
510 Database user [%s]: |;
512 $messages->{'DatabasePassword'}->{en}=qq|
513 =====================
514 = Database Password =
515 =====================
517 Please provide a good password for the user %s.
519 Database Password: |;
521 $messages->{'BlankPassword'}->{en}=qq|
526 You must not use a blank password for your MySQL user!
528 Press <ENTER> to try again:
531 sub getdatabaseinfo {
534 $::hostname = 'localhost';
535 $::user = 'kohaadmin';
538 #Get the database name
540 my $message=getmessage('DatabaseName', [$::dbname]);
541 $::dbname=showmessage($message, 'free', $::dbname);
543 #Get the hostname for the database
545 $message=getmessage('DatabaseHost', [$::hostname]);
546 $::hostname=showmessage($message, 'free', $::hostname);
548 #Get the username for the database
550 $message=getmessage('DatabaseUser', [$::dbname, $::hostname, $::user]);
551 $::user=showmessage($message, 'free', $::user);
553 #Get the password for the database user
555 while ($::pass eq '') {
556 my $message=getmessage('DatabasePassword', [$::user]);
557 $::pass=showmessage($message, 'free', $::pass);
559 my $message=getmessage('BlankPassword');
560 showmessage($message,'PressEnter');
567 $messages->{'FoundMultipleApacheConfFiles'}->{en}=qq|
568 ================================
569 = MULTIPLE APACHE CONFIG FILES =
570 ================================
572 I found more than one possible Apache configuration file:
576 Choose the correct file [1]: |;
578 $messages->{'NoApacheConfFiles'}->{en}=qq|
579 ===============================
580 = NO APACHE CONFIG FILE FOUND =
581 ===============================
583 I was not able to find your Apache configuration file.
585 The file is usually called httpd.conf or apache.conf.
587 Please specify the location of your config file: |;
589 $messages->{'NotAFile'}->{en}=qq|
590 =======================
591 = FILE DOES NOT EXIST =
592 =======================
594 The file %s does not exist.
596 Please press <ENTER> to continue: |;
598 $messages->{'EnterApacheUser'}->{en}=qq|
603 I was not able to determine the user that Apache is running as. This
604 information is necessary in order to set the access privileges correctly on
605 /etc/koha.conf. This user should be set in one of the Apache configuration
606 files using the "User" directive.
608 Enter the Apache userid: |;
610 $messages->{'InvalidUserid'}->{en}=qq|
615 The userid %s is not a valid userid on this system.
617 Press <ENTER> to continue: |;
620 my @confpossibilities;
622 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
623 /usr/local/etc/apache/httpd.conf
624 /usr/local/etc/apache/apache.conf
625 /var/www/conf/httpd.conf
626 /etc/apache/conf/httpd.conf
627 /etc/apache/conf/apache.conf
628 /etc/apache-ssl/conf/apache.conf
629 /etc/apache-ssl/httpd.conf
630 /etc/httpd/conf/httpd.conf
631 /etc/httpd/httpd.conf)) {
632 if ( -f $httpdconf ) {
633 push @confpossibilities, $httpdconf;
637 if ($#confpossibilities==-1) {
638 my $message=getmessage('NoApacheConfFiles');
641 $choice=showmessage($message, "free", 1);
643 $::realhttpdconf=$choice;
645 showmessage(getmessage('NotAFile', [$choice]),'PressEnter', '', 1);
648 } elsif ($#confpossibilities>0) {
652 foreach (@confpossibilities) {
653 $conffiles.=" $counter: $_\n";
654 $options.="$counter";
657 my $message=getmessage('FoundMultipleApacheConfFiles', [$conffiles]);
658 my $choice=showmessage($message, "restrictchar $options", 1);
659 $::realhttpdconf=$confpossibilities[$choice-1];
661 $::realhttpdconf=$confpossibilities[0];
663 unless (open (HTTPDCONF, $::realhttpdconf)) {
664 warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
668 while (<HTTPDCONF>) {
669 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
678 unless ($::httpduser) {
679 my $message=getmessage('EnterApacheUser');
680 until (length($::httpduser) && getpwnam($::httpduser)) {
681 $::httpduser=showmessage($message, "free", '');
682 if (length($::httpduser)>0) {
683 unless (getpwnam($::httpduser)) {
684 my $message=getmessage('InvalidUserid', [$::httpduser]);
685 showmessage($message,'PressEnter');
690 print "AU: $::httpduser\n";
695 $messages->{'ApacheConfigIntroduction'}->{en}=qq|
696 ========================
697 = APACHE CONFIGURATION =
698 ========================
700 Koha needs to setup your Apache configuration file for the
701 OPAC and LIBRARIAN virtual hosts. By default this installer
702 will do this by using one ip address and two different ports
703 for the virtual hosts. There are other ways to set this up,
704 and the installer will leave comments in httpd.conf detailing
705 what these other options are.
708 Press <ENTER> to continue: |;
710 $messages->{'GetVirtualHostEmail'}->{en}=qq|
711 =============================
712 = WEB SERVER E-MAIL CONTACT =
713 =============================
715 Enter the e-mail address to be used as a contact for the virtual hosts (this
716 address is displayed if any errors are encountered).
718 E-mail contact [%s]: |;
720 $messages->{'GetServerName'}->{en}=qq|
721 ======================================
722 = WEB SERVER HOST NAME OR IP ADDRESS =
723 ======================================
725 Please enter the domain name or ip address of your computer.
727 Host name or IP Address [%s]: |;
729 $messages->{'GetOpacPort'}->{en}=qq|
730 ==========================
731 = OPAC VIRTUAL HOST PORT =
732 ==========================
734 Please enter the port for your OPAC interface. This defaults to port 80, but
735 if you are already serving web content from this server, you should change it
736 to a different port (8000 might be a good choice).
738 Enter the OPAC Port [%s]: |;
740 $messages->{'GetIntranetPort'}->{en}=qq|
741 ==============================
742 = INTRANET VIRTUAL HOST PORT =
743 ==============================
745 Please enter the port for your Intranet interface. This must be different from
748 Enter the Intranet Port [%s]: |;
751 sub getapachevhostinfo {
753 $::svr_admin = "webmaster\@$::domainname";
754 $::servername=`hostname -f`;
757 $::intranetport=8080;
759 showmessage(getmessage('ApacheConfigIntroduction'), 'PressEnter');
761 $::svr_admin=showmessage(getmessage('GetVirtualHostEmail', [$::svr_admin]), 'email', $::svr_admin);
762 $::servername=showmessage(getmessage('GetServerName', [$::servername]), 'free', $::servername);
765 $::opacport=showmessage(getmessage('GetOpacPort', [$::opacport]), 'numerical', $::opacport);
766 $::intranetport=showmessage(getmessage('GetIntranetPort', [$::opacport, $::intranetport]), 'numerical', $::intranetport);
770 $messages->{'StartUpdateApache'}->{en}=qq|
771 =================================
772 = UPDATING APACHE CONFIGURATION =
773 =================================
775 Checking for modules that need to be loaded...
778 $messages->{'LoadingApacheModuleModEnv'}->{en}="Loading SetEnv Apache module.\n";
780 $messages->{'LoadingApacheModuleModInc'}->{en}="Loading Includes Apache module.\n";
782 $messages->{'ApacheConfigBackupFailed'}->{en}=qq|
783 ======================================
784 = APACHE CONFIGURATION BACKUP FAILED =
785 ======================================
787 An error occurred while trying to make a backup copy of %s.
791 No changes will be made to the apache configuration file at this time.
793 Press <ENTER> to continue: |;
796 $messages->{'ApacheAlreadyConfigured'}->{en}=qq|
797 =============================
798 = APACHE ALREADY CONFIGURED =
799 =============================
801 %s appears to already have an entry for Koha
802 Virtual Hosts. You may need to edit %s
803 f anything has changed since it was last set up. This
804 script will not attempt to modify an existing Koha apache
807 Press <ENTER> to continue: |;
809 sub updateapacheconf {
810 my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
814 $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
818 unless ($logfiledir) {
822 showmessage(getmessage('StartUpdateApache'), 'none');
826 my $includesmodule=0;
827 open HC, $::realhttpdconf;
829 if (/^\s*#\s*LoadModule env_module /) {
831 showmessage(getmessage('LoadingApacheModuleModEnv'));
834 if (/^\s*#\s*LoadModule includes_module /) {
836 showmessage(getmessage('LoadingApacheModuleModInc'));
838 if (/\s*LoadModule includes_module / ) {
845 $backupfailed=`cp -f $::realhttpdconf $::realhttpdconf\.prekoha`;
847 showmessage(getmessage('ApacheConfigBackupFailed', [$::realhttpdconf,$backupfailed ]), 'PressEnter');
851 if ($envmodule || $includesmodule) {
852 open HC, ">$::realhttpdconf";
859 if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
860 showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
863 my $includesdirectives='';
864 if ($includesmodule) {
865 $includesdirectives.="Options +Includes\n";
866 $includesdirectives.=" AddHandler server-parsed .html\n";
868 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
870 if ($::opacport != 80) {
871 $opaclisten="Listen $::opacport";
873 my $intranetlisten = '';
874 if ($::intranetport != 80) {
875 $intranetlisten="Listen $::intranetport";
879 # Ports to listen to for Koha
883 # NameVirtualHost is used by one of the optional configurations detailed below
885 #NameVirtualHost 11.22.33.44
887 # KOHA's OPAC Configuration
888 <VirtualHost $::servername\:$::opacport>
889 ServerAdmin $::svr_admin
890 DocumentRoot $::opacdir/htdocs
891 ServerName $::servername
892 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
893 ErrorLog $logfiledir/opac-error_log
894 TransferLog $logfiledir/opac-access_log
895 SetEnv PERL5LIB "$::intranetdir/modules"
899 # KOHA's INTRANET Configuration
900 <VirtualHost $::servername\:$::intranetport>
901 ServerAdmin $::svr_admin
902 DocumentRoot $::intranetdir/htdocs
903 ServerName $::servername
904 ScriptAlias /cgi-bin/koha/ "$::intranetdir/cgi-bin/"
905 ErrorLog $logfiledir/koha-error_log
906 TransferLog $logfiledir/koha-access_log
907 SetEnv PERL5LIB "$::intranetdir/modules"
911 # If you want to use name based Virtual Hosting:
912 # 1. remove the two Listen lines
913 # 2. replace $::servername\:$::opacport wih your.opac.domain.name
914 # 3. replace ServerName $::servername wih ServerName your.opac.domain.name
915 # 4. replace $::servername\:$::intranetport wih your intranet domain name
916 # 5. replace ServerName $::servername wih ServerName your.intranet.domain.name
918 # If you want to use NameVirtualHost'ing (using two names on one ip address):
919 # 1. Follow steps 1-5 above
920 # 2. Uncomment the NameVirtualHost line and set the correct ip address
928 $messages->{'IntranetAuthenticationQuestion'}->{en}=qq|
929 ===========================
930 = INTRANET AUTHENTICATION =
931 ===========================
933 I can set it up so that the Intranet/Librarian site is password protected using
934 Apache's Basic Authorization.
936 Would you like to do this ([Y]/N): |;
938 $messages->{'BasicAuthUsername'}->{en}="Please enter a userid for intranet access [%s]: ";
939 $messages->{'BasicAuthPassword'}->{en}="Please enter a password for %s: ";
940 $messages->{'BasicAuthPasswordWasBlank'}->{en}="\nYou cannot use a blank password!\n\n";
942 sub basicauthentication {
943 my $message=getmessage('IntranetAuthenticationQuestion');
944 my $answer=showmessage($message, 'yn', 'y');
946 my $apacheauthusername='librarian';
947 my $apacheauthpassword='';
948 if ($answer=~/^y/i) {
949 ($apacheauthusername) = showmessage(getmessage('BasicAuthUsername', [ $apacheauthusername]), 'free', $apacheauthusername, 1);
950 $apacheauthusername=~s/[^a-zA-Z0-9]//g;
951 while (! $apacheauthpassword) {
952 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPassword', [ $apacheauthusername]), 'free', 1);
953 if (!$apacheauthpassword) {
954 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPasswordWasBlank'), 'none', '', 1);
957 open AUTH, ">/etc/kohaintranet.pass";
958 my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
959 my $salt=substr($chars, int(rand(length($chars))),1);
960 $salt.=substr($chars, int(rand(length($chars))),1);
961 print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
963 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
966 <Directory $::intranetdir>
967 AuthUserFile /etc/kohaintranet.pass
969 AuthName "Koha Intranet (for librarians only)"
977 $messages->{'InstallFiles'}->{en}=qq|
982 Copying files to installation directories:
987 $messages->{'CopyingFiles'}->{en}="Copying %s to %s.\n";
994 showmessage(getmessage('InstallFiles'),'none');
995 print getmessage('CopyingFiles', ['intranet-html', "$::intranetdir/htdocs" ]);
996 system("cp -R intranet-html/* $::intranetdir/htdocs/");
997 print getmessage('CopyingFiles', ['intranet-cgi', "$::intranetdir/cgi-bin" ]);
998 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
999 print getmessage('CopyingFiles', ['stand-alone scripts', "$::intranetdir/scripts" ]);
1000 system("cp -R scripts/* $::intranetdir/scripts/");
1001 print getmessage('CopyingFiles', ['perl modules', "$::intranetdir/modules" ]);
1002 system("cp -R modules/* $::intranetdir/modules/");
1003 print getmessage('CopyingFiles', ['opac-html', "$::opacdir/htdocs" ]);
1004 system("cp -R opac-html/* $::opacdir/htdocs/");
1005 print getmessage('CopyingFiles', ['opac-cgi', "$::opacdir/cgi-bin" ]);
1006 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
1007 system("touch $::opacdir/cgi-bin/opac");
1009 system("chown -R root.$::httpduser $::opacdir");
1010 system("chown -R root.$::httpduser $::intranetdir");
1012 # Create /etc/koha.conf
1014 my $old_umask = umask(027); # make sure koha.conf is never world-readable
1015 open(SITES,">$::etcdir/koha.conf.tmp") or warn "Couldn't create file at $::etcdir. Must have write capability.\n";
1018 hostname=$::hostname
1021 includes=$::intranetdir/htdocs/includes
1022 intranetdir=$::intranetdir
1024 kohalogdir=$::kohalogdir
1025 kohaversion=$::kohaversion
1026 httpduser=$::httpduser
1027 intrahtdocs=$::intranetdir/htdocs/intranet-tmpl
1028 opachtdocs=$::opacdir/htdocs/opac-tmpl
1033 chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf.tmp") or warn "can't chown koha.conf: $!";
1034 chmod 0440, "$::etcdir/koha.conf.tmp";
1036 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
1037 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
1038 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
1039 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
1040 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
1044 $messages->{'MysqlRootPassword'}->{en}=qq|
1045 ============================
1046 = MYSQL ROOT USER PASSWORD =
1047 ============================
1049 To allow us to create the koha database please supply your
1050 mysql server's root user password:
1052 Enter MySql root user password: |;
1054 $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password. Please try again.";
1056 $messages->{'CreatingDatabase'}->{en}=qq|
1057 =====================
1058 = CREATING DATABASE =
1059 =====================
1061 Creating the MySql database for Koha...
1065 $messages->{'CreatingDatabaseError'}->{en}=qq|
1066 ===========================
1067 = ERROR CREATING DATABASE =
1068 ===========================
1070 Couldn't connect to the MySQL server for the reason given above.
1071 This is a serious problem, the database will not get installed.
\a
1073 Press <ENTER> to continue: |;
1075 $messages->{'SampleData'}->{en}=qq|
1080 If you are installing Koha for evaluation purposes, I have a batch of sample
1081 data that you can install now.
1083 If you are installing Koha with the intention of populating it with your own
1084 data, you probably don't want this sample data installed.
1086 Would you like to install the sample data? Y/[N]: |;
1088 $messages->{'SampleDataInstalled'}->{en}=qq|
1089 =========================
1090 = SAMPLE DATA INSTALLED =
1091 =========================
1093 Sample data has been installed. For some suggestions on testing Koha, please
1094 read the file doc/HOWTO-Testing. If you find any bugs, please submit them at
1095 http://bugs.koha.org/. If you need help with testing Koha, you can post a
1096 question through the koha-devel mailing list, or you can check for a developer
1097 online at +irc.katipo.co.nz:6667 channel #koha.
1099 You can find instructions for subscribing to the Koha mailing lists at:
1104 Press <ENTER> to continue: |;
1106 $messages->{'AddBranchPrinter'}->{en}=qq|
1107 ==========================
1108 = Add Branch and Printer =
1109 ==========================
1111 Would you like to install an initial branch and printer? [Y]/N: |;
1113 $messages->{'BranchName'}->{en}="Branch Name [%s]: ";
1114 $messages->{'BranchCode'}->{en}="Branch Code (4 letters or numbers) [%s]: ";
1115 $messages->{'PrinterQueue'}->{en}="Printer Queue [%s]: ";
1116 $messages->{'PrinterName'}->{en}="Printer Name [%s]: ";
1117 $messages->{'BlankMysqlPassword'}->{en}=qq|
1118 ========================
1119 = Blank MySql Password =
1120 ========================
1122 Do not leave your MySql root password blank unless you know exactly what you
1123 are doing. To change your MySql root password use the mysqladmin command:
1125 mysqladmin password NEWPASSWORDHERE
1127 Press <ENTER> to continue:
1131 $::mysqluser = 'root';
1134 foreach my $mysql (qw(/usr/local/mysql
1138 if ( -d $mysql && -f "$mysql/bin/mysqladmin") {
1143 print "I don't see mysql in the usual places.\n";
1145 print "Where have you installed mysql? ";
1146 chomp($::mysqldir = <STDIN>);
1147 last if -f "$::mysqldir/bin/mysqladmin";
1150 I can't find it there either. If you compiled mysql yourself,
1151 please give the value of --prefix when you ran configure.
1153 The file mysqladmin should be in bin/mysqladmin under the directory that you
1162 while ($needpassword) {
1163 $::mysqlpass=showmessage(getmessage('MysqlRootPassword'), 'free');
1164 $::mysqlpass_quoted = $::mysqlpass;
1165 $::mysqlpass_quoted =~ s/"/\\"/g;
1166 $::mysqlpass_quoted="-p\"$::mysqlpass_quoted\"";
1167 $::mysqlpass eq '' and $::mysqlpass_quoted='';
1168 my $result=system("$::mysqldir/bin/mysqladmin -u$::mysqluser $::mysqlpass_quoted proc > /dev/null 2>&1");
1170 print getmessage('InvalidMysqlRootPassword');
1172 if ($::mysqlpass eq '') {
1173 showmessage(getmessage('BlankMysqlPassword'), 'PressEnter');
1179 showmessage(getmessage('CreatingDatabase'),'none');
1181 my $result=system("$::mysqldir/bin/mysqladmin", "-u$::mysqluser", "-p$::mysqlpass", "create", "$::dbname");
1183 showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1);
1185 # Populate the Koha database
1186 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname < koha.mysql");
1187 # Set up permissions
1188 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;");
1189 system("$::mysqldir/bin/mysql -u$::mysqluser $::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')\"");
1190 system("$::mysqldir/bin/mysqladmin -u$::mysqluser $::mysqlpass_quoted reload");
1200 $messages->{'UpdateMarcTables'}->{en}=qq|
1201 =========================================
1202 = UPDATING MARC FIELD DEFINITION TABLES =
1203 =========================================
1205 You can import marc parameters for :
1211 Please choose which parameter you want to install. Note if you choose 3,
1212 nothing will be added, and it can be a BIG job to manually create those tables
1214 Choose MARC definition [1]: |;
1216 $messages->{'Language'}->{en}=qq|
1217 ====================
1218 = CHOOSE LANGUAGES =
1219 ====================
1220 This version of koha supports a few languages.
1221 Enter you languages preferences : either en, fr or es.
1222 Note that the en is always choosen when the system does not finds the
1223 language you choose in a specific screen.
1224 fr : opac is translated (except pictures)
1225 es : a few intranet is translated (including pictures)
1228 sub updatedatabase {
1229 my $result=system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
1231 print "Problem updating database...\n";
1235 my $response=showmessage(getmessage('UpdateMarcTables'), 'restrictchar 123', '1');
1237 if ($response == 1) {
1238 system("cat script/misc/marc_datas/marc21_en/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1240 if ($response == 2) {
1241 system("cat scripts/misc/marc_datas/unimarc_fr/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1242 system("cat scripts/misc/lang-datas/fr/stopwords.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1245 my $result=system ("perl -I $::intranetdir/modules scripts/marc/updatedb2marc.pl");
1247 print "Problem updating database to MARC...\n";
1251 print "\n\nFinished updating database. Press <ENTER> to continue...";
1255 sub populatedatabase {
1256 my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
1257 if ($response =~/^y/i) {
1258 system("gunzip sampledata-1.2.gz");
1259 system("cat sampledata-1.2 | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
1260 system("gzip -9 sampledata-1.2");
1261 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
1262 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
1263 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\"");
1264 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
1265 showmessage(getmessage('SampleDataInstalled'), 'PressEnter','',1);
1268 my $response=showmessage(getmessage('AddBranchPrinter'), 'yn', 'y');
1270 unless ($response =~/^n/i) {
1271 my $branch='Main Library';
1272 $branch=showmessage(getmessage('BranchName', [$branch]), 'free', $branch, 1);
1273 $branch=~s/[^A-Za-z0-9\s]//g;
1275 my $branchcode=$branch;
1276 $branchcode=~s/[^A-Za-z0-9]//g;
1277 $branchcode=uc($branchcode);
1278 $branchcode=substr($branchcode,0,4);
1279 $branchcode=showmessage(getmessage('BranchCode', [$branchcode]), 'free', $branchcode, 1);
1280 $branchcode=~s/[^A-Za-z0-9]//g;
1281 $branchcode=uc($branchcode);
1282 $branchcode=substr($branchcode,0,4);
1283 $branchcode or $branchcode='DEF';
1285 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
1286 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
1287 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\"");
1289 my $printername='Library Printer';
1290 $printername=showmessage(getmessage('PrinterName', [$printername]), 'free', $printername, 1);
1291 $printername=~s/[^A-Za-z0-9\s]//g;
1293 my $printerqueue='lp';
1294 $printerqueue=showmessage(getmessage('PrinterQueue', [$printerqueue]), 'free', $printerqueue, 1);
1295 $printerqueue=~s/[^A-Za-z0-9]//g;
1296 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
1298 my $language=showmessage(getmessage('Language'), 'free', 'en');
1299 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"update systempreferences set value='$language' where variable='opaclanguages'\"");
1303 $messages->{'RestartApache'}->{en}=qq|
1308 Apache needs to be restarted to load the new configuration for Koha.
1310 Would you like to restart Apache now? [Y]/N: |;
1314 my $response=showmessage(getmessage('RestartApache'), 'yn', 'y');
1318 unless ($response=~/^n/i) {
1319 # Need to support other init structures here?
1320 if (-e "/etc/rc.d/init.d/httpd") {
1321 system('/etc/rc.d/init.d/httpd restart');
1322 } elsif (-e "/etc/init.d/apache") {
1323 system('/etc//init.d/apache restart');
1324 } elsif (-e "/etc/init.d/apache-ssl") {
1325 system('/etc/init.d/apache-ssl restart');
1332 sub loadconfigfile {
1335 open (KC, "/etc/koha.conf");
1338 (next) if (/^\s*#/);
1339 if (/(.*)\s*=\s*(.*)/) {
1342 # Clean up white space at beginning and end
1343 $variable=~s/^\s*//g;
1344 $variable=~s/\s*$//g;
1347 $configfile{$variable}=$value;
1351 $::intranetdir=$configfile{'intranetdir'};
1352 $::opacdir=$configfile{'opacdir'};
1353 $::kohaversion=$configfile{'kohaversion'};
1354 $::kohalogdir=$configfile{'kohalogdir'};
1355 $::database=$configfile{'database'};
1356 $::hostname=$configfile{'hostname'};
1357 $::user=$configfile{'user'};
1358 $::pass=$configfile{'pass'};
1361 END { } # module clean-up code here (global destructor)