1 #!/usr/bin/perl -w # please develop with -w
4 use strict; # please develop with the strict pragma
8 **********************************
9 * Welcome to the Koha Installer *
10 **********************************
12 This installer will prompt you with a series of questions.
13 It assumes you (or your system administrator) has installed:
14 * Apache (http://httpd.apache.org/)
15 * Perl (http://www.perl.org)
17 and one of the following database applications:
18 * MySql (http://www.mysql.org)
20 on some type of Unix or Unix-like operating system
23 Are Apache, Perl, and a database from the list above installed
24 on this system? (Y/[N]):
30 if ($answer eq "Y" || $answer eq "y") {
31 print "Great! continuing setup... \n";
34 This installer currently does not support an completely automated
37 Please be sure to read the documentation, or visit the Koha website
38 at http://www.koha.org for more information.
47 # Test for Perl - Do we need to explicity check versions?
49 print "\nChecking perl modules ...\n";
50 unless (eval "require 5.004") {
51 die "Sorry, you need at least Perl 5.004\n";
55 # Test for Perl Dependancies
58 unless (eval require DBI) { push @missing,"DBI" };
59 unless (eval require Date::Manip) { push @missing,"Date::Manip" };
60 unless (eval require DBD::mysql) { push @missing,"DBD::mysql" };
61 unless (eval require Set::Scalar) { push @missing,"Set::Scalar" };
64 # Print out a list of any missing modules
68 print "You are missing some Perl modules which are required by Koha.\n";
69 print "Once these modules have been installed, rerun this installery.\n";
70 print "They can be installed by running (as root) the following:\n";
71 foreach my $module (@missing) {
72 print " perl -MCPAN -e 'install \"$module\"'\n";
75 print "All modules appear to be installed, continuing...\n";
80 print "Testing for mysql - still to be done\n";
82 #print "Are you using MySql?(Y/[N]): ";
85 #if ($answer eq "Y" || $answer eq "y") {
87 # there is no $password or $KohaDBNAME yet
88 # system("mysqladmin -uroot -p$password create $KohaDBNAME ");
89 # system("mysql -u$root -p$password ");
90 #need to get to mysql prompt HOW DO I DO THIS?
93 # you could pipe this into mysql in the shell that system generates
94 # can this be done from dbi?
95 # system("grant all privileges on Koha.* to koha@localhost identified by 'kohapassword'; ");
98 #You will need to use the MySQL database system for your application.
99 #The installer currently does not support an automated setup with this database.
106 # there is no updatedatabase program yet
108 #system ("perl updatedatabase -I /pathtoC4 ");
114 Koha uses a small configuration file that is usually placed in your
115 /etc/ files directory (although you can technically place
116 it anywhere you wish).
118 Please enter the full path to your configuration files
119 directory (the default Koha conf file is "koha.conf").
120 The path is usually something like /etc/ by default. The
121 configuration file, will be created here.
124 #Get the path to the koha.conf directory
133 chomp($conf_path = <STDIN>);
134 print "$conf_path is not a directory.\n" if !-d $conf_path;
135 } until -d $conf_path;
141 Please provide the name of the mysql database for koha.
142 This is normally "Koha".
145 #Get the database name
147 print "Enter database name:";
148 chomp($dbname = <STDIN>);
155 Please provide the hostname for mysql. Unless the database is located
156 on another machine this is likely to be "localhost".
159 #Get the hostname for the database
161 print "Enter hostname:";
162 chomp($hostname = <STDIN>);
169 Please provide the name of the user, who has full administrative
170 rights to the $dbname database, when authenicating from $hostname.
173 #Get the username for the database
175 print "Enter username:";
176 chomp($user = <STDIN>);
183 Please provide the password for the user $user.
186 #Get the password for the database user
188 print "Enter password:";
189 chomp($pass = <STDIN>);
196 Please provide the full path to your Koha OPAC installation.
197 Usually /usr/local/www/koha/htdocs
200 #Get the password for the database user
202 print "Enter installation path:";
203 chomp($inc_path = <STDIN>);
207 #Create the configuration file
208 open(SITES,">$conf_path/koha.conf") or die "Couldn't create file
209 at $conf_path. Must have write capability.\n";
215 includes=$inc_path/includes
220 print "Successfully created the Koha configuration file.\n";
226 The permissions on the koha.conf file should also be strict,
227 since they contain the database password.
228 Please supply the username that your apache webserver runs under.
231 print "Enter apache user:";
232 chomp($apache_owner = <STDIN>);
237 # Set ownership of the koha.conf file for security
238 # FIXME - this will only work if run as work.
241 chown((getpwnam($apache_owner)) [2,3], "$conf_path/koha.conf") or die "can't chown koha.conf: $!";
249 my $apache_conf_path;
255 Koha needs to setup your Apache configuration file for the
258 Please enter the filename and path to your Apache Configuration file
259 usually located in \"/usr/local/apache/conf/httpd.conf\".
263 chomp($apache_conf_path = <STDIN>);
264 print "$conf_path is not a valid file.\n" if !-f $apache_conf_path;
265 } until -f $apache_conf_path;
269 Please enter the servername for your OPAC.
270 Usually opac.your.domain
273 print "Enter servername address:";
274 chomp($svr_name = <STDIN>);
279 Please enter the e-mail address for your webserver admin.
280 Usually webmaster\@your.domain
283 print "Enter e-mail address:";
284 chomp($svr_admin = <STDIN>);
289 Please enter the full path to your OPAC\'s document root.
290 usually something like \"/usr/local/www/opac/htdocs\".
293 print "Enter Document Roots Path:";
294 chomp($docu_root = <STDIN>);
299 # Update Apache Conf File.
301 open(SITES,">>$apache_conf_path") or die "Couldn't write to file
302 $conf_path. Must have write capability.\n";
305 <VirtualHost $svr_name>
306 ServerAdmin $svr_admin
307 DocumentRoot $docu_root
309 ErrorLog logs/opac-error_log
310 TransferLog logs/opac-access_log common
317 print "Successfully updated Apache Configuration file.\n";
323 # this is a pretty rude thing to do on a system ...
324 # perhaps asking the user first would be better.
326 #system('/etc/rc.d/init.d/httpd restart');
331 print "\nCongratulations ... your Koha installation is complete!\n";
332 print "\nYou will need to restart your webserver before using Koha!\n";