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 Digest::MD5}) { push @missing,"Digest::MD5" };
222 unless (eval {require Net::Z3950}) {
223 my $message = getmessage('NETZ3950Missing');
224 showmessage($message, 'PressEnter', '', 1);
226 push @missing, "Net::Z3950";
231 # Print out a list of any missing modules
236 foreach my $module (@missing) {
237 $missing.=" perl -MCPAN -e 'install \"$module\"'\n";
239 my $message=getmessage('MissingPerlModules', [$missing]);
240 showmessage($message, 'none');
243 showmessage(getmessage('AllPerlModulesInstalled'), 'PressEnter', '', 1);
251 my $messagename=shift;
253 my $message=$messages->{$messagename}->{$::language} || $messages->{$messagename}->{en} || "Error: No message named $messagename in Install.pm\n";
254 if (defined($variables)) {
255 $message=sprintf $message, @$variables;
263 my $responsetype=shift;
264 my $defaultresponse=shift;
266 ($noclear) || (system('clear'));
267 if ($responsetype =~ /^yn$/) {
268 $responsetype='restrictchar yn';
272 if ($responsetype =~/^restrictchar (.*)/i) {
275 until ($options=~/$response/) {
276 ($defaultresponse) || ($defaultresponse=substr($options,0,1));
279 (length($response)) || ($response=$defaultresponse);
280 unless ($options=~/$response/) {
281 ($noclear) || (system('clear'));
282 print "Invalid Response. Choose from [$options].\n\n";
288 if ($responsetype =~/^free$/i) {
289 (defined($defaultresponse)) || ($defaultresponse='');
290 my $response=<STDIN>;
292 ($response) || ($response=$defaultresponse);
295 if ($responsetype =~/^numerical$/i) {
296 (defined($defaultresponse)) || ($defaultresponse='');
298 until ($response=~/^\d+$/) {
301 ($response) || ($response=$defaultresponse);
302 unless ($response=~/^\d+$/) {
303 ($noclear) || (system('clear'));
304 print "Invalid Response ($response). Response must be a number.\n\n";
310 if ($responsetype =~/^email$/i) {
311 (defined($defaultresponse)) || ($defaultresponse='');
313 until ($response=~/.*\@.*\..*/) {
316 ($response) || ($response=$defaultresponse);
317 unless ($response=~/.*\@.*\..*/) {
318 ($noclear) || (system('clear'));
319 print "Invalid Response ($response). Response must be a valid email address.\n\n";
325 if ($responsetype =~/^PressEnter$/i) {
329 if ($responsetype =~/^none$/i) {
335 sub getinstallationdirectories {
336 $::opacdir = '/usr/local/koha/opac';
337 $::intranetdir = '/usr/local/koha/intranet';
339 while ($getdirinfo) {
340 # Loop until opac directory and koha directory are different
341 my $message=getmessage('GetOpacDir', [$::opacdir]);
342 $::opacdir=showmessage($message, 'free', $::opacdir);
344 $message=getmessage('GetIntranetDir', [$::intranetdir]);
345 $::intranetdir=showmessage($message, 'free', $::intranetdir);
347 if ($::intranetdir eq $::opacdir) {
350 You must specify different directories for the OPAC and INTRANET files!
351 :: $::intranetdir :: $::opacdir ::
358 $::kohalogdir='/var/log/koha';
359 my $message=getmessage('GetKohaLogDir', [$::kohalogdir]);
360 $::kohalogdir=showmessage($message, 'free', $::kohalogdir);
363 unless ( -d $::intranetdir ) {
364 my $result=mkdir ($::intranetdir, oct(770));
366 my @dirs = split(m#/#, $::intranetdir);
370 unless (-e "$checkdir") {
371 mkdir($checkdir, 0775);
375 chown (oct(0), (getgrnam($::httpduser))[2], "$::intranetdir");
376 chmod (oct(770), "$::intranetdir");
378 unless ( -d "$::intranetdir/htdocs" ) {
379 mkdir ("$::intranetdir/htdocs", oct(750));
381 unless ( -d "$::intranetdir/cgi-bin" ) {
382 mkdir ("$::intranetdir/cgi-bin", oct(750));
384 unless ( -d "$::intranetdir/modules" ) {
385 mkdir ("$::intranetdir/modules", oct(750));
387 unless ( -d "$::intranetdir/scripts" ) {
388 mkdir ("$::intranetdir/scripts", oct(750));
390 unless ( -d $::opacdir ) {
391 my $result=mkdir ($::opacdir, oct(770));
393 my @dirs = split(m#/#, $::opacdir);
397 unless (-e "$checkdir") {
398 mkdir($checkdir, 0775);
402 chown (oct(0), (getgrnam($::httpduser))[2], "$::opacdir");
403 chmod (oct(770), "$::opacdir");
405 unless ( -d "$::opacdir/htdocs" ) {
406 mkdir ("$::opacdir/htdocs", oct(750));
408 unless ( -d "$::opacdir/cgi-bin" ) {
409 mkdir ("$::opacdir/cgi-bin", oct(750));
413 unless ( -d $::kohalogdir ) {
414 my $result=mkdir ($::kohalogdir, oct(770));
416 my @dirs = split(m#/#, $::kohalogdir);
420 unless (-e "$checkdir") {
421 mkdir($checkdir, 0775);
426 chown (oct(0), (getgrnam($::httpduser))[2,3], "$::kohalogdir");
427 chmod (oct(770), "$::kohalogdir");
433 $messages->{'DatabaseName'}->{en}=qq|
434 ==========================
435 = Name of MySQL database =
436 ==========================
438 Please provide the name of the mysql database for your koha installation.
440 Database name [%s]: |;
442 $messages->{'DatabaseHost'}->{en}=qq|
447 Please provide the hostname for mysql. Unless the database is located on
448 another machine this will be "localhost".
450 Database host [%s]: |;
452 $messages->{'DatabaseUser'}->{en}=qq|
457 Please provide the name of the user, who will have full administrative rights
458 to the %s database, when authenticating from %s.
460 Database user [%s]: |;
462 $messages->{'DatabasePassword'}->{en}=qq|
463 =====================
464 = Database Password =
465 =====================
467 Please provide a good password for the user %s.
469 Database Password: |;
471 $messages->{'BlankPassword'}->{en}=qq|
476 You must not use a blank password for your MySQL user!
478 Press <ENTER> to try again:
481 sub getdatabaseinfo {
484 $::hostname = 'localhost';
485 $::user = 'kohaadmin';
488 #Get the database name
490 my $message=getmessage('DatabaseName', [$::dbname]);
491 $::dbname=showmessage($message, 'free', $::dbname);
493 #Get the hostname for the database
495 $message=getmessage('DatabaseHost', [$::hostname]);
496 $::hostname=showmessage($message, 'free', $::hostname);
498 #Get the username for the database
500 $message=getmessage('DatabaseUser', [$::dbname, $::hostname, $::user]);
501 $::user=showmessage($message, 'free', $::user);
503 #Get the password for the database user
505 while ($::pass eq '') {
506 my $message=getmessage('DatabasePassword', [$::user]);
507 $::pass=showmessage($message, 'free', $::pass);
509 my $message=getmessage('BlankPassword');
510 showmessage($message,'PressEnter');
517 $messages->{'FoundMultipleApacheConfFiles'}->{en}=qq|
518 ================================
519 = MULTIPLE APACHE CONFIG FILES =
520 ================================
522 I found more than one possible Apache configuration file:
526 Choose the correct file [1]: |;
528 $messages->{'NoApacheConfFiles'}->{en}=qq|
529 ===============================
530 = NO APACHE CONFIG FILE FOUND =
531 ===============================
533 I was not able to find your Apache configuration file.
535 The file is usually called httpd.conf or apache.conf.
537 Please specify the location of your config file: |;
539 $messages->{'NotAFile'}->{en}=qq|
540 =======================
541 = FILE DOES NOT EXIST =
542 =======================
544 The file %s does not exist.
546 Please press <ENTER> to continue: |;
548 $messages->{'EnterApacheUser'}->{en}=qq|
553 I was not able to determine the user that Apache is running as. This
554 information is necessary in order to set the access privileges correctly on
555 /etc/koha.conf. This user should be set in one of the Apache configuration
556 files using the "User" directive.
558 Enter the Apache userid: |;
560 $messages->{'InvalidUserid'}->{en}=qq|
565 The userid %s is not a valid userid on this system.
567 Press <ENTER> to continue: |;
570 my @confpossibilities;
572 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
573 /usr/local/etc/apache/httpd.conf
574 /usr/local/etc/apache/apache.conf
575 /var/www/conf/httpd.conf
576 /etc/apache/conf/httpd.conf
577 /etc/apache/conf/apache.conf
578 /etc/apache-ssl/conf/apache.conf
579 /etc/httpd/conf/httpd.conf
580 /etc/httpd/httpd.conf)) {
581 if ( -f $httpdconf ) {
582 push @confpossibilities, $httpdconf;
586 if ($#confpossibilities==-1) {
587 my $message=getmessage('NoApacheConfFiles');
590 $choice=showmessage($message, "free", 1);
591 unless (-f $choice) {
592 showmessage(getmessage('NotAFile', [$choice]),'PressEnter', '', 1);
595 } elsif ($#confpossibilities>0) {
599 foreach (@confpossibilities) {
600 $conffiles.=" $counter: $_\n";
601 $options.="$counter";
604 my $message=getmessage('FoundMultipleApacheConfFiles', [$conffiles]);
605 my $choice=showmessage($message, "restrictchar $options", 1);
606 $::realhttpdconf=$confpossibilities[$choice-1];
608 $::realhttpdconf=$confpossibilities[0];
610 open (HTTPDCONF, $::realhttpdconf) or warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
611 while (<HTTPDCONF>) {
612 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
621 unless ($::httpduser) {
622 my $message=getmessage('EnterApacheUser');
623 until (length($::httpduser) && getpwnam($::httpduser)) {
624 $::httpduser=showmessage($message, "free", '');
625 if (length($::httpduser)>0) {
626 unless (getpwnam($::httpduser)) {
627 my $message=getmessage('InvalidUserid', [$::httpduser]);
628 showmessage($message,'PressEnter');
633 print "AU: $::httpduser\n";
638 $messages->{'ApacheConfigIntroduction'}->{en}=qq|
639 ========================
640 = APACHE CONFIGURATION =
641 ========================
643 Koha needs to setup your Apache configuration file for the
644 OPAC and LIBRARIAN virtual hosts. By default this installer
645 will do this by using one ip address and two different ports
646 for the virtual hosts. There are other ways to set this up,
647 and the installer will leave comments in httpd.conf detailing
648 what these other options are.
651 Press <ENTER> to continue: |;
653 $messages->{'GetVirtualHostEmail'}->{en}=qq|
654 =============================
655 = WEB SERVER E-MAIL CONTACT =
656 =============================
658 Enter the e-mail address to be used as a contact for the virtual hosts (this
659 address is displayed if any errors are encountered).
661 E-mail contact [%s]: |;
663 $messages->{'GetServerName'}->{en}=qq|
664 ======================================
665 = WEB SERVER HOST NAME OR IP ADDRESS =
666 ======================================
668 Please enter the domain name or ip address of your computer.
670 Host name or IP Address [%s]: |;
672 $messages->{'GetOpacPort'}->{en}=qq|
673 ==========================
674 = OPAC VIRTUAL HOST PORT =
675 ==========================
677 Please enter the port for your OPAC interface. This defaults to port 80, but
678 if you are already serving web content from this server, you should change it
679 to a different port (8000 might be a good choice).
681 Enter the OPAC Port [%s]: |;
683 $messages->{'GetIntranetPort'}->{en}=qq|
684 ==============================
685 = INTRANET VIRTUAL HOST PORT =
686 ==============================
688 Please enter the port for your Intranet interface. This must be different from
691 Enter the Intranet Port [%s]: |;
694 sub getapachevhostinfo {
696 $::svr_admin = "webmaster\@$::domainname";
697 $::servername=`hostname -f`;
700 $::intranetport=8080;
702 showmessage(getmessage('ApacheConfigIntroduction'), 'PressEnter');
704 $::svr_admin=showmessage(getmessage('GetVirtualHostEmail', [$::svr_admin]), 'email', $::svr_admin);
705 $::servername=showmessage(getmessage('GetServerName', [$::servername]), 'free', $::servername);
708 $::opacport=showmessage(getmessage('GetOpacPort', [$::opacport]), 'numerical', $::opacport);
709 $::intranetport=showmessage(getmessage('GetIntranetPort', [$::opacport, $::intranetport]), 'numerical', $::intranetport);
713 $messages->{'StartUpdateApache'}->{en}=qq|
714 =================================
715 = UPDATING APACHE CONFIGURATION =
716 =================================
718 Checking for modules that need to be loaded...
721 $messages->{'LoadingApacheModuleModEnv'}->{en}="Loading SetEnv Apache module.\n";
723 $messages->{'LoadingApacheModuleModInc'}->{en}="Loading Includes Apache module.\n";
725 $messages->{'ApacheConfigBackupFailed'}->{en}=qq|
726 ======================================
727 = APACHE CONFIGURATION BACKUP FAILED =
728 ======================================
730 An error occurred while trying to make a backup copy of %s.
734 No changes will be made to the apache configuration file at this time.
736 Press <ENTER> to continue: |;
739 $messages->{'ApacheAlreadyConfigured'}->{en}=qq|
740 =============================
741 = APACHE ALREADY CONFIGURED =
742 =============================
744 %s appears to already have an entry for Koha
745 Virtual Hosts. You may need to edit %s
746 f anything has changed since it was last set up. This
747 script will not attempt to modify an existing Koha apache
750 Press <ENTER> to continue: |;
752 sub updateapacheconf {
753 my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
757 $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
761 unless ($logfiledir) {
765 showmessage(getmessage('StartUpdateApache'), 'none');
769 my $includesmodule=0;
770 open HC, $::realhttpdconf;
772 if (/^\s*#\s*LoadModule env_module /) {
774 showmessage(getmessage('LoadingApacheModuleModEnv'));
777 if (/^\s*#\s*LoadModule includes_module /) {
779 showmessage(getmessage('LoadingApacheModuleModInc'));
781 if (/\s*LoadModule includes_module / ) {
788 $backupfailed=`cp -f $::realhttpdconf $::realhttpdconf\.prekoha`;
790 showmessage(getmessage('ApacheConfigBackupFailed', [$::realhttpdconf,$backupfailed ]), 'PressEnter');
794 if ($envmodule || $includesmodule) {
795 open HC, ">$::realhttpdconf";
802 if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
803 showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
806 my $includesdirectives='';
807 if ($includesmodule) {
808 $includesdirectives.="Options +Includes\n";
809 $includesdirectives.=" AddHandler server-parsed .html\n";
811 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
813 if ($::opacport != 80) {
814 $opaclisten="Listen $::opacport";
816 my $intranetlisten = '';
817 if ($::intranetport != 80) {
818 $intranetlisten="Listen $::intranetport";
822 # Ports to listen to for Koha
826 # NameVirtualHost is used by one of the optional configurations detailed below
828 #NameVirtualHost 11.22.33.44
830 # KOHA's OPAC Configuration
831 <VirtualHost $::servername\:$::opacport>
832 ServerAdmin $::svr_admin
833 DocumentRoot $::opacdir/htdocs
834 ServerName $::servername
835 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
836 ErrorLog $logfiledir/opac-error_log
837 TransferLog $logfiledir/opac-access_log
838 SetEnv PERL5LIB "$::intranetdir/modules"
842 # KOHA's INTRANET Configuration
843 <VirtualHost $::servername\:$::intranetport>
844 ServerAdmin $::svr_admin
845 DocumentRoot $::intranetdir/htdocs
846 ServerName $::servername
847 ScriptAlias /cgi-bin/koha/ "$::intranetdir/cgi-bin/"
848 ErrorLog $logfiledir/koha-error_log
849 TransferLog $logfiledir/koha-access_log
850 SetEnv PERL5LIB "$::intranetdir/modules"
854 # If you want to use name based Virtual Hosting:
855 # 1. remove the two Listen lines
856 # 2. replace $::servername\:$::opacport wih your.opac.domain.name
857 # 3. replace ServerName $::servername wih ServerName your.opac.domain.name
858 # 4. replace $::servername\:$::intranetport wih your intranet domain name
859 # 5. replace ServerName $::servername wih ServerName your.intranet.domain.name
861 # If you want to use NameVirtualHost'ing (using two names on one ip address):
862 # 1. Follow steps 1-5 above
863 # 2. Uncomment the NameVirtualHost line and set the correct ip address
871 $messages->{'IntranetAuthenticationQuestion'}->{en}=qq|
872 ===========================
873 = INTRANET AUTHENTICATION =
874 ===========================
876 I can set it up so that the Intranet/Librarian site is password protected using
877 Apache's Basic Authorization.
879 Would you like to do this ([Y]/N): |;
881 $messages->{'BasicAuthUsername'}->{en}="Please enter a userid for intranet access [%s]: ";
882 $messages->{'BasicAuthPassword'}->{en}="Please enter a password for %s: ";
883 $messages->{'BasicAuthPasswordWasBlank'}->{en}="\nYou cannot use a blank password!\n\n";
885 sub basicauthentication {
886 my $message=getmessage('IntranetAuthenticationQuestion');
887 my $answer=showmessage($message, 'yn', 'y');
889 my $apacheauthusername='librarian';
890 my $apacheauthpassword='';
891 if ($answer=~/^y/i) {
892 ($apacheauthusername) = showmessage(getmessage('BasicAuthUsername', [ $apacheauthusername]), 'free', $apacheauthusername, 1);
893 $apacheauthusername=~s/[^a-zA-Z0-9]//g;
894 while (! $apacheauthpassword) {
895 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPassword', [ $apacheauthusername]), 'free', 1);
896 if (!$apacheauthpassword) {
897 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPasswordWasBlank'), 'none', '', 1);
900 open AUTH, ">/etc/kohaintranet.pass";
901 my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
902 my $salt=substr($chars, int(rand(length($chars))),1);
903 $salt.=substr($chars, int(rand(length($chars))),1);
904 print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
906 open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
909 <Directory $::intranetdir>
910 AuthUserFile /etc/kohaintranet.pass
912 AuthName "Koha Intranet (for librarians only)"
920 $messages->{'InstallFiles'}->{en}=qq|
925 Copying files to installation directories:
930 $messages->{'CopyingFiles'}->{en}="Copying %s to %s.\n";
937 showmessage(getmessage('InstallFiles'),'none');
938 print getmessage('CopyingFiles', ['internet-html', "$::intranetdir/htdocs" ]);
939 system("cp -R intranet-html/* $::intranetdir/htdocs/");
940 print getmessage('CopyingFiles', ['internet-cgi', "$::intranetdir/cgi-bin" ]);
941 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
942 print getmessage('CopyingFiles', ['stand-alone scripts', "$::intranetdir/scripts" ]);
943 system("cp -R scripts/* $::intranetdir/scripts/");
944 print getmessage('CopyingFiles', ['perl modules', "$::intranetdir/modules" ]);
945 system("cp -R modules/* $::intranetdir/modules/");
946 print getmessage('CopyingFiles', ['opac-html', "$::opacdir/htdocs" ]);
947 system("cp -R opac-html/* $::opacdir/htdocs/");
948 print getmessage('CopyingFiles', ['opac-cgi', "$::opacdir/cgi-bin" ]);
949 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
950 system("touch $::opacdir/cgi-bin/opac");
952 system("chown -R root.$::httpduser $::opacdir");
953 system("chown -R root.$::httpduser $::intranetdir");
955 # Create /etc/koha.conf
957 open(KC,">$::etcdir/koha.conf") or warn "Couldn't create file
958 at $::etcdir. Must have write capability.\n";
964 includes=$::intranetdir/htdocs/includes
965 intranetdir=$::intranetdir
967 kohalogdir=$::kohalogdir
968 kohaversion=$::kohaversion
969 httpduser=$::httpduser
973 chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf") or warn "can't chown koha.conf: $!";
974 chmod 0440, "$::etcdir/koha.conf";
976 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
977 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
978 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
979 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
980 chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
984 $messages->{'MysqlRootPassword'}->{en}=qq|
985 ============================
986 = MYSQL ROOT USER PASSWORD =
987 ============================
989 To allow us to create the koha database please supply your
990 mysql server's root user password:
992 Enter MySql root user password: |;
994 $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password. Please try again.";
996 $messages->{'CreatingDatabase'}->{en}=qq|
997 =====================
998 = CREATING DATABASE =
999 =====================
1001 Creating the MySql database for Koha...
1005 $messages->{'CreatingDatabaseError'}->{en}=qq|
1006 ===========================
1007 = ERROR CREATING DATABASE =
1008 ===========================
1010 Couldn't connect to the MySQL server for the reason given above.
1011 This is a serious problem, the database will not get installed.
\a
1013 Press <ENTER> to continue: |;
1015 $messages->{'SampleData'}->{en}=qq|
1020 If you are installing Koha for evaluation purposes, I have a batch of sample
1021 data that you can install now.
1023 If you are installing Koha with the intention of populating it with your own
1024 data, you probably don't want this sample data installed.
1026 Would you like to install the sample data? Y/[N]: |;
1028 $messages->{'SampleDataInstalled'}->{en}=qq|
1029 =========================
1030 = SAMPLE DATA INSTALLED =
1031 =========================
1033 Sample data has been installed. For some suggestions on testing Koha, please
1034 read the file doc/HOWTO-Testing. If you find any bugs, please submit them at
1035 http://bugs.koha.org/. If you need help with testing Koha, you can post a
1036 question through the koha-devel mailing list, or you can check for a developer
1037 online at +irc.katipo.co.nz:6667 channel #koha.
1039 You can find instructions for subscribing to the Koha mailing lists at:
1044 Press <ENTER> to continue: |;
1046 $messages->{'AddBranchPrinter'}->{en}=qq|
1047 ==========================
1048 = Add Branch and Printer =
1049 ==========================
1051 Would you like to install an initial branch and printer? [Y]/N: |;
1053 $messages->{'BranchName'}->{en}="Branch Name [%s]: ";
1054 $messages->{'BranchCode'}->{en}="Branch Code (4 letters or numbers) [%s]: ";
1055 $messages->{'PrinterQueue'}->{en}="Printer Queue [%s]: ";
1056 $messages->{'PrinterName'}->{en}="Printer Name [%s]: ";
1060 $::mysqluser = 'root';
1063 foreach my $mysql (qw(/usr/local/mysql
1076 while ($needpassword) {
1077 $::mysqlpass=showmessage(getmessage('MysqlRootPassword'), 'free');
1078 my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass proc > /dev/null 2>&1");
1080 print getmessage('InvalidMysqlRootPassword');
1086 showmessage(getmessage('CreatingDatabase'),'none');
1088 my $result=system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass create $::dbname");
1090 showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1);
1092 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname < koha.mysql");
1093 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;");
1094 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')\"");
1095 system("$mysqldir/bin/mysqladmin -u$::mysqluser -p$::mysqlpass reload");
1097 system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
1100 my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
1101 if ($response =~/^y/i) {
1102 system("gunzip sampledata-1.2.gz");
1103 system("cat sampledata-1.2 | $mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1104 system("gzip -9 sampledata-1.2");
1105 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
1106 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
1107 showmessage(getmessage('SampleDataInstalled'), 'PressEnter');
1110 my $response=showmessage(getmessage('AddBranchPrinter'), 'yn', 'y');
1112 unless ($response =~/^n/i) {
1113 my $branch='Main Library';
1114 print "Enter a name for the library branch [$branch]: ";
1115 $branch=showmessage(getmessage('BranchName', [$branch]), 'free', $branch, 1);
1116 $branch=~s/[^A-Za-z0-9\s]//g;
1118 my $branchcode=$branch;
1119 $branchcode=~s/[^A-Za-z0-9]//g;
1120 $branchcode=uc($branchcode);
1121 $branchcode=substr($branchcode,0,4);
1122 $branchcode=showmessage(getmessage('BranchCode', [$branchcode]), 'free', $branchcode, 1);
1123 $branchcode=~s/[^A-Z]//g;
1124 $branchcode=uc($branchcode);
1125 $branchcode=substr($branchcode,0,4);
1127 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
1129 my $printername='Library Printer';
1130 $printername=showmessage(getmessage('PrinterName', [$printername]), 'free', $printername, 1);
1131 $printername=~s/[^A-Za-z0-9\s]//g;
1133 my $printerqueue='lp';
1134 $printerqueue=showmessage(getmessage('PrinterQueue', [$printerqueue]), 'free', $printerqueue, 1);
1135 $printerqueue=~s/[^A-Za-z0-9]//g;
1136 system("$mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
1146 $messages->{'RestartApache'}->{en}=qq|
1151 Apache needs to be restarted to load the new configuration for Koha.
1153 Would you like to restart Apache now? [Y]/N: |;
1157 my $response=showmessage(getmessage('RestartApache'), 'yn', 'y');
1161 unless ($response=~/^n/i) {
1162 # Need to support other init structures here?
1163 if (-e "/etc/rc.d/init.d/httpd") {
1164 system('/etc/rc.d/init.d/httpd restart');
1165 } elsif (-e "/etc/init.d/apache") {
1166 system('/etc//init.d/apache restart');
1167 } elsif (-e "/etc/init.d/apache-ssl") {
1168 system('/etc/init.d/apache-ssl restart');
1174 sub loadconfigfile {
1177 open (KC, "/etc/koha.conf");
1180 (next) if (/^\s*#/);
1181 if (/(.*)\s*=\s*(.*)/) {
1184 # Clean up white space at beginning and end
1185 $variable=~s/^\s*//g;
1186 $variable=~s/\s*$//g;
1189 $configfile{$variable}=$value;
1193 $::intranetdir=$configfile{'intranetdir'};
1194 $::opacdir=$configfile{'opacdir'};
1195 $::kohaversion=$configfile{'kohaversion'};
1196 $::kohalogdir=$configfile{'kohalogdir'};
1197 $::database=$configfile{'database'};
1198 $::hostname=$configfile{'hostname'};
1199 $::user=$configfile{'user'};
1200 $::pass=$configfile{'pass'};
1203 END { } # module clean-up code here (global destructor)