Removed the dependency on Set::Scalar.
[koha.git] / installer-lite.pl
1 #!/usr/bin/perl -w # please develop with -w
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 diagnostics;
22 use strict; # please develop with the strict pragma
23
24 system('clear');
25 print qq|
26 *******************************************
27 * Welcome to the Koha Installation Guide  *
28 *******************************************
29
30 This installer will guide you through the process of installing Koha.
31 It is not a completely automated installation, but a guide for further 
32 information please read the documentation or visit the Koha website at
33 http://www.koha.org
34
35 To successfully use Koha you need some additional software:
36
37 * A webserver (It was built to work with Apache, but there is no reason
38 it should not work with any other webserver). 
39  
40 * Mysql (You could intead use postgres, or another sql based database) 
41
42 * Perl
43
44 Are you ready to go through the installation process now? (Y/[N]):
45 |;
46
47 my $answer = <STDIN>;
48 chomp $answer;
49
50 if ($answer eq "Y" || $answer eq "y") {
51         print "Beginning setup... \n";
52     } else {
53     print qq|
54 When you are ready to complete the installation just run this installer again.
55 |;
56     exit;
57 };
58
59 print "\n";
60
61
62 #
63 # Test for Perl - Do we need to explicity check versions?
64 #
65 print "\nChecking that perl and the required modules are installed ...\n";
66     unless (eval "require 5.004") {
67     die "Sorry, you need at least Perl 5.004\n";
68 }
69
70 #
71 # Test for Perl Dependancies
72 #
73 my @missing = ();
74 unless (eval require DBI)               { push @missing,"DBI" };
75 unless (eval require Date::Manip)       { push @missing,"Date::Manip" };
76 unless (eval require DBD::mysql)        { push @missing,"DBD::mysql" };
77
78 #
79 # Print out a list of any missing modules
80 #
81 if (@missing > 0) {
82     print "\n\n";
83     print "You are missing some Perl modules which are required by Koha.\n";
84     print "Once these modules have been installed, rerun this installery.\n";
85     print "They can be installed by running (as root) the following:\n";
86     foreach my $module (@missing) {
87         print "   perl -MCPAN -e 'install \"$module\"'\n";
88         exit(1);
89     }} else{
90     print "Perl and required modules appear to be installed, continuing...\n";
91 };
92
93
94 print "\n";
95
96 #
97 #KOHA conf
98 #
99 print qq|
100 Koha uses a small configuration file that is usually placed in your
101 /etc/ files directory (note: if you wish to place the koha.conf in 
102 another location you will need to manually edit additional files).
103
104 We will help you to now create your koha.conf file, once this file 
105 has been created, please copy it to your destination folder
106 (note: this may need to be done by your systems administrator).
107 |;
108
109 my $dbname;
110 my $hostname;
111 my $user;
112 my $pass;
113 my $inc_path;
114
115 print "\n";
116 print "\n";
117 print qq|
118 Please provide the name of the mysql database that you wish to use 
119 for koha. This is normally "Koha".
120 |;
121
122 #Get the database name
123 do {
124         print "Enter database name:";
125         chomp($dbname = <STDIN>);
126 };
127
128
129 print "\n";
130 print "\n";
131 print qq|
132 Please provide the hostname for mysql.  Unless the database is located 
133 on another machine this is likely to be "localhost".
134 |;
135
136 #Get the hostname for the database
137 do {
138         print "Enter hostname:";
139         chomp($hostname = <STDIN>);
140 };
141
142
143 print "\n";
144 print "\n";
145 print qq|
146 Please provide the name of the mysql user, who will have full administrative 
147 rights to the $dbname database, when authenicating from $hostname.
148 It is recommended that you do not use your "root" user.
149 |;
150
151 #Set the username for the database
152 do {
153         print "Enter username:";
154         chomp($user = <STDIN>);
155 };
156
157
158 print "\n";
159 print "\n";
160 print qq|
161 Please provide a password for the mysql user $user.
162 |;
163
164 #Set the password for the database user
165 do {
166         print "Enter password:";
167         chomp($pass = <STDIN>);
168 };
169
170 print "\n";
171 print "\n";
172 print qq|
173 Please provide the full path to your Koha Intranet/Librarians installation.
174 Usually /usr/local/www/koha/htdocs
175 |;
176
177 #Get the password for the database user
178 do {
179         print "Enter installation path:";
180         chomp($inc_path = <STDIN>);
181 };
182
183
184 #Create the configuration file
185 open(SITES,">koha.conf") or die "Couldn't create file.  
186 Must have write capability.\n";
187 print SITES <<EOP
188 database=$dbname
189 hostname=$hostname
190 user=$user
191 password=$pass
192 includes=$inc_path/includes
193 EOP
194 ;
195 close(SITES);
196
197 print "Successfully created the Koha configuration file.\n";
198
199 print "\n";
200
201 #
202 #SETUP Virtual Host Directives
203 #
204 #OPAC Settings
205 #
206 my $opac_svr_admin;
207 my $opac_docu_root;
208 my $opac_svr_name;
209
210 print qq|
211 You need to setup your Apache configuration file for the
212 OPAC virtual host.
213
214 Please enter the servername for the OPAC interface.
215 Usually opac.your.domain
216 |;
217 do {
218         print "Enter servername address:";
219         chomp($opac_svr_name = <STDIN>);
220 };
221
222
223 print qq|
224 Please enter the e-mail address for your webserver admin.
225 Usually webmaster\@your.domain
226 |;
227 do {
228         print "Enter e-mail address:";
229         chomp($opac_svr_admin = <STDIN>);
230 };
231
232
233 print qq|
234 Please enter the full path to your OPAC\'s document root.
235 usually something like \"/usr/local/www/opac/htdocs\".
236 |;
237 do {
238         print "Enter Document Roots Path:";
239         chomp($opac_docu_root = <STDIN>);
240 };
241
242
243 #
244 # Update Apache Conf File.
245 #
246 open(SITES,">>koha-apache.conf") or die "Couldn't write to file.  
247 Must have write capability.\n";
248 print SITES <<EOP
249
250 <VirtualHost $opac_svr_name>
251     ServerAdmin $opac_svr_admin
252     DocumentRoot $opac_docu_root
253     ServerName $opac_svr_name
254     ErrorLog logs/opac-error_log
255     TransferLog logs/opac-access_log common
256 </VirtualHost>
257
258 EOP
259 ;
260 close(SITES);
261
262
263 #
264 #Intranet Settings
265 #
266 my $intranet_svr_admin;
267 my $intranet_svr_name;
268
269 print qq|
270 You need to setup your Apache configuration file for the
271 Intranet/librarian virtual host.
272
273 Please enter the servername for your Intranet/Librarian interface.
274 Usually koha.your.domain
275 |;
276 do {
277         print "Enter servername address:";
278         chomp($intranet_svr_name = <STDIN>);
279 };
280
281
282 print qq|
283 Please enter the e-mail address for your webserver admin.
284 Usually webmaster\@your.domain
285 |;
286 do {
287         print "Enter e-mail address:";
288         chomp($intranet_svr_admin = <STDIN>);
289 };
290
291
292
293 #
294 # Update Apache Conf File.
295 #
296 open(SITES,">>koha-apache.conf") or die "Couldn't write to file.  
297 Must have write capability.\n";
298 print SITES <<EOP
299
300 <VirtualHost $intranet_svr_name>
301     ServerAdmin $intranet_svr_admin
302     DocumentRoot $inc_path
303     ServerName $intranet_svr_name
304     ErrorLog logs/opac-error_log
305     TransferLog logs/opac-access_log common
306 </VirtualHost>
307
308 EOP
309 ;
310 close(SITES);
311
312
313 print "Successfully created the Apache Virtual Host Configuration file.\n";
314
315 system('clear');
316 print qq|
317 *******************************************
318 * Koha Installation Guide - Continued     *
319 *******************************************
320
321 In order to finish the installation of Koha, there is still a couple 
322 of steps that you will need to complete.
323
324   * Setup mysql
325         1. Create a new mysql database called for example Koha
326            From command line: mysqladmin -uroot -ppassword create Koha 
327
328         2. Set up a koha user and password in mysql
329            Log in to mysql: mysql -uroot -ppassword 
330
331            To create a user called "koha" who has full administrative 
332            rights to the "Koha" database when authenticating from 
333            "localhost", enter the following on mysql command line: 
334
335             grant all privileges on Koha.* to koha\@localhost identified by 'kohapassword'\;
336
337            Press ENTER, and if you see no errors then enter \q to quit mysql.
338
339
340         3. Use the mysql script to create the tables
341            mysql -uusername -ppassword Koha < koha.mysql 
342
343         4. Update your database tables
344            perl updatedatabase -I /pathtoC4 
345
346         5. Update your database to use MARC
347            perl marc/fill_usmarc.pl -I /pathtoC4 to put MARC21 - english datas in parameter table
348            perl marc/updatedb2marc.pl -I /pathtoC4 to update biblios from old-DB to MARC-DB (!!! it may be long : 30 biblios/second)
349
350   * Koha.conf
351         1. Copy Koha.conf to /etc/
352            If you wish to locate the file in another location please read 
353            the INSTALL and Hints files.
354
355
356 |;
357 #
358 # It is completed
359 #
360 print "\nCongratulations ... your Koha installation is complete!\n";
361 print "\nYou will need to restart your webserver before using Koha!\n";