bugfixes + language selection during install
[koha.git] / misc / Install.pm
1 package Install; #assumes Install.pm
2
3
4 # Copyright 2000-2002 Katipo Communications
5 #
6 # This file is part of Koha.
7 #
8 # Koha is free software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any later
11 # version.
12 #
13 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
14 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
19 # Suite 330, Boston, MA  02111-1307 USA
20
21 use strict;
22 require Exporter;
23
24 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
25
26 # set the version for version checking
27 $VERSION = 0.01;
28
29 @ISA = qw(Exporter);
30 @EXPORT = qw(   &checkperlmodules
31                 &getmessage
32                 &showmessage
33                 &releasecandidatewarning
34                 &getinstallationdirectories
35                 &getdatabaseinfo
36                 &getapacheinfo
37                 &getapachevhostinfo
38                 &updateapacheconf
39                 &basicauthentication
40                 &installfiles
41                 &databasesetup
42                 &updatedatabase
43                 &populatedatabase
44                 &restartapache
45                 &loadconfigfile
46                 );
47
48
49 my $messages;
50 $messages->{'continuing'}->{en}="Great!  Continuing setup.\n\n";
51 $messages->{'WelcomeToKohaInstaller'}->{en}=qq|
52 =================================
53 = Welcome to the Koha Installer =
54 =================================
55
56 Welcome to the Koha install script!  This script will prompt you for some
57 basic information about your desired setup, then install Koha according to
58 your specifications.  To accept the default value for any question, simply hit
59 Enter at the prompt.
60
61 Please be sure to read the documentation, or visit the Koha website at
62 http://www.koha.org for more information.
63
64 Are you ready to begin the installation? (Y/[N]): |;
65 $messages->{'ReleaseCandidateWarning'}->{en}=qq|
66 =====================
67 = RELEASE CANDIDATE =
68 =====================
69
70 WARNING WARNING WARNING WARNING WARNING
71
72 You are about to install Koha version %s.  This version of Koha is a
73 release candidate.  It is not intended to be installed on production systems.
74 It is being released so that users can test it before we release a final
75 version.
76
77 Are you sure you want to install Koha %s? (Y/[N]): |;
78 $messages->{'WatchForReleaseAnnouncements'}->{en}=qq|
79
80 Watch for announcements of Koha releases on the Koha mailing list or the Koha
81 web site (http://www.koha.org/).
82
83 |;
84
85 $messages->{'NETZ3950Missing'}->{en}=qq|
86
87 The Net::Z3950 module is missing.  This module is necessary if you want to use
88 Koha's Z39.50 client to download bibliographic records from other libraries.
89 To install this module, you will need the yaz client installed from
90 http://www.indexdata.dk/yaz/ and then you can install the perl module with the
91 command:
92
93 perl -MCPAN -e 'install Net::Z3950'
94
95 Press the <ENTER> key to continue: |;
96
97 $messages->{'CheckingPerlModules'}->{en}=qq|
98
99 ==================
100 = PERL & MODULES =
101 ==================
102
103 Checking perl modules ...
104 |;
105
106 $messages->{'PerlVersionFailure'}->{en}="Sorry, you need at least Perl %s\n";
107
108 $messages->{'MissingPerlModules'}->{en}=qq|
109
110 ========================
111 = MISSING PERL MODULES =
112 ========================
113
114 You are missing some Perl modules which are required by Koha.
115 Once these modules have been installed, rerun this installer.
116 They can be installed by running (as root) the following:
117
118 %s
119 |;
120
121 $messages->{'AllPerlModulesInstalled'}->{en}=qq|
122
123 ==============================
124 = ALL PERL MODULES INSTALLED =
125 ==============================
126
127 All mandatory perl modules are installed.
128
129 Press <ENTER> to continue: |;
130 $messages->{'KohaVersionInstalled'}->{en}="You currently have Koha %s on your system.";
131 $messages->{'KohaUnknownVersionInstalled'}->{en}="I am not able to determine what version of Koha is installed now.";
132 $messages->{'KohaAlreadyInstalled'}->{en}=qq|
133 ==========================
134 = Koha already installed =
135 ==========================
136
137 It looks like Koha is already installed on your system (/etc/koha.conf exists
138 already).  If you would like to upgrade your system to %s, please use
139 the koha.upgrade script in this directory.
140
141 %s
142
143 |;
144 $messages->{'GetOpacDir'}->{en}=qq|
145 ==================
146 = OPAC DIRECTORY =
147 ==================
148
149 Please supply the directory you want Koha to store its OPAC files in.  This
150 directory will be auto-created for you if it doesn't exist.
151
152 OPAC Directory [%s]: |;
153
154 $messages->{'GetIntranetDir'}->{en}=qq|
155 =================================
156 = INTRANET/LIBRARIANS DIRECTORY =
157 =================================
158
159 Please supply the directory you want Koha to store its Intranet/Librarians
160 files in.  This directory will be auto-created for you if it doesn't exist.
161
162 Intranet Directory [%s]: |;
163
164 $messages->{'GetKohaLogDir'}->{en}=qq|
165 ======================
166 = KOHA LOG DIRECTORY =
167 ======================
168
169 Specify a log directory where any Koha daemons can create log files.
170
171 Koha Log Directory [%s]: |;
172
173 $messages->{'AuthenticationWarning'}->{en}=qq|
174 ==================
175 = Authentication =
176 ==================
177
178 This release of Koha has a new authentication module.  If you are not already
179 using basic authentication on your intranet, you will be required to log in to
180 access some of the features of the intranet.  You can log in using the userid
181 and password from the /etc/koha.conf configuration file at any time.  Use the
182 "Members" module to add passwords for other accounts and set their permissions.
183
184 Press the <ENTER> key to continue: |;
185
186 $messages->{'Completed'}->{en}=qq|
187 ==============================
188 = KOHA INSTALLATION COMPLETE =
189 ==============================
190
191 Congratulations ... your Koha installation is complete!
192
193 You will be able to connect to your Librarian interface at:
194
195    http://%s\:%s/
196
197 and the OPAC interface at :
198
199    http://%s\:%s/
200
201 Be sure to read the INSTALL, and Hints files.
202
203 For more information visit http://www.koha.org
204
205 Press <ENTER> to exit the installer: |;
206
207 sub releasecandidatewarning {
208     my $message=getmessage('ReleaseCandidateWarning', [$::newversion, $::newversion]);
209     my $answer=showmessage($message, 'yn', 'n');
210
211     if ($answer =~ /y/i) {
212         print getmessage('continuing');
213     } else {
214         my $message=getmessage('WatchForReleaseAnnouncements');
215         print $message;
216         exit;
217     };
218 }
219
220
221 #
222 # Test for Perl and Modules
223 #
224 #
225 sub checkperlmodules {
226     my $message = getmessage('CheckingPerlModules');
227     showmessage($message, 'none');
228
229     unless (eval "require 5.006_000") {
230         die getmessage('PerlVersionFailure', ['5.6.0']);
231     }
232
233     my @missing = ();
234     unless (eval {require DBI})               { push @missing,"DBI" };
235     unless (eval {require Date::Manip})       { push @missing,"Date::Manip" };
236     unless (eval {require DBD::mysql})        { push @missing,"DBD::mysql" };
237     unless (eval {require HTML::Template})          { push @missing,"HTML::Template" };
238     unless (eval {require Set::Scalar})       { push @missing,"Set::Scalar" };
239     unless (eval {require Digest::MD5})       { push @missing,"Digest::MD5" };
240     unless (eval {require MARC::Record})       { push @missing,"MARC::Record" };
241     unless (eval {require Net::Z3950})        {
242         my $message = getmessage('NETZ3950Missing');
243         showmessage($message, 'PressEnter', '', 1);
244         if ($#missing>=0) {
245             push @missing, "Net::Z3950";
246         }
247     }
248
249 #
250 # Print out a list of any missing modules
251 #
252
253     if (@missing > 0) {
254         my $missing='';
255         foreach my $module (@missing) {
256             $missing.="   perl -MCPAN -e 'install \"$module\"'\n";
257         }
258         my $message=getmessage('MissingPerlModules', [$missing]);
259         showmessage($message, 'none');
260         exit;
261     } else {
262         showmessage(getmessage('AllPerlModulesInstalled'), 'PressEnter', '', 1);
263     }
264
265
266     unless (-x "/usr/bin/perl") {
267         my $realperl=`which perl`;
268         chomp $realperl;
269         $realperl = showmessage(getmessage('NoUsrBinPerl'), 'none');
270         until (-x $realperl) {
271             $realperl=showmessage(getmessage('AskLocationOfPerlExecutable', $realperl), 'free', $realperl, 1);
272         }
273         my $response=showmessage(getmessage('ConfirmPerlExecutableSymlink', $realperl), 'yn', 'y', 1);
274         unless ($response eq 'n') {
275             system("ln -s $realperl /usr/bin/perl");
276         }
277     }
278
279
280 }
281
282 $messages->{'NoUsrBinPerl'}->{en}=qq|
283
284 ========================================
285 = Perl is not located in /usr/bin/perl =
286 ========================================
287
288 The Koha perl scripts expect to find the perl executable in the /usr/bin
289 directory.  It is not there on your system.
290
291 |;
292
293 $messages->{'AskLocationOfPerlExecutable'}->{en}=qq|Location of Perl Executable: [%s]: |;
294 $messages->{'ConfirmPerlExecutableSymlink'}->{en}=qq|
295 The Koha scripts will _not_ work without a symlink from %s to /usr/bin/perl
296
297 May I create this symlink? ([Y]/N):
298 : |;
299
300 sub getmessage {
301     my $messagename=shift;
302     my $variables=shift;
303     my $message=$messages->{$messagename}->{$::language} || $messages->{$messagename}->{en} || "Error: No message named $messagename in Install.pm\n";
304     if (defined($variables)) {
305         $message=sprintf $message, @$variables;
306     }
307     return $message;
308 }
309
310
311 sub showmessage {
312     my $message=shift;
313     my $responsetype=shift;
314     my $defaultresponse=shift;
315     my $noclear=shift;
316     ($noclear) || (system('clear'));
317     if ($responsetype =~ /^yn$/) {
318         $responsetype='restrictchar yn';
319     }
320     print $message;
321     SWITCH: {
322         if ($responsetype =~/^restrictchar (.*)/i) {
323             my $response='\0';
324             my $options=$1;
325             until ($options=~/$response/) {
326                 ($defaultresponse) || ($defaultresponse=substr($options,0,1));
327                 $response=<STDIN>;
328                 chomp $response;
329                 (length($response)) || ($response=$defaultresponse);
330                 unless ($options=~/$response/) {
331                     ($noclear) || (system('clear'));
332                     print "Invalid Response.  Choose from [$options].\n\n";
333                     print $message;
334                 }
335             }
336             return $response;
337         }
338         if ($responsetype =~/^free$/i) {
339             (defined($defaultresponse)) || ($defaultresponse='');
340             my $response=<STDIN>;
341             chomp $response;
342             ($response) || ($response=$defaultresponse);
343             return $response;
344         }
345         if ($responsetype =~/^numerical$/i) {
346             (defined($defaultresponse)) || ($defaultresponse='');
347             my $response='';
348             until ($response=~/^\d+$/) {
349                 $response=<STDIN>;
350                 chomp $response;
351                 ($response) || ($response=$defaultresponse);
352                 unless ($response=~/^\d+$/) {
353                     ($noclear) || (system('clear'));
354                     print "Invalid Response ($response).  Response must be a number.\n\n";
355                     print $message;
356                 }
357             }
358             return $response;
359         }
360         if ($responsetype =~/^email$/i) {
361             (defined($defaultresponse)) || ($defaultresponse='');
362             my $response='';
363             until ($response=~/.*\@.*\..*/) {
364                 $response=<STDIN>;
365                 chomp $response;
366                 ($response) || ($response=$defaultresponse);
367                 unless ($response=~/.*\@.*\..*/) {
368                     ($noclear) || (system('clear'));
369                     print "Invalid Response ($response).  Response must be a valid email address.\n\n";
370                     print $message;
371                 }
372             }
373             return $response;
374         }
375         if ($responsetype =~/^PressEnter$/i) {
376             <STDIN>;
377             return;
378         }
379         if ($responsetype =~/^none$/i) {
380             return;
381         }
382     }
383 }
384
385 sub getinstallationdirectories {
386     $::opacdir = '/usr/local/koha/opac';
387     $::intranetdir = '/usr/local/koha/intranet';
388     my $getdirinfo=1;
389     while ($getdirinfo) {
390         # Loop until opac directory and koha directory are different
391         my $message=getmessage('GetOpacDir', [$::opacdir]);
392         $::opacdir=showmessage($message, 'free', $::opacdir);
393
394         $message=getmessage('GetIntranetDir', [$::intranetdir]);
395         $::intranetdir=showmessage($message, 'free', $::intranetdir);
396
397         if ($::intranetdir eq $::opacdir) {
398             print qq|
399
400 You must specify different directories for the OPAC and INTRANET files!
401  :: $::intranetdir :: $::opacdir ::
402 |;
403 <STDIN>
404         } else {
405             $getdirinfo=0;
406         }
407     }
408     $::kohalogdir='/var/log/koha';
409     my $message=getmessage('GetKohaLogDir', [$::kohalogdir]);
410     $::kohalogdir=showmessage($message, 'free', $::kohalogdir);
411
412
413     unless ( -d $::intranetdir ) {
414        my $result=mkdir ($::intranetdir, oct(770));
415        if ($result==0) {
416            my @dirs = split(m#/#, $::intranetdir);
417             my $checkdir='';
418             foreach (@dirs) {
419                 $checkdir.="$_/";
420                 unless (-e "$checkdir") {
421                     mkdir($checkdir, 0775);
422                 }
423             }
424        }
425        chown (oct(0), (getgrnam($::httpduser))[2], "$::intranetdir");
426        chmod (oct(770), "$::intranetdir");
427     }
428     unless ( -d "$::intranetdir/htdocs" ) {
429        mkdir ("$::intranetdir/htdocs", oct(750));
430     }
431     unless ( -d "$::intranetdir/cgi-bin" ) {
432        mkdir ("$::intranetdir/cgi-bin", oct(750));
433     }
434     unless ( -d "$::intranetdir/modules" ) {
435        mkdir ("$::intranetdir/modules", oct(750));
436     }
437     unless ( -d "$::intranetdir/scripts" ) {
438        mkdir ("$::intranetdir/scripts", oct(750));
439     }
440     unless ( -d $::opacdir ) {
441        my $result=mkdir ($::opacdir, oct(770));
442        if ($result==0) {
443            my @dirs = split(m#/#, $::opacdir);
444             my $checkdir='';
445             foreach (@dirs) {
446                 $checkdir.="$_/";
447                 unless (-e "$checkdir") {
448                     mkdir($checkdir, 0775);
449                 }
450             }
451        }
452        chown (oct(0), (getgrnam($::httpduser))[2], "$::opacdir");
453        chmod (oct(770), "$::opacdir");
454     }
455     unless ( -d "$::opacdir/htdocs" ) {
456        mkdir ("$::opacdir/htdocs", oct(750));
457     }
458     unless ( -d "$::opacdir/cgi-bin" ) {
459        mkdir ("$::opacdir/cgi-bin", oct(750));
460     }
461
462
463     unless ( -d $::kohalogdir ) {
464        my $result=mkdir ($::kohalogdir, oct(770));
465        if ($result==0) {
466            my @dirs = split(m#/#, $::kohalogdir);
467             my $checkdir='';
468             foreach (@dirs) {
469                 $checkdir.="$_/";
470                 unless (-e "$checkdir") {
471                     mkdir($checkdir, 0775);
472                 }
473             }
474        }
475
476        chown (oct(0), (getgrnam($::httpduser))[2,3], "$::kohalogdir");
477        chmod (oct(770), "$::kohalogdir");
478     }
479 }
480
481
482
483 $messages->{'DatabaseName'}->{en}=qq|
484 ==========================
485 = Name of MySQL database =
486 ==========================
487
488 Please provide the name of the mysql database for your koha installation.
489
490 Database name [%s]: |;
491
492 $messages->{'DatabaseHost'}->{en}=qq|
493 =================
494 = Database Host =
495 =================
496
497 Please provide the hostname for mysql.  Unless the database is located on
498 another machine this will be "localhost".
499
500 Database host [%s]: |;
501
502 $messages->{'DatabaseUser'}->{en}=qq|
503 =================
504 = Database User =
505 =================
506
507 Please provide the name of the user, who will have full administrative rights
508 to the %s database, when authenticating from %s.
509
510 Database user [%s]: |;
511
512 $messages->{'DatabasePassword'}->{en}=qq|
513 =====================
514 = Database Password =
515 =====================
516
517 Please provide a good password for the user %s.
518
519 Database Password: |;
520
521 $messages->{'BlankPassword'}->{en}=qq|
522 ==================
523 = BLANK PASSWORD =
524 ==================
525
526 You must not use a blank password for your MySQL user!
527
528 Press <ENTER> to try again: 
529 |;
530
531 sub getdatabaseinfo {
532
533     $::dbname = 'Koha';
534     $::hostname = 'localhost';
535     $::user = 'kohaadmin';
536     $::pass = '';
537
538 #Get the database name
539
540     my $message=getmessage('DatabaseName', [$::dbname]);
541     $::dbname=showmessage($message, 'free', $::dbname);
542
543 #Get the hostname for the database
544     
545     $message=getmessage('DatabaseHost', [$::hostname]);
546     $::hostname=showmessage($message, 'free', $::hostname);
547
548 #Get the username for the database
549
550     $message=getmessage('DatabaseUser', [$::dbname, $::hostname, $::user]);
551     $::user=showmessage($message, 'free', $::user);
552
553 #Get the password for the database user
554
555     while ($::pass eq '') {
556         my $message=getmessage('DatabasePassword', [$::user]);
557         $::pass=showmessage($message, 'free', $::pass);
558         if ($::pass eq '') {
559             my $message=getmessage('BlankPassword');
560             showmessage($message,'PressEnter');
561         }
562     }
563 }
564
565
566
567 $messages->{'FoundMultipleApacheConfFiles'}->{en}=qq|
568 ================================
569 = MULTIPLE APACHE CONFIG FILES =
570 ================================
571
572 I found more than one possible Apache configuration file:
573
574 %s
575
576 Choose the correct file [1]: |;
577
578 $messages->{'NoApacheConfFiles'}->{en}=qq|
579 ===============================
580 = NO APACHE CONFIG FILE FOUND =
581 ===============================
582
583 I was not able to find your Apache configuration file.
584
585 The file is usually called httpd.conf or apache.conf.
586
587 Please specify the location of your config file: |;
588
589 $messages->{'NotAFile'}->{en}=qq|
590 =======================
591 = FILE DOES NOT EXIST =
592 =======================
593
594 The file %s does not exist.
595
596 Please press <ENTER> to continue: |;
597
598 $messages->{'EnterApacheUser'}->{en}=qq|
599 ====================
600 = NEED APACHE USER =
601 ====================
602
603 I was not able to determine the user that Apache is running as.  This
604 information is necessary in order to set the access privileges correctly on
605 /etc/koha.conf.  This user should be set in one of the Apache configuration
606 files using the "User" directive.
607
608 Enter the Apache userid: |;
609
610 $messages->{'InvalidUserid'}->{en}=qq|
611 ==================
612 = INVALID USERID =
613 ==================
614
615 The userid %s is not a valid userid on this system.
616
617 Press <ENTER> to continue: |;
618
619 sub getapacheinfo {
620     my @confpossibilities;
621
622     foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
623                           /usr/local/etc/apache/httpd.conf
624                           /usr/local/etc/apache/apache.conf
625                           /var/www/conf/httpd.conf
626                           /etc/apache/conf/httpd.conf
627                           /etc/apache/conf/apache.conf
628                           /etc/apache-ssl/conf/apache.conf
629                           /etc/apache-ssl/httpd.conf
630                           /etc/httpd/conf/httpd.conf
631                           /etc/httpd/httpd.conf)) {
632         if ( -f $httpdconf ) {
633             push @confpossibilities, $httpdconf;
634         }
635     }
636
637     if ($#confpossibilities==-1) {
638         my $message=getmessage('NoApacheConfFiles');
639         my $choice='';
640         until (-f $choice) {
641             $choice=showmessage($message, "free", 1);
642             if (-f $choice) {
643                 $::realhttpdconf=$choice;
644             } else {
645                 showmessage(getmessage('NotAFile', [$choice]),'PressEnter', '', 1);
646             }
647         }
648     } elsif ($#confpossibilities>0) {
649         my $conffiles='';
650         my $counter=1;
651         my $options='';
652         foreach (@confpossibilities) {
653             $conffiles.="   $counter: $_\n";
654             $options.="$counter";
655             $counter++;
656         }
657         my $message=getmessage('FoundMultipleApacheConfFiles', [$conffiles]);
658         my $choice=showmessage($message, "restrictchar $options", 1);
659         $::realhttpdconf=$confpossibilities[$choice-1];
660     } else {
661         $::realhttpdconf=$confpossibilities[0];
662     }
663     unless (open (HTTPDCONF, $::realhttpdconf)) {
664         warn "Insufficient privileges to open $::realhttpdconf for reading.\n";
665         sleep 4;
666     }
667
668     while (<HTTPDCONF>) {
669         if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
670             $::httpduser = $1;
671         }
672     }
673     close(HTTPDCONF);
674
675
676
677
678     unless ($::httpduser) {
679         my $message=getmessage('EnterApacheUser');
680         until (length($::httpduser) && getpwnam($::httpduser)) {
681             $::httpduser=showmessage($message, "free", '');
682             if (length($::httpduser)>0) {
683                 unless (getpwnam($::httpduser)) {
684                     my $message=getmessage('InvalidUserid', [$::httpduser]);
685                     showmessage($message,'PressEnter');
686                 }
687             } else {
688             }
689         }
690         print "AU: $::httpduser\n";
691     }
692 }
693
694
695 $messages->{'ApacheConfigIntroduction'}->{en}=qq|
696 ========================
697 = APACHE CONFIGURATION =
698 ========================
699
700 Koha needs to setup your Apache configuration file for the
701 OPAC and LIBRARIAN virtual hosts.  By default this installer
702 will do this by using one ip address and two different ports
703 for the virtual hosts.  There are other ways to set this up,
704 and the installer will leave comments in httpd.conf detailing
705 what these other options are.
706
707
708 Press <ENTER> to continue: |;
709
710 $messages->{'GetVirtualHostEmail'}->{en}=qq|
711 =============================
712 = WEB SERVER E-MAIL CONTACT =
713 =============================
714
715 Enter the e-mail address to be used as a contact for the virtual hosts (this
716 address is displayed if any errors are encountered).
717
718 E-mail contact [%s]: |;
719
720 $messages->{'GetServerName'}->{en}=qq|
721 ======================================
722 = WEB SERVER HOST NAME OR IP ADDRESS =
723 ======================================
724
725 Please enter the domain name or ip address of your computer.
726
727 Host name or IP Address [%s]: |;
728
729 $messages->{'GetOpacPort'}->{en}=qq|
730 ==========================
731 = OPAC VIRTUAL HOST PORT =
732 ==========================
733
734 Please enter the port for your OPAC interface.  This defaults to port 80, but
735 if you are already serving web content from this server, you should change it
736 to a different port (8000 might be a good choice).
737
738 Enter the OPAC Port [%s]: |;
739
740 $messages->{'GetIntranetPort'}->{en}=qq|
741 ==============================
742 = INTRANET VIRTUAL HOST PORT =
743 ==============================
744
745 Please enter the port for your Intranet interface.  This must be different from
746 the OPAC port (%s).
747
748 Enter the Intranet Port [%s]: |;
749
750
751 sub getapachevhostinfo {
752
753     $::svr_admin = "webmaster\@$::domainname";
754     $::servername=`hostname -f`;
755     chomp $::servername;
756     $::opacport=80;
757     $::intranetport=8080;
758
759     showmessage(getmessage('ApacheConfigIntroduction'), 'PressEnter');
760
761     $::svr_admin=showmessage(getmessage('GetVirtualHostEmail', [$::svr_admin]), 'email', $::svr_admin);
762     $::servername=showmessage(getmessage('GetServerName', [$::servername]), 'free', $::servername);
763
764
765     $::opacport=showmessage(getmessage('GetOpacPort', [$::opacport]), 'numerical', $::opacport);
766     $::intranetport=showmessage(getmessage('GetIntranetPort', [$::opacport, $::intranetport]), 'numerical', $::intranetport);
767
768 }
769
770 $messages->{'StartUpdateApache'}->{en}=qq|
771 =================================
772 = UPDATING APACHE CONFIGURATION =
773 =================================
774
775 Checking for modules that need to be loaded...
776 |;
777
778 $messages->{'LoadingApacheModuleModEnv'}->{en}="Loading SetEnv Apache module.\n";
779
780 $messages->{'LoadingApacheModuleModInc'}->{en}="Loading Includes Apache module.\n";
781
782 $messages->{'ApacheConfigBackupFailed'}->{en}=qq|
783 ======================================
784 = APACHE CONFIGURATION BACKUP FAILED =
785 ======================================
786
787 An error occurred while trying to make a backup copy of %s.
788
789   %s
790
791 No changes will be made to the apache configuration file at this time.
792
793 Press <ENTER> to continue: |;
794
795
796 $messages->{'ApacheAlreadyConfigured'}->{en}=qq|
797 =============================
798 = APACHE ALREADY CONFIGURED =
799 =============================
800
801 %s appears to already have an entry for Koha
802 Virtual Hosts.  You may need to edit %s
803 f anything has changed since it was last set up.  This
804 script will not attempt to modify an existing Koha apache
805 configuration.
806
807 Press <ENTER> to continue: |;
808
809 sub updateapacheconf {
810     my $logfiledir=`grep ^ErrorLog $::realhttpdconf`;
811     chomp $logfiledir;
812
813     if ($logfiledir) {
814         $logfiledir=~m#ErrorLog (.*)/[^/]*$#;
815         $logfiledir=$1;
816     }
817
818     unless ($logfiledir) {
819         $logfiledir='logs';
820     }
821
822     showmessage(getmessage('StartUpdateApache'), 'none');
823
824     my $httpdconf;
825     my $envmodule=0;
826     my $includesmodule=0;
827     open HC, $::realhttpdconf;
828     while (<HC>) {
829         if (/^\s*#\s*LoadModule env_module /) {
830             s/^\s*#\s*//;
831             showmessage(getmessage('LoadingApacheModuleModEnv'));
832             $envmodule=1;
833         }
834         if (/^\s*#\s*LoadModule includes_module /) {
835             s/^\s*#\s*//;
836             showmessage(getmessage('LoadingApacheModuleModInc'));
837         }
838         if (/\s*LoadModule includes_module / ) {
839             $includesmodule=1;
840         }
841         $httpdconf.=$_;
842     }
843
844     my $backupfailed=0;
845     $backupfailed=`cp -f $::realhttpdconf $::realhttpdconf\.prekoha`;
846     if ($backupfailed) {
847         showmessage(getmessage('ApacheConfigBackupFailed', [$::realhttpdconf,$backupfailed ]), 'PressEnter');
848         return;
849     }
850
851     if ($envmodule || $includesmodule) {
852         open HC, ">$::realhttpdconf";
853         print HC $httpdconf;
854         close HC;
855     }
856
857
858     
859     if (`grep 'VirtualHost $::servername' $::realhttpdconf`) {
860         showmessage(getmessage('ApacheAlreadyConfigured', [$::realhttpdconf, $::realhttpdconf]), 'PressEnter');
861         return;
862     } else {
863         my $includesdirectives='';
864         if ($includesmodule) {
865             $includesdirectives.="Options +Includes\n";
866             $includesdirectives.="   AddHandler server-parsed .html\n";
867         }
868         open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
869         my $opaclisten = '';
870         if ($::opacport != 80) {
871             $opaclisten="Listen $::opacport";
872         }
873         my $intranetlisten = '';
874         if ($::intranetport != 80) {
875             $intranetlisten="Listen $::intranetport";
876         }
877         print SITE <<EOP
878
879 # Ports to listen to for Koha
880 $opaclisten
881 $intranetlisten
882
883 # NameVirtualHost is used by one of the optional configurations detailed below
884
885 #NameVirtualHost 11.22.33.44
886
887 # KOHA's OPAC Configuration
888 <VirtualHost $::servername\:$::opacport>
889    ServerAdmin $::svr_admin
890    DocumentRoot $::opacdir/htdocs
891    ServerName $::servername
892    ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
893    ErrorLog $logfiledir/opac-error_log
894    TransferLog $logfiledir/opac-access_log
895    SetEnv PERL5LIB "$::intranetdir/modules"
896    $includesdirectives
897 </VirtualHost>
898
899 # KOHA's INTRANET Configuration
900 <VirtualHost $::servername\:$::intranetport>
901    ServerAdmin $::svr_admin
902    DocumentRoot $::intranetdir/htdocs
903    ServerName $::servername
904    ScriptAlias /cgi-bin/koha/ "$::intranetdir/cgi-bin/"
905    ErrorLog $logfiledir/koha-error_log
906    TransferLog $logfiledir/koha-access_log
907    SetEnv PERL5LIB "$::intranetdir/modules"
908    $includesdirectives
909 </VirtualHost>
910
911 # If you want to use name based Virtual Hosting:
912 #   1. remove the two Listen lines
913 #   2. replace $::servername\:$::opacport wih your.opac.domain.name
914 #   3. replace ServerName $::servername wih ServerName your.opac.domain.name
915 #   4. replace $::servername\:$::intranetport wih your intranet domain name
916 #   5. replace ServerName $::servername wih ServerName your.intranet.domain.name
917 #
918 # If you want to use NameVirtualHost'ing (using two names on one ip address):
919 #   1.  Follow steps 1-5 above
920 #   2.  Uncomment the NameVirtualHost line and set the correct ip address
921
922 EOP
923
924
925     }
926 }
927
928 $messages->{'IntranetAuthenticationQuestion'}->{en}=qq|
929 ===========================
930 = INTRANET AUTHENTICATION =
931 ===========================
932
933 I can set it up so that the Intranet/Librarian site is password protected using
934 Apache's Basic Authorization.
935
936 Would you like to do this ([Y]/N): |;
937
938 $messages->{'BasicAuthUsername'}->{en}="Please enter a userid for intranet access [%s]: ";
939 $messages->{'BasicAuthPassword'}->{en}="Please enter a password for %s: ";
940 $messages->{'BasicAuthPasswordWasBlank'}->{en}="\nYou cannot use a blank password!\n\n";
941
942 sub basicauthentication {
943     my $message=getmessage('IntranetAuthenticationQuestion');
944     my $answer=showmessage($message, 'yn', 'y');
945
946     my $apacheauthusername='librarian';
947     my $apacheauthpassword='';
948     if ($answer=~/^y/i) {
949         ($apacheauthusername) = showmessage(getmessage('BasicAuthUsername', [ $apacheauthusername]), 'free', $apacheauthusername, 1);
950         $apacheauthusername=~s/[^a-zA-Z0-9]//g;
951         while (! $apacheauthpassword) {
952             ($apacheauthpassword) = showmessage(getmessage('BasicAuthPassword', [ $apacheauthusername]), 'free', 1);
953             if (!$apacheauthpassword) {
954                 ($apacheauthpassword) = showmessage(getmessage('BasicAuthPasswordWasBlank'), 'none', '', 1);
955             }
956         }
957         open AUTH, ">/etc/kohaintranet.pass";
958         my $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
959         my $salt=substr($chars, int(rand(length($chars))),1);
960         $salt.=substr($chars, int(rand(length($chars))),1);
961         print AUTH $apacheauthusername.":".crypt($apacheauthpassword, $salt)."\n";
962         close AUTH;
963         open(SITE,">>$::realhttpdconf") or warn "Insufficient priveleges to open $::realhttpdconf for writing.\n";
964         print SITE <<EOP
965
966 <Directory $::intranetdir>
967     AuthUserFile /etc/kohaintranet.pass
968     AuthType Basic
969     AuthName "Koha Intranet (for librarians only)"
970     Require  valid-user
971 </Directory>
972 EOP
973     }
974     close(SITE);
975 }
976
977 $messages->{'InstallFiles'}->{en}=qq|
978 ====================
979 = INSTALLING FILES =
980 ====================
981
982 Copying files to installation directories:
983
984 |;
985
986
987 $messages->{'CopyingFiles'}->{en}="Copying %s to %s.\n";
988
989
990
991 sub installfiles {
992
993
994     showmessage(getmessage('InstallFiles'),'none');
995     print getmessage('CopyingFiles', ['intranet-html', "$::intranetdir/htdocs" ]);
996     system("cp -R intranet-html/* $::intranetdir/htdocs/");
997     print getmessage('CopyingFiles', ['intranet-cgi', "$::intranetdir/cgi-bin" ]);
998     system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
999     print getmessage('CopyingFiles', ['stand-alone scripts', "$::intranetdir/scripts" ]);
1000     system("cp -R scripts/* $::intranetdir/scripts/");
1001     print getmessage('CopyingFiles', ['perl modules', "$::intranetdir/modules" ]);
1002     system("cp -R modules/* $::intranetdir/modules/");
1003     print getmessage('CopyingFiles', ['opac-html', "$::opacdir/htdocs" ]);
1004     system("cp -R opac-html/* $::opacdir/htdocs/");
1005     print getmessage('CopyingFiles', ['opac-cgi', "$::opacdir/cgi-bin" ]);
1006     system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
1007     system("touch $::opacdir/cgi-bin/opac");
1008
1009     system("chown -R root.$::httpduser $::opacdir");
1010     system("chown -R root.$::httpduser $::intranetdir");
1011
1012     # Create /etc/koha.conf
1013
1014     my $old_umask = umask(027); # make sure koha.conf is never world-readable
1015     open(SITES,">$::etcdir/koha.conf.tmp") or warn "Couldn't create file at $::etcdir. Must have write capability.\n";
1016     print SITES qq|
1017 database=$::dbname
1018 hostname=$::hostname
1019 user=$::user
1020 pass=$::pass
1021 includes=$::intranetdir/htdocs/includes
1022 intranetdir=$::intranetdir
1023 opacdir=$::opacdir
1024 kohalogdir=$::kohalogdir
1025 kohaversion=$::kohaversion
1026 httpduser=$::httpduser
1027 |;
1028     close(SITES);
1029     umask($old_umask);
1030
1031     chown((getpwnam($::httpduser)) [2,3], "$::etcdir/koha.conf.tmp") or warn "can't chown koha.conf: $!";
1032     chmod 0440, "$::etcdir/koha.conf.tmp";
1033
1034     chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
1035     chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
1036     chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
1037     chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
1038     chown(0, (getpwnam($::httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
1039
1040 }
1041
1042 $messages->{'MysqlRootPassword'}->{en}=qq|
1043 ============================
1044 = MYSQL ROOT USER PASSWORD =
1045 ============================
1046
1047 To allow us to create the koha database please supply your
1048 mysql server's root user password:
1049
1050 Enter MySql root user password: |;
1051
1052 $messages->{'InvalidMysqlRootPassword'}->{en}="Invalid Password.  Please try again.";
1053
1054 $messages->{'CreatingDatabase'}->{en}=qq|
1055 =====================
1056 = CREATING DATABASE =
1057 =====================
1058
1059 Creating the MySql database for Koha...
1060
1061 |;
1062
1063 $messages->{'CreatingDatabaseError'}->{en}=qq|
1064 ===========================
1065 = ERROR CREATING DATABASE =
1066 ===========================
1067
1068 Couldn't connect to the MySQL server for the reason given above.
1069 This is a serious problem, the database will not get installed.\a
1070
1071 Press <ENTER> to continue: |;
1072
1073 $messages->{'SampleData'}->{en}=qq|
1074 ===============
1075 = SAMPLE DATA =
1076 ===============
1077
1078 If you are installing Koha for evaluation purposes,  I have a batch of sample
1079 data that you can install now.
1080
1081 If you are installing Koha with the intention of populating it with your own
1082 data, you probably don't want this sample data installed.
1083
1084 Would you like to install the sample data? Y/[N]: |;
1085
1086 $messages->{'SampleDataInstalled'}->{en}=qq|
1087 =========================
1088 = SAMPLE DATA INSTALLED =
1089 =========================
1090
1091 Sample data has been installed.  For some suggestions on testing Koha, please
1092 read the file doc/HOWTO-Testing.  If you find any bugs, please submit them at
1093 http://bugs.koha.org/.  If you need help with testing Koha, you can post a
1094 question through the koha-devel mailing list, or you can check for a developer
1095 online at +irc.katipo.co.nz:6667 channel #koha.
1096
1097 You can find instructions for subscribing to the Koha mailing lists at:
1098
1099     http://www.koha.org
1100
1101
1102 Press <ENTER> to continue: |;
1103
1104 $messages->{'AddBranchPrinter'}->{en}=qq|
1105 ==========================
1106 = Add Branch and Printer =
1107 ==========================
1108
1109 Would you like to install an initial branch and printer? [Y]/N: |;
1110
1111 $messages->{'BranchName'}->{en}="Branch Name [%s]: ";
1112 $messages->{'BranchCode'}->{en}="Branch Code (4 letters or numbers) [%s]: ";
1113 $messages->{'PrinterQueue'}->{en}="Printer Queue [%s]: ";
1114 $messages->{'PrinterName'}->{en}="Printer Name [%s]: ";
1115 $messages->{'BlankMysqlPassword'}->{en}=qq|
1116 ========================
1117 = Blank MySql Password =
1118 ========================
1119
1120 Do not leave your MySql root password blank unless you know exactly what you
1121 are doing.  To change your MySql root password use the mysqladmin command:
1122
1123 mysqladmin password NEWPASSWORDHERE
1124
1125 Press <ENTER> to continue: 
1126 |;
1127
1128 sub databasesetup {
1129     $::mysqluser = 'root';
1130     $::mysqlpass = '';
1131
1132     foreach my $mysql (qw(/usr/local/mysql
1133                           /opt/mysql
1134                           /usr
1135                           )) {
1136        if ( -d $mysql  && -f "$mysql/bin/mysqladmin") {
1137             $::mysqldir=$mysql;
1138        }
1139     }
1140     if (!$::mysqldir){
1141         print "I don't see mysql in the usual places.\n";
1142         for (;;) {
1143             print "Where have you installed mysql? ";
1144             chomp($::mysqldir = <STDIN>);
1145             last if -f "$::mysqldir/bin/mysqladmin";
1146         print <<EOP;
1147
1148 I can't find it there either. If you compiled mysql yourself,
1149 please give the value of --prefix when you ran configure.
1150
1151 The file mysqladmin should be in bin/mysqladmin under the directory that you
1152 provide here.
1153
1154 EOP
1155         }
1156     }
1157
1158
1159     my $needpassword=1;
1160     while ($needpassword) {
1161         $::mysqlpass=showmessage(getmessage('MysqlRootPassword'), 'free');
1162         $::mysqlpass_quoted = $::mysqlpass;
1163         $::mysqlpass_quoted =~ s/"/\\"/g;
1164         $::mysqlpass_quoted="-p\"$::mysqlpass_quoted\"";
1165         $::mysqlpass eq '' and $::mysqlpass_quoted='';
1166         my $result=system("$::mysqldir/bin/mysqladmin -u$::mysqluser $::mysqlpass_quoted proc > /dev/null 2>&1");
1167         if ($result) {
1168             print getmessage('InvalidMysqlRootPassword');
1169         } else {
1170             if ($::mysqlpass eq '') {
1171                 showmessage(getmessage('BlankMysqlPassword'), 'PressEnter');
1172             }
1173             $needpassword=0;
1174         }
1175     }
1176
1177     showmessage(getmessage('CreatingDatabase'),'none');
1178
1179     my $result=system("$::mysqldir/bin/mysqladmin", "-u$::mysqluser", "-p$::mysqlpass", "create", "$::dbname");
1180     if ($result) {
1181         showmessage(getmessage('CreatingDatabaseError'),'PressEnter', '', 1);
1182     } else {
1183         # Populate the Koha database
1184         system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname < koha.mysql");
1185         # Set up permissions
1186         system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted mysql -e \"insert into user (Host,User,Password) values ('$::hostname','$::user',password('$::pass'))\"\;");
1187         system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted 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')\"");
1188         system("$::mysqldir/bin/mysqladmin -u$::mysqluser $::mysqlpass_quoted reload");
1189
1190
1191
1192
1193
1194     }
1195
1196 }
1197
1198 $messages->{'UpdateMarcTables'}->{en}=qq|
1199 =========================================
1200 = UPDATING MARC FIELD DEFINITION TABLES =
1201 =========================================
1202
1203 You can import marc parameters for :
1204
1205   1 MARC21
1206   2 UNIMARC
1207   3 none
1208
1209 Please choose which parameter you want to install. Note if you choose 3,
1210 nothing will be added, and it can be a BIG job to manually create those tables
1211
1212 Choose MARC definition [1]: |;
1213
1214 $messages->{'Language'}->{en}=qq|
1215 ====================
1216 = CHOOSE LANGUAGES  =
1217 ====================
1218 This version of koha supports a few languages.
1219 Enter you languages preferences : either en, fr or es.
1220 Note that the en is always choosen when the system does not finds the
1221 language you choose in a specific screen.
1222 fr : opac is translated (except pictures)
1223 es : a few intranet is translated (including pictures)
1224 |;
1225
1226 sub updatedatabase {
1227     my $result=system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
1228     if ($result) {
1229         print "Problem updating database...\n";
1230         exit;
1231     }
1232
1233     my $response=showmessage(getmessage('UpdateMarcTables'), 'restrictchar 123', '1');
1234
1235     if ($response == 1) {
1236         system("cat script/misc/marc_datas/marc21_en/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1237     }
1238     if ($response == 2) {
1239         system("cat scripts/misc/marc_datas/unimarc_fr/structure_def.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1240         system("cat scripts/misc/lang-datas/fr/stopwords.sql | $::mysqldir/bin/mysql -u$::mysqluser -p$::mysqlpass $::dbname");
1241     }
1242
1243     system ("perl -I $::kohadir/modules scripts/marc/updatedb2marc.pl");
1244
1245
1246     print "\n\nFinished updating database. Press <ENTER> to continue...";
1247     <STDIN>;
1248 }
1249
1250 sub populatedatabase {
1251         my $response=showmessage(getmessage('SampleData'), 'yn', 'n');
1252         if ($response =~/^y/i) {
1253                 system("gunzip sampledata-1.2.gz");
1254                 system("cat sampledata-1.2 | $::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname");
1255                 system("gzip -9 sampledata-1.2");
1256                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('MAIN', 'Main Library', 1)\"");
1257                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
1258                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\"");
1259                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('Circulation Desk Printer', 'lp', 'hp')\"");
1260                 showmessage(getmessage('SampleDataInstalled'), 'PressEnter','',1);
1261         } else {
1262                 my $input;
1263                 my $response=showmessage(getmessage('AddBranchPrinter'), 'yn', 'y');
1264
1265                 unless ($response =~/^n/i) {
1266                 my $branch='Main Library';
1267                 $branch=showmessage(getmessage('BranchName', [$branch]), 'free', $branch, 1);
1268                 $branch=~s/[^A-Za-z0-9\s]//g;
1269
1270                 my $branchcode=$branch;
1271                 $branchcode=~s/[^A-Za-z0-9]//g;
1272                 $branchcode=uc($branchcode);
1273                 $branchcode=substr($branchcode,0,4);
1274                 $branchcode=showmessage(getmessage('BranchCode', [$branchcode]), 'free', $branchcode, 1);
1275                 $branchcode=~s/[^A-Za-z0-9]//g;
1276                 $branchcode=uc($branchcode);
1277                 $branchcode=substr($branchcode,0,4);
1278                 $branchcode or $branchcode='DEF';
1279
1280                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
1281                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
1282                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\"");
1283
1284                 my $printername='Library Printer';
1285                 $printername=showmessage(getmessage('PrinterName', [$printername]), 'free', $printername, 1);
1286                 $printername=~s/[^A-Za-z0-9\s]//g;
1287
1288                 my $printerqueue='lp';
1289                 $printerqueue=showmessage(getmessage('PrinterQueue', [$printerqueue]), 'free', $printerqueue, 1);
1290                 $printerqueue=~s/[^A-Za-z0-9]//g;
1291                 system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
1292                 }
1293         my $language=showmessage(getmessage('Language'), 'free', 'en');
1294         system("$::mysqldir/bin/mysql -u$::mysqluser $::mysqlpass_quoted $::dbname -e \"update systempreferences set value='$language' where variable='opaclanguages'\"");
1295         }
1296 }
1297
1298 $messages->{'RestartApache'}->{en}=qq|
1299 ==================
1300 = RESTART APACHE =
1301 ==================
1302
1303 Apache needs to be restarted to load the new configuration for Koha.
1304
1305 Would you like to restart Apache now?  [Y]/N: |;
1306
1307 sub restartapache {
1308
1309     my $response=showmessage(getmessage('RestartApache'), 'yn', 'y');
1310
1311
1312
1313     unless ($response=~/^n/i) {
1314         # Need to support other init structures here?
1315         if (-e "/etc/rc.d/init.d/httpd") {
1316             system('/etc/rc.d/init.d/httpd restart');
1317         } elsif (-e "/etc/init.d/apache") {
1318             system('/etc//init.d/apache restart');
1319         } elsif (-e "/etc/init.d/apache-ssl") {
1320             system('/etc/init.d/apache-ssl restart');
1321         }
1322     }
1323
1324 }
1325
1326
1327 sub loadconfigfile {
1328     my %configfile;
1329
1330     open (KC, "/etc/koha.conf");
1331     while (<KC>) {
1332      chomp;
1333      (next) if (/^\s*#/);
1334      if (/(.*)\s*=\s*(.*)/) {
1335        my $variable=$1;
1336        my $value=$2;
1337        # Clean up white space at beginning and end
1338        $variable=~s/^\s*//g;
1339        $variable=~s/\s*$//g;
1340        $value=~s/^\s*//g;
1341        $value=~s/\s*$//g;
1342        $configfile{$variable}=$value;
1343      }
1344     }
1345
1346     $::intranetdir=$configfile{'intranetdir'};
1347     $::opacdir=$configfile{'opacdir'};
1348     $::kohaversion=$configfile{'kohaversion'};
1349     $::kohalogdir=$configfile{'kohalogdir'};
1350     $::database=$configfile{'database'};
1351     $::hostname=$configfile{'hostname'};
1352     $::user=$configfile{'user'};
1353     $::pass=$configfile{'pass'};
1354 }
1355
1356 END { }       # module clean-up code here (global destructor)
1357
1358 1;