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