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