bugfix
[koha.git] / installer.pl
blobeacc3dd7c408424ec067d797a1df7de9ed2f52b2
1 #!/usr/bin/perl -w # please develop with -w
3 # $Id$
5 #use diagnostics;
7 # Copyright 2000-2002 Katipo Communications
9 # This file is part of Koha.
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA 02111-1307 USA
24 use strict; # please develop with the strict pragma
26 if ($<) {
27 print "\n\nYou must run $0 as root.\n\n";
28 exit;
30 unless ($< == 0) {
31 print "You must be root to run this script.\n";
32 exit 1;
35 my $kohaversion=`cat koha.version`;
36 chomp $kohaversion;
39 if ($kohaversion =~ /RC/) {
40 print qq|
41 =====================
42 = RELEASE CANDIDATE =
43 =====================
45 WARNING WARNING WARNING WARNING WARNING
47 You are about to install Koha version $kohaversion. This version of Koha is a
48 release candidate. It is not intended to be installed on production systems.
49 It is being released so that users can test it before we release a final
50 version.
53 print "Are you sure you want to install Koha $kohaversion? (Y/[N]): ";
55 my $answer = <STDIN>;
56 chomp $answer;
58 if ($answer eq "Y" || $answer eq "y") {
59 print "Great! continuing setup... \n";
60 } else {
61 print qq|
63 Watch for announcements of Koha releases on the Koha mailing list or the Koha
64 web site (http://www.koha.org/).
67 exit;
71 if (-e "/etc/koha.conf") {
72 my $installedversion=`grep kohaversion= /etc/koha.conf`;
73 chomp $installedversion;
74 $installedversion=~m/kohaversion=(.*)/;
75 $installedversion=$1;
76 if ($installedversion) {
77 $installedversion="You currently have Koha $installedversion on your system.\n";
78 } else {
79 $installedversion="I am not able to determine what version of Koha is installed now.\n";
82 print qq|
83 ==========================
84 = Koha already installed =
85 ==========================
87 It looks like Koha is already installed on your system (/etc/koha.conf exists
88 already). If you would like to upgrade your system to $kohaversion, please use
89 the koha.upgrade script in this directory.
91 $installedversion
94 exit;
97 system('clear');
98 print qq|
99 **********************************
100 * Welcome to the Koha Installer *
101 **********************************
102 Welcome to the Koha install script! This script will prompt you for some
103 basic information about your desired setup, then install Koha according to
104 your specifications. To accept the default value for any question, simply hit
105 Enter at the prompt.
107 Please be sure to read the documentation, or visit the Koha website at
108 http://www.koha.org for more information.
110 Are you ready to begin the installation? (Y/[N]):
113 my $answer = <STDIN>;
114 chomp $answer;
116 if ($answer eq "Y" || $answer eq "y") {
117 print "Great! continuing setup... \n";
118 } else {
119 print qq|
120 This installer currently does not support a completely automated
121 setup.
123 Please be sure to read the documentation, or visit the Koha website
124 at http://www.koha.org for more information.
126 exit;
129 print "\n";
132 # Test for Perl and Modules
134 print qq|
136 PERL & MODULES
137 ==============
141 print "\nChecking perl modules ...\n";
142 unless (eval "require 5.004") {
143 die "Sorry, you need at least Perl 5.004\n";
146 my @missing = ();
147 unless (eval {require DBI}) { push @missing,"DBI" };
148 unless (eval {require Date::Manip}) { push @missing,"Date::Manip" };
149 unless (eval {require DBD::mysql}) { push @missing,"DBD::mysql" };
150 unless (eval {require Net::Z3950}) {
151 print qq|
153 The Net::Z3950 module is missing. This module is necessary if you want to use
154 Koha's Z39.50 client to download bibliographic records from other libraries.
155 To install this module, you will need the yaz client installed from
156 http://www.indexdata.dk/yaz/ and then you can install the perl module with the
157 command:
159 perl -MCPAN -e 'install Net::Z3950'
161 Press the <ENTER> key to continue:
163 <STDIN>;
167 # Print out a list of any missing modules
169 if (@missing > 0) {
170 print "\n\n";
171 print "You are missing some Perl modules which are required by Koha.\n";
172 print "Once these modules have been installed, rerun this installer.\n";
173 print "They can be installed by running (as root) the following:\n";
174 foreach my $module (@missing) {
175 print " perl -MCPAN -e 'install \"$module\"'\n";
176 exit(1);
177 }} else{
178 print "All modules appear to be installed, continuing...\n";
182 print "\n";
183 my $input;
184 my $domainname = `hostname -d`;
185 chomp $domainname;
186 my $opacdir = '/usr/local/koha/opac';
187 my $kohadir = '/usr/local/koha/intranet';
188 my $getdirinfo=1;
189 while ($getdirinfo) {
190 # Loop until opac directory and koha directory are different
191 print qq|
193 OPAC DIRECTORY
194 ==============
195 Please supply the directory you want Koha to store its OPAC files in. Leave off
196 the trailing slash. This directory will be auto-created for you if it doesn't
197 exist.
199 Usually $opacdir
202 print "Enter directory [$opacdir]: ";
203 chomp($input = <STDIN>);
205 if ($input) {
206 $opacdir = $input;
210 print qq|
212 INTRANET/LIBRARIANS DIRECTORY
213 =============================
214 Please supply the directory you want Koha to store its Intranet/Librarians files
215 in. Leave off the trailing slash. This directory will be auto-created for you if
216 it doesn't exist.
220 print "Enter directory [$kohadir]: ";
221 chomp($input = <STDIN>);
223 if ($input) {
224 $kohadir = $input;
226 if ($kohadir eq $opacdir) {
227 print qq|
229 You must specify different directories for the OPAC and INTRANET files!
232 } else {
233 $getdirinfo=0;
238 #KOHA conf
240 my $etcdir = '/etc';
241 my $dbname = 'Koha';
242 my $hostname = 'localhost';
243 my $user = 'kohaadmin';
244 my $pass = '';
246 print qq|
248 KOHA.CONF
249 =========
250 Koha uses a small configuration file that is placed in your /etc/ files
251 directory. The configuration file, will be created in this directory.
255 #Get the path to the koha.conf directory
256 #print "Enter the path to your configuration directory [$etcdir]: ";
257 #chomp($input = <STDIN>);
259 #if ($input) {
260 # $etcdir = $input;
264 #Get the database name
265 print qq|
267 Please provide the name of the mysql database for your koha installation.
268 This is normally "$dbname".
272 print "Enter database name [$dbname]: ";
273 chomp($input = <STDIN>);
275 if ($input) {
276 $dbname = $input;
280 #Get the hostname for the database
281 print qq|
283 Please provide the hostname for mysql. Unless the database is located on another
284 machine this will be "localhost".
287 print "Enter hostname [$hostname]: ";
288 chomp($input = <STDIN>);
290 if ($input) {
291 $hostname = $input;
294 #Get the username for the database
295 print qq|
297 Please provide the name of the user, who will have full administrative rights
298 to the $dbname database, when authenticating from $hostname.
300 If no user is entered it will default to $user.
303 print "Enter username [$user]:";
304 chomp($input = <STDIN>);
306 if ($input) {
307 $user = $input;
310 #Get the password for the database user
311 print qq|
313 Please provide a good password for the user $user.
316 print "Enter password:";
317 chomp($input = <STDIN>);
319 if ($input) {
320 $pass = $input;
323 print "\n";
327 print "Successfully created the Koha configuration file.\n";
329 my $httpduser;
330 my $realhttpdconf;
332 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
333 /usr/local/etc/apache/httpd.conf
334 /usr/local/etc/apache/apache.conf
335 /var/www/conf/httpd.conf
336 /etc/apache/conf/httpd.conf
337 /etc/apache/conf/apache.conf
338 /etc/apache-ssl/conf/apache.conf
339 /etc/httpd/conf/httpd.conf
340 /etc/httpd/httpd.conf)) {
341 if ( -f $httpdconf ) {
342 $realhttpdconf=$httpdconf;
343 open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to open $httpdconf for reading.\n";
344 while (<HTTPDCONF>) {
345 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
346 $httpduser = $1;
349 close(HTTPDCONF);
352 unless ($realhttpdconf) {
353 print qq|
355 I was not able to find your apache configuration file. It is usually
356 called httpd.conf or apache.conf.
358 print "Where is your Apache configuratin file? ";
359 chomp($input = <STDIN>);
361 if ($input) {
362 $realhttpdconf = $input;
363 } else {
364 $realhttpdconf='';
366 if ( -f $realhttpdconf ) {
367 open (HTTPDCONF, $realhttpdconf) or warn "Insufficient privileges to open $realhttpdconf for reading.\n";
368 while (<HTTPDCONF>) {
369 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
370 $httpduser = $1;
373 close(HTTPDCONF);
377 unless ($httpduser) {
378 print qq|
380 I was not able to determine the user that Apache is running as. This
381 information is necessary in order to set the access privileges correctly on
382 /etc/koha.conf. This user should be set in one of the Apache configuration
383 files using the "User" directive.
385 print "What is your Apache user? ";
386 chomp($input = <STDIN>);
388 if ($input) {
389 $httpduser = $input;
390 } else {
391 $httpduser='Undetermined';
397 #SETUP opac
399 my $svr_admin = "webmaster\@$domainname";
400 my $servername=`hostname -f`;
401 chomp $servername;
402 my $opacport=80;
403 my $kohaport=8080;
405 print qq|
407 OPAC and KOHA/LIBRARIAN CONFIGURATION
408 =====================================
409 Koha needs to setup your Apache configuration file for the
410 OPAC and LIBRARIAN virtual hosts. By default this installer
411 will do this by using one ip address and two different ports
412 for the virtual hosts. There are other ways to set this up,
413 and the installer will leave comments in httpd.conf detailing
414 what these other options are.
416 Please enter the e-mail address for your webserver admin.
417 Usually $svr_admin
420 print "Enter e-mail address [$svr_admin]:";
421 chomp($input = <STDIN>);
423 if ($input) {
424 $svr_admin = $input;
428 print qq|
431 Please enter the domain name or ip address of your computer.
433 print "Enter server name/ip address [$servername]:";
434 chomp($input = <STDIN>);
436 if ($input) {
437 $servername = $input;
440 print qq|
442 Please enter the port for your OPAC interface.
444 print "Enter OPAC port [$opacport]:";
445 chomp($input = <STDIN>);
447 if ($input) {
448 $opacport = $input;
451 print qq|
453 Please enter the port for your Intranet/Librarian interface.
455 print "Enter intranet port [$kohaport]:";
456 chomp($input = <STDIN>);
458 if ($input) {
459 $kohaport = $input;
464 # Update Apache Conf File.
468 my $logfiledir=`grep ^ErrorLog $realhttpdconf`;
469 chomp $logfiledir;
471 if ($logfiledir) {
472 $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
473 $logfiledir=$1;
476 unless ($logfiledir) {
477 $logfiledir='logs';
479 print qq|
481 UPDATING APACHE.CONF
482 ====================
487 print "Checking for modules that need to be loaded...\n";
488 my $httpdconf='';
489 my $envmodule=0;
490 my $includesmodule=0;
491 open HC, $realhttpdconf;
492 while (<HC>) {
493 if (/^\s*#\s*LoadModule env_module /) {
494 s/^\s*#\s*//;
495 print " Loading env_module in httpd.conf\n";
496 $envmodule=1;
498 if (/^\s*#\s*LoadModule includes_module /) {
499 s/^\s*#\s*//;
500 print " Loading includes_module in httpd.conf\n";
502 if (/\s*LoadModule includes_module / ) {
503 $includesmodule=1;
505 $httpdconf.=$_;
508 my $apachebackupmade=0;
509 if ($envmodule || $includesmodule) {
510 system("mv -f $realhttpdconf $realhttpdconf\.prekoha");
511 $apachebackupmade=1;
512 open HC, ">$realhttpdconf";
513 print HC $httpdconf;
514 close HC;
518 if (`grep 'VirtualHost $servername' $realhttpdconf`) {
519 print qq|
520 $realhttpdconf appears to already have an entry for Koha
521 Virtual Hosts. You may need to edit $realhttpdconf
522 if anything has changed since it was last set up. This
523 script will not attempt to modify an existing Koha apache
524 configuration.
527 print "Press <ENTER> to continue...";
528 <STDIN>;
529 print "\n";
530 } else {
531 unless ($apachebackupmade) {
532 system("cp -f $realhttpdconf $realhttpdconf\.prekoha");
534 my $includesdirectives='';
535 if ($includesmodule) {
536 $includesdirectives.="Options +Includes\n";
537 $includesdirectives.=" AddHandler server-parsed .html\n";
539 open(SITE,">>$realhttpdconf") or warn "Insufficient priveleges to open $realhttpdconf for writing.\n";
540 print SITE <<EOP
543 # Ports to listen to for Koha
544 Listen $opacport
545 Listen $kohaport
547 # NameVirtualHost is used by one of the optional configurations detailed below
549 #NameVirtualHost 11.22.33.44
551 # KOHA's OPAC Configuration
552 <VirtualHost $servername\:$opacport>
553 ServerAdmin $svr_admin
554 DocumentRoot $opacdir/htdocs
555 ServerName $servername
556 ScriptAlias /cgi-bin/koha/ $opacdir/cgi-bin/
557 ErrorLog $logfiledir/opac-error_log
558 TransferLog $logfiledir/opac-access_log
559 SetEnv PERL5LIB "$kohadir/modules"
560 $includesdirectives
561 </VirtualHost>
563 # KOHA's INTRANET Configuration
564 <VirtualHost $servername\:$kohaport>
565 ServerAdmin $svr_admin
566 DocumentRoot $kohadir/htdocs
567 ServerName $servername
568 ScriptAlias /cgi-bin/koha/ "$kohadir/cgi-bin/"
569 ErrorLog $logfiledir/koha-error_log
570 TransferLog $logfiledir/koha-access_log
571 SetEnv PERL5LIB "$kohadir/modules"
572 $includesdirectives
573 </VirtualHost>
575 # If you want to use name based Virtual Hosting:
576 # 1. remove the two Listen lines
577 # 2. replace $servername\:$opacport wih your.opac.domain.name
578 # 3. replace ServerName $servername wih ServerName your.opac.domain.name
579 # 4. replace $servername\:$kohaport wih your intranet domain name
580 # 5. replace ServerName $servername wih ServerName your.intranet.domain.name
582 # If you want to use NameVirtualHost'ing (using two names on one ip address):
583 # 1. Follow steps 1-5 above
584 # 2. Uncomment the NameVirtualHost line and set the correct ip address
590 print qq|
592 Intranet Authentication
593 =======================
595 I can set it up so that the Intranet/Librarian site is password protected.
597 print "Would you like to do this? ([Y]/N): ";
598 chomp($input = <STDIN>);
600 my $apacheauthusername='librarian';
601 my $apacheauthpassword='';
602 unless ($input=~/^n/i) {
603 print "\nEnter a userid to login with [$apacheauthusername]: ";
604 chomp ($input = <STDIN>);
605 if ($input) {
606 $apacheauthusername=$input;
607 $apacheauthusername=~s/[^a-zA-Z0-9]//g;
609 while (! $apacheauthpassword) {
610 print "\nEnter a password for the $apacheauthusername user: ";
611 chomp ($input = <STDIN>);
612 if ($input) {
613 $apacheauthpassword=$input;
615 if (!$apacheauthpassword) {
616 print "\nPlease enter a password.\n";
619 open AUTH, ">/etc/kohaintranet.pass";
620 my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
621 my $salt=substr($chars, int(rand(length($chars))),1);
622 $salt.=substr($chars, int(rand(length($chars))),1);
623 print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
624 close AUTH;
625 print SITE <<EOP
627 <Directory $kohadir>
628 AuthUserFile /etc/kohaintranet.pass
629 AuthType Basic
630 AuthName "Koha Intranet (for librarians only)"
631 Require valid-user
632 </Directory>
636 close(SITE);
638 print "Successfully updated Apache Configuration file.\n";
641 print qq|
643 SETTING UP Z39.50 DAEMON
644 ========================
647 my $kohalogdir='/var/log/koha';
648 print "Directory for logging by Z39.50 daemon [$kohalogdir]: ";
649 chomp($input = <STDIN>);
650 if ($input) {
651 $kohalogdir=$input;
654 unless (-e "$kohalogdir") {
655 my $result = mkdir 0770, "$kohalogdir";
656 if ($result==0) {
657 my @dirs = split(m#/#, $kohalogdir);
658 my $checkdir='';
659 foreach (@dirs) {
660 $checkdir.="$_/";
661 unless (-e "$checkdir") {
662 mkdir($checkdir, 0775);
669 # Setup the modules directory
671 print qq|
673 CREATING REQUIRED DIRECTORIES
674 =============================
679 unless ( -d $kohadir ) {
680 print "Creating $kohadir...\n";
681 my $result=mkdir ($kohadir, oct(770));
682 if ($result==0) {
683 my @dirs = split(m#/#, $kohadir);
684 my $checkdir='';
685 foreach (@dirs) {
686 $checkdir.="$_/";
687 unless (-e "$checkdir") {
688 mkdir($checkdir, 0775);
692 chown (oct(0), (getgrnam($httpduser))[2], "$kohadir");
693 chmod (oct(770), "$kohadir");
695 unless ( -d "$kohadir/htdocs" ) {
696 print "Creating $kohadir/htdocs...\n";
697 mkdir ("$kohadir/htdocs", oct(750));
699 unless ( -d "$kohadir/cgi-bin" ) {
700 print "Creating $kohadir/cgi-bin...\n";
701 mkdir ("$kohadir/cgi-bin", oct(750));
703 unless ( -d "$kohadir/modules" ) {
704 print "Creating $kohadir/modules...\n";
705 mkdir ("$kohadir/modules", oct(750));
707 unless ( -d "$kohadir/scripts" ) {
708 print "Creating $kohadir/scripts...\n";
709 mkdir ("$kohadir/scripts", oct(750));
711 unless ( -d $opacdir ) {
712 print "Creating $opacdir...\n";
713 my $result=mkdir ($opacdir, oct(770));
714 if ($result==0) {
715 my @dirs = split(m#/#, $opacdir);
716 my $checkdir='';
717 foreach (@dirs) {
718 $checkdir.="$_/";
719 unless (-e "$checkdir") {
720 mkdir($checkdir, 0775);
724 chown (oct(0), (getgrnam($httpduser))[2], "$opacdir");
725 chmod (oct(770), "$opacdir");
727 unless ( -d "$opacdir/htdocs" ) {
728 print "Creating $opacdir/htdocs...\n";
729 mkdir ("$opacdir/htdocs", oct(750));
731 unless ( -d "$opacdir/cgi-bin" ) {
732 print "Creating $opacdir/cgi-bin...\n";
733 mkdir ("$opacdir/cgi-bin", oct(750));
738 print "\n\nINSTALLING KOHA...\n";
739 print "\n\n==================\n";
740 print "Copying internet-html files to $kohadir/htdocs...\n";
741 system("cp -R intranet-html/* $kohadir/htdocs/");
742 print "Copying intranet-cgi files to $kohadir/cgi-bin...\n";
743 system("cp -R intranet-cgi/* $kohadir/cgi-bin/");
744 print "Copying script files to $kohadir/scripts...\n";
745 system("cp -R scripts/* $kohadir/scripts/");
746 print "Copying module files to $kohadir/modules...\n";
747 system("cp -R modules/* $kohadir/modules/");
748 print "Copying opac-html files to $opacdir/htdocs...\n";
749 system("cp -R opac-html/* $opacdir/htdocs/");
750 print "Copying opac-cgi files to $opacdir/cgi-bin...\n";
751 system("cp -R opac-cgi/* $opacdir/cgi-bin/");
753 system("chown -R root.$httpduser $opacdir");
754 system("chown -R root.$httpduser $kohadir");
758 #Create the configuration file
759 open(SITES,">$etcdir/koha.conf") or warn "Couldn't create file
760 at $etcdir. Must have write capability.\n";
761 print SITES <<EOP
762 database=$dbname
763 hostname=$hostname
764 user=$user
765 pass=$pass
766 intrahtdocs=$kohadir/cgi-bin/koha-tmpl/intranet-tmpl
767 opachtdocs=$kohadir/cgi-bin/koha-tmpl/opac-tmpl
768 kohalogdir=$kohalogdir
769 kohaversion=$kohaversion
770 httpduser=$httpduser
773 close(SITES);
776 # Set ownership of the koha.conf file for security
778 chown((getpwnam($httpduser)) [2,3], "$etcdir/koha.conf") or warn "can't chown koha.conf: $!";
779 chmod 0440, "$etcdir/koha.conf";
782 print qq|
784 MYSQL CONFIGURATION
785 ===================
787 my $mysql;
788 my $mysqldir;
789 my $mysqluser = 'root';
790 my $mysqlpass = '';
792 foreach my $mysql (qw(/usr/local/mysql
793 /opt/mysql
794 /usr
795 )) {
796 if ( -d $mysql ) {
797 $mysqldir=$mysql;
800 if (!$mysqldir){
801 $mysqldir='/usr';
803 print qq|
804 To allow us to create the koha database please supply the
805 mysql\'s root users password
808 my $needpassword=1;
809 while ($needpassword) {
810 print "Enter mysql\'s root users password: ";
811 chomp($input = <STDIN>);
812 $mysqlpass = $input;
813 my $result=system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass proc > /dev/null 2>&1");
814 if ($result) {
815 print "\n\nInvalid password for the MySql root user.\n\n";
816 } else {
817 $needpassword=0;
822 print qq|
824 CREATING DATABASE
825 =================
827 my $result=system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass create $dbname");
828 if ($result) {
829 print "\nCouldn't connect to the MySQL server for the reason given above.\n";
830 print "This is a serious problem, the database will not get installed.\a\n";
831 print "Press <ENTER> to continue...";
832 <STDIN>;
833 print "\n";
834 } else {
835 system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname < koha.mysql");
836 system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass mysql -e \"insert into user (Host,User,Password) values ('$hostname','$user',password('$pass'))\"\;");
837 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')\"");
838 system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass reload");
840 system ("perl -I $kohadir/modules scripts/updater/updatedatabase");
843 print qq|
845 SAMPLE DATA
846 ===========
847 If you are installing Koha for evaluation purposes, I have a batch of sample
848 data that you can install now.
850 If you are installing Koha with the intention of populating it with your own
851 data, you probably don't want this sample data installed.
853 print "\nWould you like to install the sample data? Y/[N]: ";
854 chomp($input = <STDIN>);
855 if ($input =~/^y/i) {
856 system("gunzip sampledata-1.2.gz");
857 system("cat sampledata-1.2 | $mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname");
858 system("gzip -9 sampledata-1.2");
859 system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
860 system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
861 print qq|
863 Sample data has been installed. For some suggestions on testing Koha, please
864 read the file doc/HOWTO-Testing. If you find any bugs, please submit them at
865 http://bugs.koha.org/. If you need help with testing Koha, you can post a
866 question through the koha-devel mailing list, or you can check for a developer
867 online at +irc.katipo.co.nz:6667 channel #koha.
869 You can find instructions for subscribing to the Koha mailing lists at:
871 http://www.koha.org
874 Press <ENTER> to continue...
876 <STDIN>;
877 } else {
878 print "\n\nWould you like to add a branch and printer? [Y]/N: ";
879 chomp($input = <STDIN>);
882 unless ($input =~/^n/i) {
883 my $branch='Main Library';
884 print "Enter a name for the library branch [$branch]: ";
885 chomp($input = <STDIN>);
886 if ($input) {
887 $branch=$input;
889 $branch=~s/[^A-Za-z0-9\s]//g;
890 my $branchcode=$branch;
891 $branchcode=~s/[^A-Za-z0-9]//g;
892 $branchcode=uc($branchcode);
893 $branchcode=substr($branchcode,0,4);
894 print "Enter a four letter code for your branch [$branchcode]: ";
895 chomp($input = <STDIN>);
896 if ($input) {
897 $branchcode=$input;
899 $branchcode=~s/[^A-Z]//g;
900 $branchcode=uc($branchcode);
901 $branchcode=substr($branchcode,0,4);
902 print "Adding branch '$branch' with code '$branchcode'.\n";
903 system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
904 my $printername='Library Printer';
905 print "Enter a name for the printer [$printername]: ";
906 chomp($input = <STDIN>);
907 if ($input) {
908 $printername=$input;
910 $printername=~s/[^A-Za-z0-9\s]//g;
911 my $printerqueue='lp';
912 print "Enter the queue for the printer [$printerqueue]: ";
913 chomp($input = <STDIN>);
914 if ($input) {
915 $printerqueue=$input;
917 $printerqueue=~s/[^A-Za-z0-9]//g;
918 system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
925 print qq|
927 UPDATING DATABASE (MARC TABLES)
928 ===============================
930 system ("perl -I $kohadir/modules scripts/marc/fill_usmarc.pl");
931 system ("perl -I $kohadir/modules scripts/marc/updatedb2marc.pl");
934 chmod 0770, $kohalogdir;
935 chown((getpwnam($httpduser)) [2,3], $kohalogdir) or warn "can't chown $kohalogdir: $!";
937 # LAUNCH SCRIPT
938 print "Modifying Z39.50 daemon launch script...\n";
939 my $newfile='';
940 open (L, "$kohadir/scripts/z3950daemon/z3950-daemon-launch.sh");
941 while (<L>) {
942 if (/^RunAsUser=/) {
943 $newfile.="RunAsUser=$httpduser\n";
944 } elsif (/^KohaZ3950Dir=/) {
945 $newfile.="KohaZ3950Dir=$kohadir/scripts/z3950daemon\n";
946 } else {
947 $newfile.=$_;
950 close L;
951 system("mv $kohadir/scripts/z3950daemon/z3950-daemon-launch.sh $kohadir/scripts/z3950daemon/z3950-daemon-launch.sh.orig");
952 open L, ">$kohadir/scripts/z3950daemon/z3950-daemon-launch.sh";
953 print L $newfile;
954 close L;
957 # SHELL SCRIPT
958 print "Modifying Z39.50 daemon wrapper script...\n";
959 $newfile='';
960 open (S, "$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh");
961 while (<S>) {
962 if (/^KohaModuleDir=/) {
963 $newfile.="KohaModuleDir=$kohadir/modules\n";
964 } elsif (/^KohaZ3950Dir=/) {
965 $newfile.="KohaZ3950Dir=$kohadir/scripts/z3950daemon\n";
966 } elsif (/^LogDir=/) {
967 $newfile.="LogDir=$kohalogdir\n";
968 } else {
969 $newfile.=$_;
972 close S;
974 system("mv $kohadir/scripts/z3950daemon/z3950-daemon-shell.sh $kohadir/scripts/z3950daemon/z3950-daemon-shell.sh.orig");
975 open S, ">$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh";
976 print S $newfile;
977 close S;
978 chmod 0750, "$kohadir/scripts/z3950daemon/z3950-daemon-launch.sh";
979 chmod 0750, "$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh";
980 chmod 0750, "$kohadir/scripts/z3950daemon/processz3950queue";
981 chown(0, (getpwnam($httpduser)) [3], "$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $kohadir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
982 chown(0, (getpwnam($httpduser)) [3], "$kohadir/scripts/z3950daemon/processz3950queue") or warn "can't chown $kohadir/scripts/z3950daemon/processz3950queue: $!";
985 #RESTART APACHE
986 print "\n\n";
987 print qq|
989 COMPLETED
990 =========
991 Congratulations ... your Koha installation is almost complete!
992 The final step is to restart your webserver.
994 You will be able to connect to your Librarian interface at:
996 http://$servername\:$kohaport/
998 and the OPAC interface at :
1000 http://$servername\:$opacport/
1003 Be sure to read the INSTALL, and Hints files.
1005 For more information visit http://www.koha.org
1007 Would you like to restart your webserver now? (Y/[N]):
1010 my $restart = <STDIN>;
1011 chomp $restart;
1013 if ($restart=~/^y/i) {
1014 # Need to support other init structures here?
1015 if (-e "/etc/rc.d/init.d/httpd") {
1016 system('/etc/rc.d/init.d/httpd restart');
1017 } elsif (-e "/etc/init.d/apache") {
1018 system('/etc//init.d/apache restart');
1019 } elsif (-e "/etc/init.d/apache-ssl") {
1020 system('/etc/init.d/apache-ssl restart');
1022 } else {
1023 print qq|
1024 Congratulations ... your Koha installation is complete!
1025 You will need to restart your webserver before using Koha!
1027 exit;