1 package Install; #assumes Install.pm
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8 # set the version for version checking
12 @EXPORT = qw( &checkperlmodules
15 &releasecandidatewarning
16 &getinstallationdirectories
30 $messages->{'continuing'}->{en}="Great! Continuing setup.\n\n";
31 $messages->{'WelcomeToKohaInstaller'}->{en}=qq|
32 =================================
33 = Welcome to the Koha Installer =
34 =================================
36 Welcome to the Koha install script! This script will prompt you for some
37 basic information about your desired setup, then install Koha according to
38 your specifications. To accept the default value for any question, simply hit
41 Please be sure to read the documentation, or visit the Koha website at
42 http://www.koha.org for more information.
44 Are you ready to begin the installation? (Y/[N]): |;
45 $messages->{'ReleaseCandidateWarning'}->{en}=qq|
50 WARNING WARNING WARNING WARNING WARNING
52 You are about to install Koha version %s. This version of Koha is a
53 release candidate. It is not intended to be installed on production systems.
54 It is being released so that users can test it before we release a final
57 Are you sure you want to install Koha %s? (Y/[N]): |;
58 $messages->{'WatchForReleaseAnnouncements'}->{en}=qq|
60 Watch for announcements of Koha releases on the Koha mailing list or the Koha
61 web site (http://www.koha.org/).
65 $messages->{'NETZ3950Missing'}->{en}=qq|
67 The Net::Z3950 module is missing. This module is necessary if you want to use
68 Koha's Z39.50 client to download bibliographic records from other libraries.
69 To install this module, you will need the yaz client installed from
70 http://www.indexdata.dk/yaz/ and then you can install the perl module with the
73 perl -MCPAN -e 'install Net::Z3950'
75 Press the <ENTER> key to continue: |;
77 $messages->{'CheckingPerlModules'}->{en}=qq|
83 Checking perl modules ...
86 $messages->{'PerlVersionFailure'}->{en}="Sorry, you need at least Perl %s\n";
88 $messages->{'MissingPerlModules'}->{en}=qq|
90 ========================
91 = MISSING PERL MODULES =
92 ========================
94 You are missing some Perl modules which are required by Koha.
95 Once these modules have been installed, rerun this installer.
96 They can be installed by running (as root) the following:
100 $messages->{'AllPerlModulesInstalled'}->{en}=qq|
102 ==============================
103 = ALL PERL MODULES INSTALLED =
104 ==============================
106 All mandatory perl modules are installed.
108 Press <ENTER> to continue: |;
109 $messages->{'KohaVersionInstalled'}->{en}="You currently have Koha %s on your system.";
110 $messages->{'KohaUnknownVersionInstalled'}->{en}="I am not able to determine what version of Koha is installed now.";
111 $messages->{'KohaAlreadyInstalled'}->{en}=qq|
112 ==========================
113 = Koha already installed =
114 ==========================
116 It looks like Koha is already installed on your system (/etc/koha.conf exists
117 already). If you would like to upgrade your system to %s, please use
118 the koha.upgrade script in this directory.
123 $messages->{'GetOpacDir'}->{en}=qq|
128 Please supply the directory you want Koha to store its OPAC files in. This
129 directory will be auto-created for you if it doesn't exist.
131 OPAC Directory [%s]: |;
133 $messages->{'GetIntranetDir'}->{en}=qq|
134 =================================
135 = INTRANET/LIBRARIANS DIRECTORY =
136 =================================
138 Please supply the directory you want Koha to store its Intranet/Librarians
139 files in. This directory will be auto-created for you if it doesn't exist.
141 Intranet Directory [%s]: |;
143 $messages->{'GetKohaLogDir'}->{en}=qq|
144 ======================
145 = KOHA LOG DIRECTORY =
146 ======================
148 Specify a log directory where any Koha daemons can create log files.
150 Koha Log Directory [%s]: |;
152 $messages->{'AuthenticationWarning'}->{en}=qq|
157 This release of Koha has a new authentication module. If you are not already
158 using basic authentication on your intranet, you will be required to log in to
159 access some of the features of the intranet. You can log in using the userid
160 and password from the /etc/koha.conf configuration file at any time. Use the
161 "Members" module to add passwords for other accounts and set their permissions.
163 [NOTE PERMISSIONS ARE NOT COMPLETED AS OF THIS RELEASE. Do not give passwords
164 to any patrons unless you want them to have full access to your intranet.]
166 Press the <ENTER> key to continue: |;
168 $messages->{'Completed'}->{en}=qq|
169 ==============================
170 = KOHA INSTALLATION COMPLETE =
171 ==============================
173 Congratulations ... your Koha installation is complete!
175 You will be able to connect to your Librarian interface at:
179 and the OPAC interface at :
184 Be sure to read the INSTALL, and Hints files.
186 For more information visit http://www.koha.org
188 Press <ENTER> to exit the installer: |;
190 sub releasecandidatewarning {
191 my $message=getmessage('ReleaseCandidateWarning', [$::kohaversion, $::kohaversion]);
192 my $answer=showmessage($message, 'yn', 'n');
194 if ($answer =~ /y/i) {
195 print getmessage('continuing');
197 my $message=getmessage('WatchForReleaseAnnouncements');
205 # Test for Perl and Modules
208 sub checkperlmodules {
209 my $message = getmessage('CheckingPerlModules');
210 showmessage($message, 'none');
212 unless (eval "require 5.6.0") {
213 die getmessage('PerlVersionFailure', ['5.6.0']);
217 unless (eval {require DBI}) { push @missing,"DBI" };
218 unless (eval {require Date::Manip}) { push @missing,"Date::Manip" };
219 unless (eval {require DBD::mysql}) { push @missing,"DBD::mysql" };
220 unless (eval {require Set::Scalar}) { push @missing,"Set::Scalar" };
221 unless (eval {require Net::Z3950}) {
222 my $message = getmessage('NETZ3950Missing');
223 showmessage($message, 'PressEnter', '', 1);
225 push @missing, "Net::Z3950";
230 # Print out a list of any missing modules
235 foreach my $module (@missing) {
236 $missing.=" perl -MCPAN -e 'install \"$module\"'\n";
238 my $message=getmessage('MissingPerlModules', [$missing]);
239 showmessage($message, 'none');
242 showmessage(getmessage('AllPerlModulesInstalled'), 'PressEnter', '', 1);
250 my $messagename=shift;
252 my $message=$messages->{$messagename}->{$::language} || $messages->{$messagename}->{en} || "Error: No message named $messagename in Install.pm\n";
253 if (defined($variables)) {
254 $message=sprintf $message, @$variables;
262 my $responsetype=shift;
263 my $defaultresponse=shift;
265 ($noclear) || (system('clear'));
266 if ($responsetype =~ /^yn$/) {
267 $responsetype='restrictchar yn';
271 if ($responsetype =~/^restrictchar (.*)/i) {
274 until ($options=~/$response/) {
275 ($defaultresponse) || ($defaultresponse=substr($options,0,1));
278 (length($response)) || ($response=$defaultresponse);
279 unless ($options=~/$response/) {
280 ($noclear) || (system('clear'));
281 print "Invalid Response. Choose from [$options].\n\n";
287 if ($responsetype =~/^free$/i) {
288 (defined($defaultresponse)) || ($defaultresponse='');
289 my $response=<STDIN>;
291 ($response) || ($response=$defaultresponse);
294 if ($responsetype =~/^numerical$/i) {
295 (defined($defaultresponse)) || ($defaultresponse='');
297 until ($response=~/^\d+$/) {
300 ($response) || ($response=$defaultresponse);
301 unless ($response=~/^\d+$/) {
302 ($noclear) || (system('clear'));
303 print "Invalid Response ($response). Response must be a number.\n\n";
309 if ($responsetype =~/^email$/i) {
310 (defined($defaultresponse)) || ($defaultresponse='');
312 until ($response=~/.*\@.*\..*/) {
315 ($response) || ($response=$defaultresponse);
316 unless ($response=~/.*\@.*\..*/) {
317 ($noclear) || (system('clear'));
318 print "Invalid Response ($response). Response must be a valid email address.\n\n";
324 if ($responsetype =~/^PressEnter$/i) {
328 if ($responsetype =~/^none$/i) {
334 sub getinstallationdirectories {
335 $::opacdir = '/usr/local/koha/opac';
336 $::intranetdir = '/usr/local/koha/intranet';
338 while ($getdirinfo) {
339 # Loop until opac directory and koha directory are different
340 my $message=getmessage('GetOpacDir', [$::opacdir]);
341 $::opacdir=showmessage($message, 'free', $::opacdir);
343 $message=getmessage('GetIntranetDir', [$::intranetdir]);
344 $::intranetdir=showmessage($message, 'free', $::intranetdir);
346 if ($::intranetdir eq $::opacdir) {
349 You must specify different directories for the OPAC and INTRANET files!
350 :: $::intranetdir :: $::opacdir ::
357 $::kohalogdir='/var/log/koha';
358 my $message=getmessage('GetKohaLogDir', [$::kohalogdir]);
359 $::kohalogdir=showmessage($message, 'free', $::kohalogdir);
362 unless ( -d $::intranetdir ) {
363 my $result=mkdir ($::intranetdir, oct(770));
365 my @dirs = split(m#/#, $::intranetdir);
369 unless (-e "$checkdir") {
370 mkdir($checkdir, 0775);
374 chown (oct(0), (getgrnam($::httpduser))[2], "$::intranetdir");
375 chmod (oct(770), "$::intranetdir");
377 unless ( -d "$::intranetdir/htdocs" ) {
378 mkdir ("$::intranetdir/htdocs", oct(750));
380 unless ( -d "$::intranetdir/cgi-bin" ) {
381 mkdir ("$::intranetdir/cgi-bin", oct(750));
383 unless ( -d "$::intranetdir/modules" ) {
384 mkdir ("$::intranetdir/modules", oct(750));
386 unless ( -d "$::intranetdir/scripts" ) {
387 mkdir ("$::intranetdir/scripts", oct(750));
389 unless ( -d $::opacdir ) {
390 my $result=mkdir ($::opacdir, oct(770));
392 my @dirs = split(m#/#, $::opacdir);
396 unless (-e "$checkdir") {
397 mkdir($checkdir, 0775);
401 chown (oct(0), (getgrnam($::httpduser))[2], "$::opacdir");
402 chmod (oct(770), "$::opacdir");
404 unless ( -d "$::opacdir/htdocs" ) {
405 mkdir ("$::opacdir/htdocs", oct(750));
407 unless ( -d "$::opacdir/cgi-bin" ) {
408 mkdir ("$::opacdir/cgi-bin", oct(750));
412 unless ( -d $::kohalogdir ) {
413 my $result=mkdir ($::kohalogdir, oct(770));
415 my @dirs = split(m#/#, $::kohalogdir);
419 unless (-e "$checkdir") {
420 mkdir($checkdir, 0775);
425 chown (oct(0), (getgrnam($::httpduser))[2,3], "$::kohalogdir");
426 chmod (oct(770), "$::kohalogdir");
432 $messages->{'DatabaseName'}->{en}=qq|
433 ==========================
434 = Name of MySQL database =
435 ==========================
437 Please provide the name of the mysql database for your koha installation.
439 Database name [%s]: |;
441 $messages->{'DatabaseHost'}->{en}=qq|
446 Please provide the hostname for mysql. Unless the database is located on
447 another machine this will be "localhost".
449 Database host [%s]: |;
451 $messages->{'DatabaseUser'}->{en}=qq|
456 Please provide the name of the user, who will have full administrative rights
457 to the %s database, when authenticating from %s.
459 Database user [%s]: |;
461 $messages->{'DatabasePassword'}->{en}=qq|
462 =====================
463 = Database Password =
464 =====================
466 Please provide a good password for the user %s.
468 Database Password: |;
470 $messages->{'BlankPassword'}->{en}=qq|
475 You must not use a blank password for your MySQL user!
477 Press <ENTER> to try again:
480 sub getdatabaseinfo {
483 $::hostname = 'localhost';
484 $::user = 'kohaadmin';
487 #Get the database name
489 my $message=getmessage('DatabaseName', [$::dbname]);
490 $::dbname=showmessage($message, 'free', $::dbname);
492 #Get the hostname for the database
494 $message=getmessage('DatabaseHost', [$::hostname]);
495 $::hostname=showmessage($message, 'free', $::hostname);
497 #Get the username for the database
499 $message=getmessage('DatabaseUser', [$::dbname, $::hostname, $::user]);
500 $::user=showmessage($message, 'free', $::user);
502 #Get the password for the database user
504 while ($::pass eq '') {
505 my $message=getmessage('DatabasePassword', [$::user]);
506 $::pass=showmessage($message, 'free', $::pass);
508 my $message=getmessage('BlankPassword');
509 showmessage($message,'PressEnter');
516 $messages->{'FoundMultipleApacheConfFiles'}->{en}=qq|
517 ================================
518 = MULTIPLE APACHE CONFIG FILES =
519 ================================
521 I found more than one possible Apache configuration file:
525 Choose the correct file [1]: |;
527 $messages->{'NoApacheConfFiles'}->{en}=qq|
528 ===============================
529 = NO APACHE CONFIG FILE FOUND =
530 ===============================
532 I was not able to find your Apache configuration file.
534 The file is usually called httpd.conf or apache.conf.
536 Please specify the location of your config file: |;
538 $messages->{'NotAFile'}->{en}=qq|
539 =======================
540 = FILE DOES NOT EXIST =
541 =======================
543 The file %s does not exist.
545 Please press <ENTER> to continue: |;
547 $messages->{'EnterApacheUser'}->{en}=qq|
552 I was not able to determine the user that Apache is running as. This
553 information is necessary in order to set the access privileges correctly on
554 /etc/koha.conf. This user should be set in one of the Apache configuration
555 files using the "User" directive.
557 Enter the Apache userid: |;
559 $messages->{'InvalidUserid'}->{en}=qq|
564 The userid %s is not a valid userid on this system.
566 Press <ENTER> to continue: |;
569 my @confpossibilities;
571 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
572 /usr/local/etc/apache/httpd.conf
573 /usr/local/etc/apache/apache.conf
574 /var/www/conf/httpd.conf
575 /etc/apache/conf/httpd.conf
576 /etc/apache/conf/apache.conf
577 /etc/apache-ssl/conf/apache.conf
578 /etc/httpd/conf/httpd.conf
579 /etc/httpd/httpd.conf)) {
580 if ( -f $httpdconf ) {
581 push @confpossibilities, $httpdconf;
585 if ($#confpossibilities==-1) {
586 my $message=getmessage('NoApacheConfFiles');
589 $choice=showmessage($message, "free", 1);
590 unless (-f $choice) {
591 showmessage(getmessage('NotAFile', [$choice]),'PressEnter', '', 1);
594 } elsif ($#confpossibilities>0) {
598 foreach (@confpossibilities) {
599 $conffiles.=" $counter: $_\n";
600 $options.="$counter";
603 my $message=getmessage('FoundMultipleApacheConfFiles', [$conffiles]);
604 my $choice=showmessage($message, "restrictchar $options", 1);
605 $::realhttpdconf=$confpossibilities[$choice-1];
607 $::realhttpdconf=$confpossibilities[0];
609 open (HTTPDCONF, $::realhttpdconf) or warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
610 while (<HTTPDCONF>) {
611 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
620 unless ($::httpduser) {
621 my $message=getmessage('EnterApacheUser');
622 until (length($::httpduser) && getpwnam($::httpduser)) {
623 $::httpduser=showmessage($message, "free", '');
624 if (length($::httpduser)>0) {
625 unless (getpwnam($::httpduser)) {
626 my $message=getmessage('InvalidUserid', [$::httpduser]);
627 showmessage($message,'PressEnter');
632 print "AU: $::httpduser\n";
637 $messages->{'ApacheConfigIntroduction'}->{en}=qq|
638 ========================
639 = APACHE CONFIGURATION =
640 ========================
642 Koha needs to setup your Apache configuration file for the
643 OPAC and LIBRARIAN virtual hosts. By default this installer
644 will do this by using one ip address and two different ports
645 for the virtual hosts. There are other ways to set this up,
646 and the installer will leave comments in httpd.conf detailing
647 what these other options are.
650 Press <ENTER> to continue: |;
652 $messages->{'GetVirtualHostEmail'}->{en}=qq|
653 =============================
654 = WEB SERVER E-MAIL CONTACT =
655 =============================
657 Enter the e-mail address to be used as a contact for the virtual hosts (this
658 address is displayed if any errors are encountered).
660 E-mail contact [%s]: |;
662 $messages->{'GetServerName'}->{en}=qq|
663 ======================================
664 = WEB SERVER HOST NAME OR IP ADDRESS =
665 ======================================
667 Please enter the domain name or ip address of your computer.
669 Host name or IP Address [%s]: |;
671 $messages->{'GetOpacPort'}->{en}=qq|
672 ==========================
673 = OPAC VIRTUAL HOST PORT =
674 ==========================
676 Please enter the port for your OPAC interface. This defaults to port 80, but
677 if you are already serving web content from this server, you should change it
678 to a different port (8000 might be a good choice).
680 Enter the OPAC Port [%s]: |;
682 $messages->{'GetIntranetPort'}->{en}=qq|
683 ==============================
684 = INTRANET VIRTUAL HOST PORT =
685 ==============================
687 Please enter the port for your Intranet interface. This must be different from
690 Enter the Intranet Port [%s]: |;
693 sub getapachevhostinfo {
695 $::svr_admin = "webmaster\@$::domainname";
696 $::servername=`hostname -f`;
699 $::intranetport=8080;
701 showmessage(getmessage('ApacheConfigIntroduction'), 'PressEnter');
703 $::svr_admin=showmessage(getmessage('GetVirtualHostEmail', [$::svr_admin]), 'email', $::svr_admin);
704 $::servername=showmessage(getmessage('GetServerName', [$::servername]), 'free', $::servername);
707 $::opacport=showmessage(getmessage('GetOpacPort', [$::opacport]), 'numerical', $::opacport);
708 $::intranetport=showmessage(getmessage('GetIntranetPort', [$::opacport, $::intranetport]), 'numerical', $::intranetport);
712 $messages->{'StartUpdateApache'}->{en}=qq|
713 =================================
714 = UPDATING APACHE CONFIGURATION =
715 =================================
717 Checking for modules that need to be loaded...
720 $messages->{'LoadingApacheModuleModEnv'}->{en}="Loading SetEnv Apache module.\n";
722 $messages->{'LoadingApacheModuleModInc'}->{en}="Loading Includes Apache module.\n";
724 $messages->{'ApacheConfigBackupFailed'}->{en}=qq|
725 ======================================
726 = APACHE CONFIGURATION BACKUP FAILED =
727 ======================================
729 An error occurred while trying to make a backup copy of %s.
733 No changes will be made to the apache configuration file at this time.
735 Press <ENTER> to continue: |;
738 $messages->{'ApacheAlreadyConfigured'}->{en}=qq|
739 =============================
740 = APACHE ALREADY CONFIGURED =
741 =============================
743 %s appears to already have an entry for Koha
744 Virtual Hosts. You may need to edit %s
745 f anything has changed since it was last set up. This
746 script will not attempt to modify an existing Koha apache
749 Press <ENTER> to continue: |;
751 sub updateapacheconf {
752 my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
756 $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
760 unless ($logfiledir) {
764 showmessage(getmessage('StartUpdateApache'), 'none');
768 my $includesmodule=0;
769 open HC, $::realhttpdconf;
771 if (/^\s*#\s*LoadModule env_module /) {
773 showmessage(getmessage('LoadingApacheModuleModEnv'));
776 if (/^\s*#\s*LoadModule includes_module /) {
778 showmessage(getmessage('LoadingApacheModuleModInc'));
780 if (/\s*LoadModule includes_module / ) {
787 $backupfailed=`cp -f $::realhttpdconf $::realhttpdconf\.prekoha`;
789 showmessage(getmessage('ApacheConfigBackupFailed', [$::realhttpdconf,$backupfailed ]), 'PressEnter');
793 if ($envmodule || $includesmodule) {
794 open HC, ">$::realhttpdconf";
801 if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
802 showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
805 my $includesdirectives='';
806 if ($includesmodule) {
807 $includesdirectives.="Options +Includes\n";
808 $includesdirectives.=" AddHandler server-parsed .html\n";
810 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
812 if ($::opacport != 80) {
813 $opaclisten="Listen $::opacport";
815 my $intranetlisten = '';
816 if ($::intranetport != 80) {
817 $intranetlisten="Listen $::intranetport";
821 # Ports to listen to for Koha
825 # NameVirtualHost is used by one of the optional configurations detailed below
827 #NameVirtualHost 11.22.33.44
829 # KOHA's OPAC Configuration
830 <VirtualHost $::servername\:$::opacport>
831 ServerAdmin $::svr_admin
832 DocumentRoot $::opacdir/htdocs
833 ServerName $::servername
834 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
835 ErrorLog $logfiledir/opac-error_log
836 TransferLog $logfiledir/opac-access_log
837 SetEnv PERL5LIB "$::intranetdir/modules"
841 # KOHA's INTRANET Configuration
842 <VirtualHost $::servername\:$::intranetport>
843 ServerAdmin $::svr_admin
844 DocumentRoot $::intranetdir/htdocs
845 ServerName $::servername
846 ScriptAlias /cgi-bin/koha/ "$::intranetdir/cgi-bin/"
847 ErrorLog $logfiledir/koha-error_log
848 TransferLog $logfiledir/koha-access_log
849 SetEnv PERL5LIB "$::intranetdir/modules"
853 # If you want to use name based Virtual Hosting:
854 # 1. remove the two Listen lines
855 # 2. replace $::servername\:$::opacport wih your.opac.domain.name
856 # 3. replace ServerName $::servername wih ServerName your.opac.domain.name
857 # 4. replace $::servername\:$::intranetport wih your intranet domain name
858 # 5. replace ServerName $::servername wih ServerName your.intranet.domain.name
860 # If you want to use NameVirtualHost'ing (using two names on one ip address):
861 # 1. Follow steps 1-5 above
862 # 2. Uncomment the NameVirtualHost line and set the correct ip address
870 $messages->{'IntranetAuthenticationQuestion'}->{en}=qq|
871 ===========================
872 = INTRANET AUTHENTICATION =
873 ===========================
875 I can set it up so that the Intranet/Librarian site is password protected using
876 Apache's Basic Authorization.
878 Would you like to do this ([Y]/N): |;
880 $messages->{'BasicAuthUsername'}->{en}="Please enter a userid for intranet access [%s]: ";
881 $messages->{'BasicAuthPassword'}->{en}="Please enter a password for %s: ";
882 $messages->{'BasicAuthPasswordWasBlank'}->{en}="\nYou cannot use a blank password!\n\n";
884 sub basicauthentication {
885 my $message=getmessage('IntranetAuthenticationQuestion');
886 my $answer=showmessage($message, 'yn', 'y');
888 my $apacheauthusername='librarian';
889 my $apacheauthpassword='';
890 if ($answer=~/^y/i) {
891 ($apacheauthusername) = showmessage(getmessage('BasicAuthUsername', [ $apacheauthusername]), 'free', $apacheauthusername, 1);
892 $apacheauthusername=~s/[^a-zA-Z0-9]//g;
893 while (! $apacheauthpassword) {
894 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPassword', [ $apacheauthusername]), 'free', 1);
895 if (!$apacheauthpassword) {
896 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPasswordWasBlank'), 'none', '', 1);
899 open AUTH, ">/etc/kohaintranet.pass";
900 my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
901 my $salt=substr($chars, int(rand(length($chars))),1);
902 $salt.=substr($chars, int(rand(length($chars))),1);
903 print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
905 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
908 <Directory $::intranetdir>
909 AuthUserFile /etc/kohaintranet.pass
911 AuthName "Koha Intranet (for librarians only)"
919 $messages->{'InstallFiles'}->{en}=qq|
924 Copying files to installation directories:
929 $messages->{'CopyingFiles'}->{en}="Copying %s to %s.\n";
936 showmessage(getmessage('InstallFiles'),'none');
937 print getmessage('CopyingFiles', ['internet-html', "$::intranetdir/htdocs" ]);
938 system("cp -R intranet-html/* $::intranetdir/htdocs/");
939 print getmessage('CopyingFiles', ['internet-cgi', "$::intranetdir/cgi-bin" ]);
940 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
941 print getmessage('CopyingFiles', ['stand-alone scripts', "$::intranetdir/scripts" ]);
942 system("cp -R scripts/* $::intranetdir/scripts/");
943 print getmessage('CopyingFiles', ['perl modules', "$::intranetdir/modules" ]);
944 system("cp -R modules/* $::intranetdir/modules/");
945 print getmessage('CopyingFiles', ['opac-html', "$::opacdir/htdocs" ]);
946 system("cp -R opac-html/* $::opacdir/htdocs/");
947 print getmessage('CopyingFiles', ['opac-cgi', "$::opacdir/cgi-bin" ]);
948 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
950 system("chown -R root.$::httpduser $::opacdir");
951 system("chown -R root.$::httpduser $::intranetdir");
953 # Create /etc/koha.conf
955 open(KC,">$::etcdir/koha.conf") or warn "Couldn't create file
956 at $::etcdir. Must have write capability.\n";
962 includes=$::intranetdir/htdocs/includes
963 intranetdir=$::intranetdir
965 kohalogdir=$::kohalogdir
966 kohaversion=$::kohaversion
967 httpduser=$::httpduser
971 chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf") or warn "can't chown koha.conf: $!";
972 chmod 0440, "$::etcdir/koha.conf";
974 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
975 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
976 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
977 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
978 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
982 $messages->{'MysqlRootPassword'}->{en}=qq|
983 ============================
984 = MYSQL ROOT USER PASSWORD =
985 ============================
987 To allow us to create the koha database please supply your
988 mysql server's root user password:
990 Enter MySql root user password: |;
992 $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password. Please try again.";
994 $messages->{'CreatingDatabase'}->{en}=qq|
995 =====================
996 = CREATING DATABASE =
997 =====================
999 Creating the MySql database for Koha...
1003 $messages->{'CreatingDatabaseError'}->{en}=qq|
1004 ===========================
1005 = ERROR CREATING DATABASE =
1006 ===========================
1008 Couldn't connect to the MySQL server for the reason given above.
1009 This is a serious problem, the database will not get installed.
\a
1011 Press <ENTER> to continue: |;
1013 $messages->{'SampleData'}->{en}=qq|
1018 If you are installing Koha for evaluation purposes, I have a batch of sample
1019 data that you can install now.
1021 If you are installing Koha with the intention of populating it with your own
1022 data, you probably don't want this sample data installed.
1024 Would you like to install the sample data? Y/[N]: |;
1026 $messages->{'SampleDataInstalled'}->{en}=qq|
1027 =========================
1028 = SAMPLE DATA INSTALLED =
1029 =========================
1031 Sample data has been installed. For some suggestions on testing Koha, please
1032 read the file doc/HOWTO-Testing. If you find any bugs, please submit them at
1033 http://bugs.koha.org/. If you need help with testing Koha, you can post a
1034 question through the koha-devel mailing list, or you can check for a developer
1035 online at +irc.katipo.co.nz:6667 channel #koha.
1037 You can find instructions for subscribing to the Koha mailing lists at:
1042 Press <ENTER> to continue: |;
1044 $messages->{'AddBranchPrinter'}->{en}=qq|
1045 ==========================
1046 = Add Branch and Printer =
1047 ==========================
1049 Would you like to install an initial branch and printer? [Y]/N: |;
1051 $messages->{'BranchName'}->{en}="Branch Name [%s]: ";
1052 $messages->{'BranchCode'}->{en}="Branch Code (4 letters or numbers) [%s]: ";
1053 $messages->{'PrinterQueue'}->{en}="Printer Queue [%s]: ";
1054 $messages->{'PrinterName'}->{en}="Printer Name [%s]: ";
1058 $::mysqluser = 'root';
1061 foreach my $mysql (qw(/usr/local/mysql
1074 while ($needpassword) {
1075 $::mysqlpass=showmessage(getmessage('MysqlRootPassword'), 'free');
1076 my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass proc > /dev/null 2>&1");
1078 print getmessage('InvalidMysqlRootPassword');
1084 showmessage(getmessage('CreatingDatabase'),'none');
1086 my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass create $::dbname");
1088 showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1);
1090 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname < koha.mysql");
1091 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;");
1092 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')\"");
1093 system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass reload");
1095 system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
1098 my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
1099 if ($response =~/^y/i) {
1100 system("gunzip sampledata-1.2.gz");
1101 system("cat sampledata-1.2 | $mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1102 system("gzip -9 sampledata-1.2");
1103 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
1104 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
1105 showmessage(getmessage('SampleDataInstalled'), 'PressEnter');
1108 my $response=showmessage(getmessage('AddBranchPrinter'), 'yn', 'y');
1110 unless ($response =~/^n/i) {
1111 my $branch='Main Library';
1112 print "Enter a name for the library branch [$branch]: ";
1113 $branch=showmessage(getmessage('BranchName', [$branch]), 'free', $branch, 1);
1114 $branch=~s/[^A-Za-z0-9\s]//g;
1116 my $branchcode=$branch;
1117 $branchcode=~s/[^A-Za-z0-9]//g;
1118 $branchcode=uc($branchcode);
1119 $branchcode=substr($branchcode,0,4);
1120 $branchcode=showmessage(getmessage('BranchCode', [$branchcode]), 'free', $branchcode, 1);
1121 $branchcode=~s/[^A-Z]//g;
1122 $branchcode=uc($branchcode);
1123 $branchcode=substr($branchcode,0,4);
1125 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
1127 my $printername='Library Printer';
1128 $printername=showmessage(getmessage('PrinterName', [$printername]), 'free', $printername, 1);
1129 $printername=~s/[^A-Za-z0-9\s]//g;
1131 my $printerqueue='lp';
1132 $printerqueue=showmessage(getmessage('PrinterQueue', [$printerqueue]), 'free', $printerqueue, 1);
1133 $printerqueue=~s/[^A-Za-z0-9]//g;
1134 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
1144 $messages->{'RestartApache'}->{en}=qq|
1149 Apache needs to be restarted to load the new configuration for Koha.
1151 Would you like to restart Apache now? [Y]/N: |;
1155 my $response=showmessage(getmessage('RestartApache'), 'yn', 'y');
1159 unless ($response=~/^n/i) {
1160 # Need to support other init structures here?
1161 if (-e "/etc/rc.d/init.d/httpd") {
1162 system('/etc/rc.d/init.d/httpd restart');
1163 } elsif (-e "/etc/init.d/apache") {
1164 system('/etc//init.d/apache restart');
1165 } elsif (-e "/etc/init.d/apache-ssl") {
1166 system('/etc/init.d/apache-ssl restart');
1172 sub loadconfigfile {
1175 open (KC, "/etc/koha.conf");
1178 (next) if (/^\s*#/);
1179 if (/(.*)\s*=\s*(.*)/) {
1182 # Clean up white space at beginning and end
1183 $variable=~s/^\s*//g;
1184 $variable=~s/\s*$//g;
1187 $configfile{$variable}=$value;
1191 $::intranetdir=$configfile{'intranetdir'};
1192 $::opacdir=$configfile{'opacdir'};
1193 $::kohaversion=$configfile{'kohaversion'};
1194 $::kohalogdir=$configfile{'kohalogdir'};
1195 $::database=$configfile{'database'};
1196 $::hostname=$configfile{'hostname'};
1197 $::user=$configfile{'user'};
1198 $::pass=$configfile{'pass'};
1201 END { } # module clean-up code here (global destructor)