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 Template}) { push @missing,"Template" };
221 unless (eval {require Set::Scalar}) { push @missing,"Set::Scalar" };
222 unless (eval {require Digest::MD5}) { push @missing,"Digest::MD5" };
223 unless (eval {require Net::Z3950}) {
224 my $message = getmessage('NETZ3950Missing');
225 showmessage($message, 'PressEnter', '', 1);
227 push @missing, "Net::Z3950";
232 # Print out a list of any missing modules
237 foreach my $module (@missing) {
238 $missing.=" perl -MCPAN -e 'install \"$module\"'\n";
240 my $message=getmessage('MissingPerlModules', [$missing]);
241 showmessage($message, 'none');
244 showmessage(getmessage('AllPerlModulesInstalled'), 'PressEnter', '', 1);
252 my $messagename=shift;
254 my $message=$messages->{$messagename}->{$::language} || $messages->{$messagename}->{en} || "Error: No message named $messagename in Install.pm\n";
255 if (defined($variables)) {
256 $message=sprintf $message, @$variables;
264 my $responsetype=shift;
265 my $defaultresponse=shift;
267 ($noclear) || (system('clear'));
268 if ($responsetype =~ /^yn$/) {
269 $responsetype='restrictchar yn';
273 if ($responsetype =~/^restrictchar (.*)/i) {
276 until ($options=~/$response/) {
277 ($defaultresponse) || ($defaultresponse=substr($options,0,1));
280 (length($response)) || ($response=$defaultresponse);
281 unless ($options=~/$response/) {
282 ($noclear) || (system('clear'));
283 print "Invalid Response. Choose from [$options].\n\n";
289 if ($responsetype =~/^free$/i) {
290 (defined($defaultresponse)) || ($defaultresponse='');
291 my $response=<STDIN>;
293 ($response) || ($response=$defaultresponse);
296 if ($responsetype =~/^numerical$/i) {
297 (defined($defaultresponse)) || ($defaultresponse='');
299 until ($response=~/^\d+$/) {
302 ($response) || ($response=$defaultresponse);
303 unless ($response=~/^\d+$/) {
304 ($noclear) || (system('clear'));
305 print "Invalid Response ($response). Response must be a number.\n\n";
311 if ($responsetype =~/^email$/i) {
312 (defined($defaultresponse)) || ($defaultresponse='');
314 until ($response=~/.*\@.*\..*/) {
317 ($response) || ($response=$defaultresponse);
318 unless ($response=~/.*\@.*\..*/) {
319 ($noclear) || (system('clear'));
320 print "Invalid Response ($response). Response must be a valid email address.\n\n";
326 if ($responsetype =~/^PressEnter$/i) {
330 if ($responsetype =~/^none$/i) {
336 sub getinstallationdirectories {
337 $::opacdir = '/usr/local/koha/opac';
338 $::intranetdir = '/usr/local/koha/intranet';
340 while ($getdirinfo) {
341 # Loop until opac directory and koha directory are different
342 my $message=getmessage('GetOpacDir', [$::opacdir]);
343 $::opacdir=showmessage($message, 'free', $::opacdir);
345 $message=getmessage('GetIntranetDir', [$::intranetdir]);
346 $::intranetdir=showmessage($message, 'free', $::intranetdir);
348 if ($::intranetdir eq $::opacdir) {
351 You must specify different directories for the OPAC and INTRANET files!
352 :: $::intranetdir :: $::opacdir ::
359 $::kohalogdir='/var/log/koha';
360 my $message=getmessage('GetKohaLogDir', [$::kohalogdir]);
361 $::kohalogdir=showmessage($message, 'free', $::kohalogdir);
364 unless ( -d $::intranetdir ) {
365 my $result=mkdir ($::intranetdir, oct(770));
367 my @dirs = split(m#/#, $::intranetdir);
371 unless (-e "$checkdir") {
372 mkdir($checkdir, 0775);
376 chown (oct(0), (getgrnam($::httpduser))[2], "$::intranetdir");
377 chmod (oct(770), "$::intranetdir");
379 unless ( -d "$::intranetdir/htdocs" ) {
380 mkdir ("$::intranetdir/htdocs", oct(750));
382 unless ( -d "$::intranetdir/cgi-bin" ) {
383 mkdir ("$::intranetdir/cgi-bin", oct(750));
385 unless ( -d "$::intranetdir/modules" ) {
386 mkdir ("$::intranetdir/modules", oct(750));
388 unless ( -d "$::intranetdir/scripts" ) {
389 mkdir ("$::intranetdir/scripts", oct(750));
391 unless ( -d $::opacdir ) {
392 my $result=mkdir ($::opacdir, oct(770));
394 my @dirs = split(m#/#, $::opacdir);
398 unless (-e "$checkdir") {
399 mkdir($checkdir, 0775);
403 chown (oct(0), (getgrnam($::httpduser))[2], "$::opacdir");
404 chmod (oct(770), "$::opacdir");
406 unless ( -d "$::opacdir/htdocs" ) {
407 mkdir ("$::opacdir/htdocs", oct(750));
409 unless ( -d "$::opacdir/cgi-bin" ) {
410 mkdir ("$::opacdir/cgi-bin", oct(750));
414 unless ( -d $::kohalogdir ) {
415 my $result=mkdir ($::kohalogdir, oct(770));
417 my @dirs = split(m#/#, $::kohalogdir);
421 unless (-e "$checkdir") {
422 mkdir($checkdir, 0775);
427 chown (oct(0), (getgrnam($::httpduser))[2,3], "$::kohalogdir");
428 chmod (oct(770), "$::kohalogdir");
434 $messages->{'DatabaseName'}->{en}=qq|
435 ==========================
436 = Name of MySQL database =
437 ==========================
439 Please provide the name of the mysql database for your koha installation.
441 Database name [%s]: |;
443 $messages->{'DatabaseHost'}->{en}=qq|
448 Please provide the hostname for mysql. Unless the database is located on
449 another machine this will be "localhost".
451 Database host [%s]: |;
453 $messages->{'DatabaseUser'}->{en}=qq|
458 Please provide the name of the user, who will have full administrative rights
459 to the %s database, when authenticating from %s.
461 Database user [%s]: |;
463 $messages->{'DatabasePassword'}->{en}=qq|
464 =====================
465 = Database Password =
466 =====================
468 Please provide a good password for the user %s.
470 Database Password: |;
472 $messages->{'BlankPassword'}->{en}=qq|
477 You must not use a blank password for your MySQL user!
479 Press <ENTER> to try again:
482 sub getdatabaseinfo {
485 $::hostname = 'localhost';
486 $::user = 'kohaadmin';
489 #Get the database name
491 my $message=getmessage('DatabaseName', [$::dbname]);
492 $::dbname=showmessage($message, 'free', $::dbname);
494 #Get the hostname for the database
496 $message=getmessage('DatabaseHost', [$::hostname]);
497 $::hostname=showmessage($message, 'free', $::hostname);
499 #Get the username for the database
501 $message=getmessage('DatabaseUser', [$::dbname, $::hostname, $::user]);
502 $::user=showmessage($message, 'free', $::user);
504 #Get the password for the database user
506 while ($::pass eq '') {
507 my $message=getmessage('DatabasePassword', [$::user]);
508 $::pass=showmessage($message, 'free', $::pass);
510 my $message=getmessage('BlankPassword');
511 showmessage($message,'PressEnter');
518 $messages->{'FoundMultipleApacheConfFiles'}->{en}=qq|
519 ================================
520 = MULTIPLE APACHE CONFIG FILES =
521 ================================
523 I found more than one possible Apache configuration file:
527 Choose the correct file [1]: |;
529 $messages->{'NoApacheConfFiles'}->{en}=qq|
530 ===============================
531 = NO APACHE CONFIG FILE FOUND =
532 ===============================
534 I was not able to find your Apache configuration file.
536 The file is usually called httpd.conf or apache.conf.
538 Please specify the location of your config file: |;
540 $messages->{'NotAFile'}->{en}=qq|
541 =======================
542 = FILE DOES NOT EXIST =
543 =======================
545 The file %s does not exist.
547 Please press <ENTER> to continue: |;
549 $messages->{'EnterApacheUser'}->{en}=qq|
554 I was not able to determine the user that Apache is running as. This
555 information is necessary in order to set the access privileges correctly on
556 /etc/koha.conf. This user should be set in one of the Apache configuration
557 files using the "User" directive.
559 Enter the Apache userid: |;
561 $messages->{'InvalidUserid'}->{en}=qq|
566 The userid %s is not a valid userid on this system.
568 Press <ENTER> to continue: |;
571 my @confpossibilities;
573 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
574 /usr/local/etc/apache/httpd.conf
575 /usr/local/etc/apache/apache.conf
576 /var/www/conf/httpd.conf
577 /etc/apache/conf/httpd.conf
578 /etc/apache/conf/apache.conf
579 /etc/apache-ssl/conf/apache.conf
580 /etc/httpd/conf/httpd.conf
581 /etc/httpd/httpd.conf)) {
582 if ( -f $httpdconf ) {
583 push @confpossibilities, $httpdconf;
587 if ($#confpossibilities==-1) {
588 my $message=getmessage('NoApacheConfFiles');
591 $choice=showmessage($message, "free", 1);
592 unless (-f $choice) {
593 showmessage(getmessage('NotAFile', [$choice]),'PressEnter', '', 1);
596 } elsif ($#confpossibilities>0) {
600 foreach (@confpossibilities) {
601 $conffiles.=" $counter: $_\n";
602 $options.="$counter";
605 my $message=getmessage('FoundMultipleApacheConfFiles', [$conffiles]);
606 my $choice=showmessage($message, "restrictchar $options", 1);
607 $::realhttpdconf=$confpossibilities[$choice-1];
609 $::realhttpdconf=$confpossibilities[0];
611 open (HTTPDCONF, $::realhttpdconf) or warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
612 while (<HTTPDCONF>) {
613 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
622 unless ($::httpduser) {
623 my $message=getmessage('EnterApacheUser');
624 until (length($::httpduser) && getpwnam($::httpduser)) {
625 $::httpduser=showmessage($message, "free", '');
626 if (length($::httpduser)>0) {
627 unless (getpwnam($::httpduser)) {
628 my $message=getmessage('InvalidUserid', [$::httpduser]);
629 showmessage($message,'PressEnter');
634 print "AU: $::httpduser\n";
639 $messages->{'ApacheConfigIntroduction'}->{en}=qq|
640 ========================
641 = APACHE CONFIGURATION =
642 ========================
644 Koha needs to setup your Apache configuration file for the
645 OPAC and LIBRARIAN virtual hosts. By default this installer
646 will do this by using one ip address and two different ports
647 for the virtual hosts. There are other ways to set this up,
648 and the installer will leave comments in httpd.conf detailing
649 what these other options are.
652 Press <ENTER> to continue: |;
654 $messages->{'GetVirtualHostEmail'}->{en}=qq|
655 =============================
656 = WEB SERVER E-MAIL CONTACT =
657 =============================
659 Enter the e-mail address to be used as a contact for the virtual hosts (this
660 address is displayed if any errors are encountered).
662 E-mail contact [%s]: |;
664 $messages->{'GetServerName'}->{en}=qq|
665 ======================================
666 = WEB SERVER HOST NAME OR IP ADDRESS =
667 ======================================
669 Please enter the domain name or ip address of your computer.
671 Host name or IP Address [%s]: |;
673 $messages->{'GetOpacPort'}->{en}=qq|
674 ==========================
675 = OPAC VIRTUAL HOST PORT =
676 ==========================
678 Please enter the port for your OPAC interface. This defaults to port 80, but
679 if you are already serving web content from this server, you should change it
680 to a different port (8000 might be a good choice).
682 Enter the OPAC Port [%s]: |;
684 $messages->{'GetIntranetPort'}->{en}=qq|
685 ==============================
686 = INTRANET VIRTUAL HOST PORT =
687 ==============================
689 Please enter the port for your Intranet interface. This must be different from
692 Enter the Intranet Port [%s]: |;
695 sub getapachevhostinfo {
697 $::svr_admin = "webmaster\@$::domainname";
698 $::servername=`hostname -f`;
701 $::intranetport=8080;
703 showmessage(getmessage('ApacheConfigIntroduction'), 'PressEnter');
705 $::svr_admin=showmessage(getmessage('GetVirtualHostEmail', [$::svr_admin]), 'email', $::svr_admin);
706 $::servername=showmessage(getmessage('GetServerName', [$::servername]), 'free', $::servername);
709 $::opacport=showmessage(getmessage('GetOpacPort', [$::opacport]), 'numerical', $::opacport);
710 $::intranetport=showmessage(getmessage('GetIntranetPort', [$::opacport, $::intranetport]), 'numerical', $::intranetport);
714 $messages->{'StartUpdateApache'}->{en}=qq|
715 =================================
716 = UPDATING APACHE CONFIGURATION =
717 =================================
719 Checking for modules that need to be loaded...
722 $messages->{'LoadingApacheModuleModEnv'}->{en}="Loading SetEnv Apache module.\n";
724 $messages->{'LoadingApacheModuleModInc'}->{en}="Loading Includes Apache module.\n";
726 $messages->{'ApacheConfigBackupFailed'}->{en}=qq|
727 ======================================
728 = APACHE CONFIGURATION BACKUP FAILED =
729 ======================================
731 An error occurred while trying to make a backup copy of %s.
735 No changes will be made to the apache configuration file at this time.
737 Press <ENTER> to continue: |;
740 $messages->{'ApacheAlreadyConfigured'}->{en}=qq|
741 =============================
742 = APACHE ALREADY CONFIGURED =
743 =============================
745 %s appears to already have an entry for Koha
746 Virtual Hosts. You may need to edit %s
747 f anything has changed since it was last set up. This
748 script will not attempt to modify an existing Koha apache
751 Press <ENTER> to continue: |;
753 sub updateapacheconf {
754 my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
758 $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
762 unless ($logfiledir) {
766 showmessage(getmessage('StartUpdateApache'), 'none');
770 my $includesmodule=0;
771 open HC, $::realhttpdconf;
773 if (/^\s*#\s*LoadModule env_module /) {
775 showmessage(getmessage('LoadingApacheModuleModEnv'));
778 if (/^\s*#\s*LoadModule includes_module /) {
780 showmessage(getmessage('LoadingApacheModuleModInc'));
782 if (/\s*LoadModule includes_module / ) {
789 $backupfailed=`cp -f $::realhttpdconf $::realhttpdconf\.prekoha`;
791 showmessage(getmessage('ApacheConfigBackupFailed', [$::realhttpdconf,$backupfailed ]), 'PressEnter');
795 if ($envmodule || $includesmodule) {
796 open HC, ">$::realhttpdconf";
803 if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
804 showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
807 my $includesdirectives='';
808 if ($includesmodule) {
809 $includesdirectives.="Options +Includes\n";
810 $includesdirectives.=" AddHandler server-parsed .html\n";
812 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
814 if ($::opacport != 80) {
815 $opaclisten="Listen $::opacport";
817 my $intranetlisten = '';
818 if ($::intranetport != 80) {
819 $intranetlisten="Listen $::intranetport";
823 # Ports to listen to for Koha
827 # NameVirtualHost is used by one of the optional configurations detailed below
829 #NameVirtualHost 11.22.33.44
831 # KOHA's OPAC Configuration
832 <VirtualHost $::servername\:$::opacport>
833 ServerAdmin $::svr_admin
834 DocumentRoot $::opacdir/htdocs
835 ServerName $::servername
836 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
837 ErrorLog $logfiledir/opac-error_log
838 TransferLog $logfiledir/opac-access_log
839 SetEnv PERL5LIB "$::intranetdir/modules"
843 # KOHA's INTRANET Configuration
844 <VirtualHost $::servername\:$::intranetport>
845 ServerAdmin $::svr_admin
846 DocumentRoot $::intranetdir/htdocs
847 ServerName $::servername
848 ScriptAlias /cgi-bin/koha/ "$::intranetdir/cgi-bin/"
849 ErrorLog $logfiledir/koha-error_log
850 TransferLog $logfiledir/koha-access_log
851 SetEnv PERL5LIB "$::intranetdir/modules"
855 # If you want to use name based Virtual Hosting:
856 # 1. remove the two Listen lines
857 # 2. replace $::servername\:$::opacport wih your.opac.domain.name
858 # 3. replace ServerName $::servername wih ServerName your.opac.domain.name
859 # 4. replace $::servername\:$::intranetport wih your intranet domain name
860 # 5. replace ServerName $::servername wih ServerName your.intranet.domain.name
862 # If you want to use NameVirtualHost'ing (using two names on one ip address):
863 # 1. Follow steps 1-5 above
864 # 2. Uncomment the NameVirtualHost line and set the correct ip address
872 $messages->{'IntranetAuthenticationQuestion'}->{en}=qq|
873 ===========================
874 = INTRANET AUTHENTICATION =
875 ===========================
877 I can set it up so that the Intranet/Librarian site is password protected using
878 Apache's Basic Authorization.
880 Would you like to do this ([Y]/N): |;
882 $messages->{'BasicAuthUsername'}->{en}="Please enter a userid for intranet access [%s]: ";
883 $messages->{'BasicAuthPassword'}->{en}="Please enter a password for %s: ";
884 $messages->{'BasicAuthPasswordWasBlank'}->{en}="\nYou cannot use a blank password!\n\n";
886 sub basicauthentication {
887 my $message=getmessage('IntranetAuthenticationQuestion');
888 my $answer=showmessage($message, 'yn', 'y');
890 my $apacheauthusername='librarian';
891 my $apacheauthpassword='';
892 if ($answer=~/^y/i) {
893 ($apacheauthusername) = showmessage(getmessage('BasicAuthUsername', [ $apacheauthusername]), 'free', $apacheauthusername, 1);
894 $apacheauthusername=~s/[^a-zA-Z0-9]//g;
895 while (! $apacheauthpassword) {
896 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPassword', [ $apacheauthusername]), 'free', 1);
897 if (!$apacheauthpassword) {
898 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPasswordWasBlank'), 'none', '', 1);
901 open AUTH, ">/etc/kohaintranet.pass";
902 my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
903 my $salt=substr($chars, int(rand(length($chars))),1);
904 $salt.=substr($chars, int(rand(length($chars))),1);
905 print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
907 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
910 <Directory $::intranetdir>
911 AuthUserFile /etc/kohaintranet.pass
913 AuthName "Koha Intranet (for librarians only)"
921 $messages->{'InstallFiles'}->{en}=qq|
926 Copying files to installation directories:
931 $messages->{'CopyingFiles'}->{en}="Copying %s to %s.\n";
938 showmessage(getmessage('InstallFiles'),'none');
939 print getmessage('CopyingFiles', ['internet-html', "$::intranetdir/htdocs" ]);
940 system("cp -R intranet-html/* $::intranetdir/htdocs/");
941 print getmessage('CopyingFiles', ['internet-cgi', "$::intranetdir/cgi-bin" ]);
942 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
943 print getmessage('CopyingFiles', ['stand-alone scripts', "$::intranetdir/scripts" ]);
944 system("cp -R scripts/* $::intranetdir/scripts/");
945 print getmessage('CopyingFiles', ['perl modules', "$::intranetdir/modules" ]);
946 system("cp -R modules/* $::intranetdir/modules/");
947 print getmessage('CopyingFiles', ['opac-html', "$::opacdir/htdocs" ]);
948 system("cp -R opac-html/* $::opacdir/htdocs/");
949 print getmessage('CopyingFiles', ['opac-cgi', "$::opacdir/cgi-bin" ]);
950 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
951 system("touch $::opacdir/cgi-bin/opac");
953 system("chown -R root.$::httpduser $::opacdir");
954 system("chown -R root.$::httpduser $::intranetdir");
956 # Create /etc/koha.conf
958 open(KC,">$::etcdir/koha.conf") or warn "Couldn't create file
959 at $::etcdir. Must have write capability.\n";
965 includes=$::intranetdir/htdocs/includes
966 intranetdir=$::intranetdir
968 kohalogdir=$::kohalogdir
969 kohaversion=$::kohaversion
970 httpduser=$::httpduser
974 chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf") or warn "can't chown koha.conf: $!";
975 chmod 0440, "$::etcdir/koha.conf";
977 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
978 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
979 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
980 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
981 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
985 $messages->{'MysqlRootPassword'}->{en}=qq|
986 ============================
987 = MYSQL ROOT USER PASSWORD =
988 ============================
990 To allow us to create the koha database please supply your
991 mysql server's root user password:
993 Enter MySql root user password: |;
995 $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password. Please try again.";
997 $messages->{'CreatingDatabase'}->{en}=qq|
998 =====================
999 = CREATING DATABASE =
1000 =====================
1002 Creating the MySql database for Koha...
1006 $messages->{'CreatingDatabaseError'}->{en}=qq|
1007 ===========================
1008 = ERROR CREATING DATABASE =
1009 ===========================
1011 Couldn't connect to the MySQL server for the reason given above.
1012 This is a serious problem, the database will not get installed.
\a
1014 Press <ENTER> to continue: |;
1016 $messages->{'SampleData'}->{en}=qq|
1021 If you are installing Koha for evaluation purposes, I have a batch of sample
1022 data that you can install now.
1024 If you are installing Koha with the intention of populating it with your own
1025 data, you probably don't want this sample data installed.
1027 Would you like to install the sample data? Y/[N]: |;
1029 $messages->{'SampleDataInstalled'}->{en}=qq|
1030 =========================
1031 = SAMPLE DATA INSTALLED =
1032 =========================
1034 Sample data has been installed. For some suggestions on testing Koha, please
1035 read the file doc/HOWTO-Testing. If you find any bugs, please submit them at
1036 http://bugs.koha.org/. If you need help with testing Koha, you can post a
1037 question through the koha-devel mailing list, or you can check for a developer
1038 online at +irc.katipo.co.nz:6667 channel #koha.
1040 You can find instructions for subscribing to the Koha mailing lists at:
1045 Press <ENTER> to continue: |;
1047 $messages->{'AddBranchPrinter'}->{en}=qq|
1048 ==========================
1049 = Add Branch and Printer =
1050 ==========================
1052 Would you like to install an initial branch and printer? [Y]/N: |;
1054 $messages->{'BranchName'}->{en}="Branch Name [%s]: ";
1055 $messages->{'BranchCode'}->{en}="Branch Code (4 letters or numbers) [%s]: ";
1056 $messages->{'PrinterQueue'}->{en}="Printer Queue [%s]: ";
1057 $messages->{'PrinterName'}->{en}="Printer Name [%s]: ";
1061 $::mysqluser = 'root';
1064 foreach my $mysql (qw(/usr/local/mysql
1077 while ($needpassword) {
1078 $::mysqlpass=showmessage(getmessage('MysqlRootPassword'), 'free');
1079 my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass proc > /dev/null 2>&1");
1081 print getmessage('InvalidMysqlRootPassword');
1087 showmessage(getmessage('CreatingDatabase'),'none');
1089 my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass create $::dbname");
1091 showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1);
1093 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname < koha.mysql");
1094 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;");
1095 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')\"");
1096 system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass reload");
1098 system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
1101 my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
1102 if ($response =~/^y/i) {
1103 system("gunzip sampledata-1.2.gz");
1104 system("cat sampledata-1.2 | $mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1105 system("gzip -9 sampledata-1.2");
1106 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
1107 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
1108 showmessage(getmessage('SampleDataInstalled'), 'PressEnter');
1111 my $response=showmessage(getmessage('AddBranchPrinter'), 'yn', 'y');
1113 unless ($response =~/^n/i) {
1114 my $branch='Main Library';
1115 print "Enter a name for the library branch [$branch]: ";
1116 $branch=showmessage(getmessage('BranchName', [$branch]), 'free', $branch, 1);
1117 $branch=~s/[^A-Za-z0-9\s]//g;
1119 my $branchcode=$branch;
1120 $branchcode=~s/[^A-Za-z0-9]//g;
1121 $branchcode=uc($branchcode);
1122 $branchcode=substr($branchcode,0,4);
1123 $branchcode=showmessage(getmessage('BranchCode', [$branchcode]), 'free', $branchcode, 1);
1124 $branchcode=~s/[^A-Z]//g;
1125 $branchcode=uc($branchcode);
1126 $branchcode=substr($branchcode,0,4);
1128 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
1130 my $printername='Library Printer';
1131 $printername=showmessage(getmessage('PrinterName', [$printername]), 'free', $printername, 1);
1132 $printername=~s/[^A-Za-z0-9\s]//g;
1134 my $printerqueue='lp';
1135 $printerqueue=showmessage(getmessage('PrinterQueue', [$printerqueue]), 'free', $printerqueue, 1);
1136 $printerqueue=~s/[^A-Za-z0-9]//g;
1137 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
1147 $messages->{'RestartApache'}->{en}=qq|
1152 Apache needs to be restarted to load the new configuration for Koha.
1154 Would you like to restart Apache now? [Y]/N: |;
1158 my $response=showmessage(getmessage('RestartApache'), 'yn', 'y');
1162 unless ($response=~/^n/i) {
1163 # Need to support other init structures here?
1164 if (-e "/etc/rc.d/init.d/httpd") {
1165 system('/etc/rc.d/init.d/httpd restart');
1166 } elsif (-e "/etc/init.d/apache") {
1167 system('/etc//init.d/apache restart');
1168 } elsif (-e "/etc/init.d/apache-ssl") {
1169 system('/etc/init.d/apache-ssl restart');
1175 sub loadconfigfile {
1178 open (KC, "/etc/koha.conf");
1181 (next) if (/^\s*#/);
1182 if (/(.*)\s*=\s*(.*)/) {
1185 # Clean up white space at beginning and end
1186 $variable=~s/^\s*//g;
1187 $variable=~s/\s*$//g;
1190 $configfile{$variable}=$value;
1194 $::intranetdir=$configfile{'intranetdir'};
1195 $::opacdir=$configfile{'opacdir'};
1196 $::kohaversion=$configfile{'kohaversion'};
1197 $::kohalogdir=$configfile{'kohalogdir'};
1198 $::database=$configfile{'database'};
1199 $::hostname=$configfile{'hostname'};
1200 $::user=$configfile{'user'};
1201 $::pass=$configfile{'pass'};
1204 END { } # module clean-up code here (global destructor)