little bugfixes for opac templated.
[koha.git] / misc / 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 $::language='en';
10
11 unless ($< == 0) {
12     print "You must be root to run this script.\n";
13     exit 1;
14 }
15
16
17 unless (-d 'intranet-html') {
18    print <<EOP;
19 You seem to be installing from CVS. Please run the "buildrelease" script
20 and install from the resulting release tarball.
21 EOP
22    exit 1;
23 }
24
25 $::kohaversion=`cat koha.version`;
26 chomp $::kohaversion;
27
28
29 if ($::kohaversion =~ /RC/) {
30     releasecandidatewarning();
31 }
32
33 if (-e "/etc/koha.conf") {
34     $::installedversion=`grep kohaversion= /etc/koha.conf`;
35     chomp $::installedversion;
36     $::installedversion=~m/kohaversion=(.*)/;
37     $::installedversion=$1;
38     my $installedversionmsg;
39     if ($::installedversion) {
40         $installedversionmsg=getmessage('KohaVersionInstalled', [$::installedversion]);
41     } else {
42         $installedversionmsg=getmessage('KohaUnknownVersionInstalled');
43     }
44
45     my $message=getmessage('KohaAlreadyInstalled', [$::kohaversion, $installedversionmsg]);
46     showmessage($message, 'none');
47     exit;
48 }
49
50 my $continuingmsg=getmessage('continuing');
51
52 my $message=getmessage('WelcomeToKohaInstaller');
53 my $answer=showmessage($message, 'yn');
54
55 if ($answer eq "Y" || $answer eq "y") {
56         print $continuingmsg;
57     } else {
58     print qq|
59 This installer currently does not support a completely automated 
60 setup.
61
62 Please be sure to read the documentation, or visit the Koha website 
63 at http://www.koha.org for more information.
64 |;
65     exit;
66 };
67
68 my $input;
69 $::domainname = `hostname -d`;
70 chomp $::domainname;
71 $::etcdir = '/etc';
72
73
74 # Check for missing Perl Modules
75 checkperlmodules();
76
77 # Ask for installation directories
78 getapacheinfo();
79
80 getinstallationdirectories();
81
82 getdatabaseinfo();
83
84 getapachevhostinfo();
85
86 updateapacheconf();
87
88 basicauthentication();
89
90 installfiles();
91
92 databasesetup();
93
94 restartapache();
95
96
97 # Installation is complete.  Rename the koha.conf.tmp file
98
99 rename "$::etcdir/koha.conf.tmp", "$::etcdir/koha.conf" || warn "Couldn't rename file at $::etcdir. Must have write capability.\n";
100
101
102 updatedatabase();
103
104 populatedatabase();
105
106 showmessage(getmessage('AuthenticationWarning'), 'PressEnter');
107
108
109 showmessage(getmessage('Completed', [ $::servername, $::intranetport, $::servername, $::opacport]), 'PressEnter');
110
111
112
113
114 my $reply=showmessage('Would you like to complete a survey about your library?', 'yn', 'y');
115 if ($reply=~/y/i) {
116     system("perl kohareporter");
117 }
118