moved z3950 scripts to z3950daemon subdir within scripts dir in tarball
[koha.git] / installer.pl
1 #!/usr/bin/perl -w # please develop with -w
2
3 use diagnostics;
4 use strict; # please develop with the strict pragma
5
6 unless ($< == 0) {
7     print "You must be root to run this script.\n";
8     exit 1;
9 }
10
11 system('clear');
12 print qq|
13 **********************************
14 * Welcome to the Koha Installer  *
15 **********************************
16 Welcome to the Koha install script!  This script will prompt you for some
17 basic information about your desired setup, then install Koha according to
18 your specifications.  To accept the default value for any question, simply hit
19 Enter at the prompt.
20
21 Please be sure to read the documentation, or visit the Koha website at 
22 http://www.koha.org for more information.
23
24 Are you ready to begin the installation? (Y/[N]):
25 |;
26
27 my $answer = <STDIN>;
28 chomp $answer;
29
30 if ($answer eq "Y" || $answer eq "y") {
31         print "Great! continuing setup... \n";
32     } else {
33     print qq|
34 This installer currently does not support an completely automated 
35 setup.
36
37 Please be sure to read the documentation, or visit the Koha website 
38 at http://www.koha.org for more information.
39 |;
40     exit;
41 };
42
43 print "\n";
44
45 #
46 # Test for Perl and Modules
47 #
48 print qq|
49
50 PERL & MODULES
51 ==============
52
53 |;
54
55 print "\nChecking perl modules ...\n";
56     unless (eval "require 5.004") {
57     die "Sorry, you need at least Perl 5.004\n";
58 }
59
60 my @missing = ();
61 unless (eval {require DBI})               { push @missing,"DBI" };
62 unless (eval {require Date::Manip})       { push @missing,"Date::Manip" };
63 unless (eval {require DBD::mysql})        { push @missing,"DBD::mysql" };
64 unless (eval {require Set::Scalar})       { push @missing,"Set::Scalar" };
65 #unless (eval {require Net::Z3950})        { 
66 #    print qq|
67 #
68 #The Net::Z3950 module is missing.  This module is necessary if you want to use
69 #Koha's Z39.50 client to download bibliographic records from other libraries.
70 #To install this module, you will need the yaz client installed from
71 #http://www.indexdata.dk/yaz/ and then you can install the perl module with the
72 #command:
73 #
74 #perl -MCPAN -e 'install Net::Z3950'
75 #
76 #Press the <ENTER> key to continue:
77 #|;
78 #    <STDIN>;
79 #}
80
81 #
82 # Print out a list of any missing modules
83 #
84 if (@missing > 0) {
85     print "\n\n";
86     print "You are missing some Perl modules which are required by Koha.\n";
87     print "Once these modules have been installed, rerun this installer.\n";
88     print "They can be installed by running (as root) the following:\n";
89     foreach my $module (@missing) {
90         print "   perl -MCPAN -e 'install \"$module\"'\n";
91         exit(1);
92     }} else{
93     print "All modules appear to be installed, continuing...\n";
94 };
95
96
97 print "\n";
98 my $input;
99 my $domainname = `hostname -d`;
100 chomp $domainname;
101 my $opacdir = '/usr/local/koha/opac';
102 my $kohadir = '/usr/local/koha/intranet';
103 my $getdirinfo=1;
104 while ($getdirinfo) {
105     # Loop until opac directory and koha directory are different
106     print qq|
107
108 OPAC DIRECTORY
109 ==============
110 Please supply the directory you want Koha to store its OPAC files in.  Leave off
111 the trailing slash.  This directory will be auto-created for you if it doesn't
112 exist.
113
114 Usually $opacdir
115 |;
116
117     print "Enter directory [$opacdir]: ";
118     chomp($input = <STDIN>);
119
120     if ($input) {
121       $opacdir = $input;
122     }
123
124
125     print qq|
126
127 INTRANET/LIBRARIANS DIRECTORY
128 =============================
129 Please supply the directory you want Koha to store its Intranet/Librarians files 
130 in.  Leave off the trailing slash.  This directory will be auto-created for you if 
131 it doesn't exist.
132
133 |;
134
135     print "Enter directory [$kohadir]: ";
136     chomp($input = <STDIN>);
137
138     if ($input) {
139       $kohadir = $input;
140     }
141     if ($kohadir eq $opacdir) {
142         print qq|
143
144 You must specify different directories for the OPAC and INTRANET files!
145
146 |;
147     } else {
148         $getdirinfo=0;
149     }
150 }
151
152 #
153 #KOHA conf
154 #
155 my $etcdir = '/etc';
156 my $dbname = 'Koha';
157 my $hostname = 'localhost';
158 my $user = 'kohaadmin';
159 my $pass = '';
160
161 print qq|
162
163 KOHA.CONF
164 =========
165 Koha uses a small configuration file that is usually placed in your /etc/ files 
166 directory. The configuration file, will be created in this directory
167
168 |;
169
170 #Get the path to the koha.conf directory
171 print "Enter the path to your configuration directory [$etcdir]: ";
172 chomp($input = <STDIN>);
173
174 if ($input) {
175   $etcdir = $input;
176 }
177
178
179 #Get the database name
180 print qq|
181
182 Please provide the name of the mysql database for your koha installation.
183 This is normally "$dbname".
184
185 |;
186
187 print "Enter database name [$dbname]: ";
188 chomp($input = <STDIN>);
189
190 if ($input) {
191   $dbname = $input;
192 }
193
194
195 #Get the hostname for the database
196 print qq|
197
198 Please provide the hostname for mysql.  Unless the database is located on another 
199 machine this will be "localhost".
200 |;
201
202 print "Enter hostname [$hostname]: ";
203 chomp($input = <STDIN>);
204
205 if ($input) {
206   $hostname = $input;
207 }
208
209 #Get the username for the database
210 print qq|
211
212 Please provide the name of the user, who will have full administrative rights
213 to the $dbname database, when authenticating from $hostname.
214
215 If no user is entered it will default to $user.
216 |;
217
218 print "Enter username [$user]:";
219 chomp($input = <STDIN>);
220
221 if ($input) {
222   $user = $input;
223 }
224
225 #Get the password for the database user
226 print qq|
227
228 Please provide a good password for the user $user.
229 |;
230
231 print "Enter password:";
232 chomp($input = <STDIN>);
233
234 if ($input) {
235   $pass = $input;
236 }
237
238 print "\n";
239
240
241 #Create the configuration file
242 open(SITES,">$etcdir/koha.conf") or warn "Couldn't create file
243 at $etcdir.  Must have write capability.\n";
244 print SITES <<EOP
245 database=$dbname
246 hostname=$hostname
247 user=$user
248 pass=$pass
249 includes=$kohadir/htdocs/includes
250 EOP
251 ;
252 close(SITES);
253
254 print "Successfully created the Koha configuration file.\n";
255
256 my $httpduser;
257 my $realhttpdconf;
258
259 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
260                       /usr/local/etc/apache/httpd.conf
261                       /usr/local/etc/apache/apache.conf
262                       /var/www/conf/httpd.conf
263                       /etc/apache/conf/httpd.conf
264                       /etc/apache/conf/apache.conf
265                       /etc/httpd/conf/httpd.conf
266                       /etc/httpd/httpd.conf)) {
267    if ( -f $httpdconf ) {
268             $realhttpdconf=$httpdconf;
269             open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to open $httpdconf for reading.\n";
270       while (<HTTPDCONF>) {
271          if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
272             $httpduser = $1;
273          }
274       }
275       close(HTTPDCONF);
276    }
277 }
278 $httpduser ||= 'Undetermined';
279
280 #
281 # Set ownership of the koha.conf file for security
282 #
283 chown((getpwnam($httpduser)) [2,3], "$etcdir/koha.conf") or warn "can't chown koha.conf: $!";
284 chmod 0440, "$etcdir/koha.conf";
285
286 #
287 #SETUP opac
288 #
289 my $svr_admin = "webmaster\@$domainname";
290 my $servername=`hostname -f`;
291 chomp $servername;
292 my $opacport=80;
293 my $kohaport=8080;
294
295 print qq|
296
297 OPAC and KOHA/LIBRARIAN CONFIGURATION
298 =====================================
299 Koha needs to setup your Apache configuration file for the
300 OPAC and LIBRARIAN virtual hosts.  By default this installer
301 will do this by using one ip address and two different ports
302 for the virtual hosts.  There are other ways to set this up,
303 and the installer will leave comments in httpd.conf detailing
304 what these other options are.
305
306 Please enter the e-mail address for your webserver admin.
307 Usually $svr_admin
308 |;
309
310 print "Enter e-mail address [$svr_admin]:";
311 chomp($input = <STDIN>);
312
313 if ($input) {
314   $svr_admin = $input;
315 }
316
317
318 print qq|
319
320
321 Please enter the domain name or ip address of your computer.
322 |;
323 print "Enter server name/ip address [$servername]:";
324 chomp($input = <STDIN>);
325
326 if ($input) {
327   $servername = $input;
328 }
329
330 print qq|
331
332 Please enter the port for your OPAC interface.
333 |;
334 print "Enter OPAC port [$opacport]:";
335 chomp($input = <STDIN>);
336
337 if ($input) {
338   $opacport = $input;
339 }
340
341 print qq|
342
343 Please enter the port for your Intranet/Librarian interface.
344 |;
345 print "Enter intranet port [$kohaport]:";
346 chomp($input = <STDIN>);
347
348 if ($input) {
349   $kohaport = $input;
350 }
351
352
353 #
354 # Update Apache Conf File.
355 #
356 #
357
358 my $logfiledir=`grep ^ErrorLog $realhttpdconf`;
359 chomp $logfiledir;
360
361 if ($logfiledir) {
362     $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
363     $logfiledir=$1;
364 }
365
366 unless ($logfiledir) {
367     $logfiledir='logs';
368 }
369 print qq|
370
371 UPDATING APACHE.CONF
372 ====================
373
374 |;
375
376
377 print "Checking for modules that need to be loaded...\n";
378 my $httpdconf='';
379 my $envmodule=0;
380 my $includesmodule=0;
381 open HC, $realhttpdconf;
382 while (<HC>) {
383     if (/^\s*#\s*LoadModule env_module /) {
384         s/^\s*#\s*//;
385         print "  Loading env_module in httpd.conf\n";
386         $envmodule=1;
387     }
388     if (/^\s*#\s*LoadModule includes_module /) {
389         s/^\s*#\s*//;
390         print "  Loading includes_module in httpd.conf\n";
391     }
392     if (/\s*LoadModule includes_module / ) {
393         $includesmodule=1;
394     }
395     $httpdconf.=$_;
396 }
397
398 my $apachebackupmade=0;
399 if ($envmodule || $includesmodule) {
400     system("mv -f $realhttpdconf $realhttpdconf\.prekoha");
401     $apachebackupmade=1;
402     open HC, ">$realhttpdconf";
403     print HC $httpdconf;
404     close HC;
405 }
406
407
408 if (`grep 'VirtualHost $servername' $realhttpdconf`) {
409     print qq|
410 $realhttpdconf appears to already have an entry for Koha
411 Virtual Hosts.  You may need to edit $realhttpdconf
412 if anything has changed since it was last set up.  This
413 script will not attempt to modify an existing Koha apache
414 configuration.
415
416 |;
417     print "Press <ENTER> to continue...";
418     <STDIN>;
419     print "\n";
420 } else {
421     unless ($apachebackupmade) {
422         system("cp -f $realhttpdconf $realhttpdconf\.prekoha");
423     }
424     my $includesdirectives='';
425     if ($includesmodule) {
426         $includesdirectives.="Options +Includes\n";
427         $includesdirectives.="AddHandler server-parsed .html\n";
428     }
429     open(SITE,">>$realhttpdconf") or warn "Insufficient priveleges to open $realhttpdconf for writing.\n";
430     print SITE <<EOP
431
432
433 # Ports to listen to for Koha
434 Listen $opacport
435 Listen $kohaport
436
437 # NameVirtualHost is used by one of the optional configurations detailed below
438
439 #NameVirtualHost 11.22.33.44
440
441 # KOHA's OPAC Configuration
442 <VirtualHost $servername\:$opacport>
443    ServerAdmin $svr_admin
444    DocumentRoot $opacdir/htdocs
445    ServerName $servername
446    ScriptAlias /cgi-bin/koha/ $opacdir/cgi-bin/
447    ErrorLog $logfiledir/opac-error_log
448    TransferLog $logfiledir/opac-access_log
449    SetEnv PERL5LIB "$kohadir/modules"
450    $includesdirectives
451 </VirtualHost>
452
453 # KOHA's INTRANET Configuration
454 <VirtualHost $servername\:$kohaport>
455    ServerAdmin $svr_admin
456    DocumentRoot $kohadir/htdocs
457    ServerName $servername
458    ScriptAlias /cgi-bin/koha/ "$kohadir/cgi-bin/"
459    ErrorLog $logfiledir/koha-error_log
460    TransferLog $logfiledir/koha-access_log
461    SetEnv PERL5LIB "$kohadir/modules"
462    $includesdirectives
463 </VirtualHost>
464
465 # If you want to use name based Virtual Hosting:
466 #   1. remove the two Listen lines
467 #   2. replace $servername\:$opacport wih your.opac.domain.name
468 #   3. replace ServerName $servername wih ServerName your.opac.domain.name
469 #   4. replace $servername\:$kohaport wih your intranet domain name
470 #   5. replace ServerName $servername wih ServerName your.intranet.domain.name
471 #
472 # If you want to use NameVirtualHost'ing (using two names on one ip address):
473 #   1.  Follow steps 1-5 above
474 #   2.  Uncomment the NameVirtualHost line and set the correct ip address
475
476 EOP
477 ;
478     close(SITE);
479     print "Successfully updated Apache Configuration file.\n";
480 }
481
482 #
483 # Setup the modules directory
484 #
485 print qq|
486
487 CREATING REQUIRED DIRECTORIES
488 =============================
489
490 |;
491
492
493 unless ( -d $kohadir ) {
494    print "Creating $kohadir...\n";
495    my $result=mkdir ($kohadir, oct(770));
496    if ($result==0) {
497        my @dirs = split(m#/#, $kohadir);
498         my $checkdir='';
499         foreach (@dirs) {
500             $checkdir.="$_/";
501             unless (-e "$checkdir") {
502                 mkdir($checkdir, 0775);
503             }
504         }
505    }
506    chown (oct(0), (getgrnam($httpduser))[2], "$kohadir");
507    chmod (oct(770), "$kohadir");
508 }
509 unless ( -d "$kohadir/htdocs" ) {
510    print "Creating $kohadir/htdocs...\n";
511    mkdir ("$kohadir/htdocs", oct(750));
512 }
513 unless ( -d "$kohadir/cgi-bin" ) {
514    print "Creating $kohadir/cgi-bin...\n";
515    mkdir ("$kohadir/cgi-bin", oct(750));
516 }
517 unless ( -d "$kohadir/modules" ) {
518    print "Creating $kohadir/modules...\n";
519    mkdir ("$kohadir/modules", oct(750));
520 }
521 unless ( -d "$kohadir/scripts" ) {
522    print "Creating $kohadir/scripts...\n";
523    mkdir ("$kohadir/scripts", oct(750));
524 }
525 unless ( -d $opacdir ) {
526    print "Creating $opacdir...\n";
527    my $result=mkdir ($opacdir, oct(770));
528    if ($result==0) {
529        my @dirs = split(m#/#, $opacdir);
530         my $checkdir='';
531         foreach (@dirs) {
532             $checkdir.="$_/";
533             unless (-e "$checkdir") {
534                 mkdir($checkdir, 0775);
535             }
536         }
537    }
538    chown (oct(0), (getgrnam($httpduser))[2], "$opacdir");
539    chmod (oct(770), "$opacdir");
540 }
541 unless ( -d "$opacdir/htdocs" ) {
542    print "Creating $opacdir/htdocs...\n";
543    mkdir ("$opacdir/htdocs", oct(750));
544 }
545 unless ( -d "$opacdir/cgi-bin" ) {
546    print "Creating $opacdir/cgi-bin...\n";
547    mkdir ("$opacdir/cgi-bin", oct(750));
548 }
549
550
551
552 print "\n\nINSTALLING KOHA...\n";
553 print "\n\n==================\n";
554 print "Copying internet-html files to $kohadir/htdocs...\n";
555 system("cp -R intranet-html/* $kohadir/htdocs/");
556 print "Copying intranet-cgi files to $kohadir/cgi-bin...\n";
557 system("cp -R intranet-cgi/* $kohadir/cgi-bin/");
558 print "Copying script files to $kohadir/scripts...\n";
559 system("cp -R scripts/* $kohadir/scripts/");
560 print "Copying module files to $kohadir/modules...\n";
561 system("cp -R modules/* $kohadir/modules/");
562 print "Copying opac-html files to $opacdir/htdocs...\n";
563 system("cp -R opac-html/* $opacdir/htdocs/");
564 print "Copying opac-cgi files to $opacdir/cgi-bin...\n";
565 system("cp -R opac-cgi/* $opacdir/cgi-bin/");
566
567 system("chown -R root.$httpduser $opacdir");
568 system("chown -R root.$httpduser $kohadir");
569
570 print qq|
571
572 MYSQL CONFIGURATION
573 ===================
574 |;
575 my $mysql;
576 my $mysqldir;
577 my $mysqluser = 'root';
578 my $mysqlpass = '';
579
580 foreach my $mysql (qw(/usr/local/mysql
581                       /opt/mysql
582                       )) {
583    if ( -d $mysql ) {
584             $mysqldir=$mysql;
585    }
586 }
587 if (!$mysqldir){
588     $mysqldir='/usr';
589 }
590 print qq|
591 To allow us to create the koha database please supply the 
592 mysql\'s root users password
593 |;
594
595 print "Enter mysql\'s root users password: ";
596 chomp($input = <STDIN>);
597
598 if ($input) {
599   $mysqlpass = $input;
600 }
601
602
603 print qq|
604
605 CREATING DATABASE
606 =================
607 |;
608 my $result=system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass create $dbname");
609 if ($result) {
610     print "\nCouldn't connect to the MySQL server for the reason given above.\n";
611     print "This is a serious problem, the database will not get installed.\a\n";
612     print "Press <ENTER> to continue...";
613     <STDIN>;
614     print "\n";
615 } else {
616     system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname < koha.mysql");
617     system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass mysql -e \"insert into user (Host,User,Password) values ('$hostname','$user',password('$pass'))\"\;");
618     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')\"");
619     system("$mysqldir/bin/mysqladmin -u$mysqluser -p$mysqlpass reload");
620
621     system ("perl -I $kohadir/modules scripts/updater/updatedatabase");
622
623
624     print qq|
625
626 SAMPLE DATA
627 ===========
628 If you are installing Koha for evaluation purposes,  I have a batch of sample
629 data that you can install now.
630
631 If you are installing Koha with the intention of populating it with your own
632 data, you probably don't want this sample data installed.
633 |;
634     print "\nWould you like to install the sample data? Y/[N]: ";
635     chomp($input = <STDIN>);
636     if ($input =~/^y/i) {
637         system("gunzip sampledata-1.2.gz");
638         system("cat sampledata-1.2 | $mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname");
639         system("gzip -9 sampledata-1.2");
640         system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into branches (branchcode,branchname,issuing) values ('Main', 'Main Library', 1)\"");
641         system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
642         print qq|
643
644 Sample data has been installed.  For some suggestions on testing Koha, please
645 read the file doc/HOWTO-Testing.  If you find any bugs, please submit them at
646 http://bugs.koha.org/.  If you need help with testing Koha, you can post a
647 question through the koha-devel mailing list, or you can check for a developer
648 online at +irc.katipo.co.nz:6667 channel #koha.
649
650 You can find instructions for subscribing to the Koha mailing lists at:
651
652     http://www.koha.org
653
654
655 Press <ENTER> to continue...
656 |;
657         <STDIN>;
658     } else {
659         print "\n\nWould you like to add a branch and printer? [Y]/N: ";
660         chomp($input = <STDIN>);
661
662
663         unless ($input =~/^n/i) {
664             my $branch='Main Library';
665             print "Enter a name for the library branch [$branch]: ";
666             chomp($input = <STDIN>);
667             if ($input) {
668                 $branch=$input;
669             }
670             $branch=~s/[^A-Za-z0-9\s]//g;
671             my $branchcode=$branch;
672             $branchcode=~s/[^A-Za-z0-9]//g;
673             $branchcode=uc($branchcode);
674             $branchcode=substr($branchcode,0,4);
675             print "Enter a four letter code for your branch [$branchcode]: ";
676             chomp($input = <STDIN>);
677             if ($input) {
678                 $branchcode=$input;
679             }
680             $branchcode=~s/[^A-Z]//g;
681             $branchcode=uc($branchcode);
682             $branchcode=substr($branchcode,0,4);
683             print "Adding branch '$branch' with code '$branchcode'.\n";
684             system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
685             my $printername='Library Printer';
686             print "Enter a name for the printer [$printername]: ";
687             chomp($input = <STDIN>);
688             if ($input) {
689                 $printername=$input;
690             }
691             $printername=~s/[^A-Za-z0-9\s]//g;
692             my $printerqueue='lp';
693             print "Enter the queue for the printer [$printerqueue]: ";
694             chomp($input = <STDIN>);
695             if ($input) {
696                 $printerqueue=$input;
697             }
698             $printerqueue=~s/[^A-Za-z0-9]//g;
699             system("$mysqldir/bin/mysql -u$mysqluser -p$mysqlpass $dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
700         }
701     }
702
703
704 }
705
706
707 print qq|
708
709 SETTING UP Z39.50 DAEMON
710 ========================
711 |;
712
713 my $kohalogdir='/var/log/koha';
714 print "Directory for logging by Z39.50 daemon [$kohalogdir]: ";
715 chomp($input = <STDIN>);
716 if ($input) {
717     $kohalogdir=$input;
718 }
719
720 unless (-e "$kohalogdir") {
721     my $result = mkdir 0770, "$kohalogdir"; 
722     if ($result==0) {
723         my @dirs = split(m#/#, $kohalogdir);
724         my $checkdir='';
725         foreach (@dirs) {
726             $checkdir.="$_/";
727             unless (-e "$checkdir") {
728                 mkdir($checkdir, 0775);
729             }
730         }
731     }
732 }
733 chmod 0770, $kohalogdir;
734 chown((getpwnam($httpduser)) [2,3], $kohalogdir) or warn "can't chown $kohalogdir: $!";
735
736 # LAUNCH SCRIPT
737 print "Modifying Z39.50 daemon launch script...\n";
738 my $newfile='';
739 open (L, "$kohadir/scripts/z3950daemon/z3950-daemon-launch.sh");
740 while (<L>) {
741     if (/^RunAsUser=/) {
742         $newfile.="RunAsUser=$httpduser\n";
743     } elsif (/^KohaZ3950Dir=/) {
744         $newfile.="KohaZ3950Dir=$kohadir/scripts/z3950daemon\n";
745     } else {
746         $newfile.=$_;
747     }
748 }
749 close L;
750 system("mv $kohadir/scripts/z3950daemon/z3950-daemon-launch.sh $kohadir/scripts/z3950daemon/z3950-daemon-launch.sh.orig");
751 open L, ">$kohadir/scripts/z3950daemon/z3950-daemon-launch.sh";
752 print L $newfile;
753 close L;
754
755
756 # SHELL SCRIPT
757 print "Modifying Z39.50 daemon wrapper script...\n";
758 $newfile='';
759 open (S, "$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh");
760 while (<S>) {
761     if (/^KohaModuleDir=/) {
762         $newfile.="KohaModuleDir=$kohadir/modules\n";
763     } elsif (/^KohaZ3950Dir=/) {
764         $newfile.="KohaZ3950Dir=$kohadir/scripts/z3950daemon\n";
765     } elsif (/^LogDir=/) {
766         $newfile.="LogDir=$kohalogdir\n";
767     } else {
768         $newfile.=$_;
769     }
770 }
771 close S;
772
773 system("mv $kohadir/scripts/z3950daemon/z3950-daemon-shell.sh $kohadir/scripts/z3950daemon/z3950-daemon-shell.sh.orig");
774 open S, ">$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh";
775 print S $newfile;
776 close S;
777 chmod 0750, "$kohadir/scripts/z3950daemon/z3950-daemon-launch.sh";
778 chmod 0750, "$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh";
779 chmod 0750, "$kohadir/scripts/z3950daemon/processz3950queue";
780 chown(0, (getpwnam($httpduser)) [3], "$kohadir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $kohadir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
781 chown(0, (getpwnam($httpduser)) [3], "$kohadir/scripts/z3950daemon/processz3950queue") or warn "can't chown $kohadir/scripts/z3950daemon/processz3950queue: $!";
782
783
784 #RESTART APACHE
785 print "\n\n";
786 print qq|
787
788 COMPLETED
789 =========
790 Congratulations ... your Koha installation is almost complete!
791 The final step is to restart your webserver.
792
793 You will be able to connect to your Librarian interface at:
794
795    http://$servername\:$kohaport/
796
797 and the OPAC interface at :
798
799    http://$servername\:$opacport/
800
801
802 Be sure to read the INSTALL, and Hints files. 
803
804 For more information visit http://www.koha.org
805
806 Would you like to restart your webserver now? (Y/[N]):
807 |;
808
809 my $restart = <STDIN>;
810 chomp $restart;
811
812 if ($restart=~/^y/i) {
813         # Need to support other init structures here?
814         if (-e "/etc/rc.d/init.d/httpd") {
815             system('/etc/rc.d/init.d/httpd restart');
816         } elsif (-e "/etc/init.d/apache") {
817             system('/etc//init.d/apache restart');
818         } elsif (-e "/etc/init.d/apache-ssl") {
819             system('/etc/init.d/apache-ssl restart');
820         }
821     } else {
822         print qq|
823 Congratulations ... your Koha installation is complete!
824 You will need to restart your webserver before using Koha!
825 |;
826     exit;
827 };