Going to MARC 1.4...
[koha.git] / installer.pl
1 #!/usr/bin/perl -w # please develop with -w
2
3 use strict; # please develop with the strict pragma
4
5 print <<EOM;
6 **********************************
7 * Welcome to the Koha Installer  *
8 **********************************
9
10
11
12
13 This installer will prompt you with a series of questions.
14 It assumes you (or your system administrator) has installed:
15   * Apache (http://www.apache.org)
16   * Perl (http://www.perl.org)
17
18
19 and one of the following database applications:
20   * MySql (http://www.mysql.org)
21
22
23 on some type of Unix or Unix-like operating system
24
25
26
27 Is Apache, Perl, and a database from the list above installed on this system?
28
29 EOM
30
31 my $answer = $_;                      
32 chomp $answer;
33
34 if ($answer eq "Y" || $answer eq "y") {
35         print "Great!  \n";
36     } else {
37     print <<EOM;
38 You will need to setup database space for your application.
39 The installer currently does not support an automated setup with this database.
40 Please be sure to read the documentation.
41 EOM
42     exit(1);
43   };
44
45 print "I need to unpack the Koha TarFile -- where is it?  ";
46 $answer = $_;
47 chomp $answer;    
48
49 # FIXME?  using system is probably not the best way to do this 
50 # tar on solaris may not work properly, etc.
51 system("tar -x $answer"); #unpack fill out
52
53
54 #test for Perl and Apache?
55 print "Are you using MySql?[Y/N]: ";
56 $answer = $_;                      
57 chomp $answer
58 if ($answer eq "Y") { 
59         system("mysqladmin -uroot -ppassword create $KohaDBNAME ");
60         system("mysql -u$root -p$password ");
61         #need to get to mysql prompt  HOW DO I DO THIS?
62
63         # FIXME 
64         # you could pipe this into mysql in the shell that system generates
65         # can this be done from dbi?
66         system("grant all privileges on Koha.* to koha@localhost identified by 'kohapassword'; ");
67
68   };
69 if ($answer eq "N") {
70     print <<EOM;
71 You will need to use the MySQL database system for your application.
72 The installer currently does not support an automated setup with this database.
73 EOM
74   };
75
76 print "\n";
77 system ("perl updatedatabase -I /pathtoC4 ");
78
79 #KOHA conf
80 # FIXME
81 # is there a reason we don't just create the conf file here?
82
83 print <<EOM;
84 You will need to add the following to the Koha configuration file\n";
85 database=Koha\n";
86 hostname=localhost\n";
87 user=Koha\n";
88 pass=$password\n";
89 includes=/usr/local/www/koha/htdocs/includes\n";
90 EOM
91
92 #SETUP opac
93 #   <VirtualHost opac.your.site>                         
94 #   ServerAdmin webmaster@your.site                            
95 #   DocumentRoot /usr/local/www/opac/htdocs                     
96 #   ServerName opac.your.site                      
97 #   ErrorLog logs/opac-error_log       
98 #   TransferLog logs/opac-access_log               
99 #   </VirtualHost>
100
101
102 ###RESTART APACHE
103 # FIXME
104 # this is a pretty rude thing to do on a system ...
105 # perhaps asking the user first would be better.
106 #
107 system('/etc/rc.d/init.d/httpd restart');