# Copyright 2000-2002 Katipo Communications
-# Contains parts Copyright 2003 MJ Ray
+# Contains parts Copyright 2003-4 MJ Ray
#
# This file is part of Koha.
#
use POSIX;
#MJR: everyone will have these modules, right?
# They look like part of perl core to me
-use Term::Cap;
+#use Term::Cap;
use Term::ANSIColor qw(:constants);
use Text::Wrap;
+use File::Temp qw/ :mktemp /;
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
&checkabortedinstall
&getmessage
&showmessage
+ &completeupgrade
&releasecandidatewarning
&getinstallationdirectories
&getdatabaseinfo
use vars qw( $etcdir ); # set in installer.pl, usu. /etc
use vars qw( $intranetdir $opacdir $kohalogdir );
-use vars qw( $realhttpdconf $httpduser );
+use vars qw( $realhttpdconf $httpduser $httpdgroup );
use vars qw( $servername $svr_admin $opacport $intranetport );
use vars qw( $mysqldir );
use vars qw( $database $mysqluser );
=cut
-my $termios = POSIX::Termios->new();
-$termios->getattr();
-my $terminal = Term::Cap->Tgetent({OSPEED=>$termios->getospeed()});
-my $clear_string = "\n";
+#my $termios = POSIX::Termios->new();
+#$termios->getattr();
+#my $terminal = Term::Cap->Tgetent({OSPEED=>$termios->getospeed()});
+my $clear_string = "\n\n"; #MJR: was $terminal->Tputs('cl');
sub heading ($) {
my $title = shift;
}
my $mycnf = $ENV{HOME}."/.my.cnf";
-my $mytmpcnf = `mktemp my.cnf.koha.XXXXXX`;
+my $mytmpcnf = mktemp("my.cnf.koha.XXXXXX");
chomp($mytmpcnf);
my $messages;
$messages->{'WelcomeToKohaInstaller'}->{en} =
heading('Welcome to the Koha Installer') . qq|
This program will ask some questions and try to install koha for you.
-You need to know:
-* where most koha files should be stored (you can set the prefix environment variable for this);
-* the username and password of a mysql superuser;
-* Details of your library setup.
-* Details of your Apache setup.
+You need to know: where most koha files should be stored (you can set
+the prefix environment variable for this); the username and password of
+a mysql superuser; and details of your library setup. You may also need
+to know details of your Apache setup.
If you want to install the Koha configuration files somewhere other than
-/etc (for multiple Koha versions on one system, for example), you should
+/etc (for installing not as root, or to have many Kohas on one system, for example), you should
set the etcdir environment variable. Please look at your manuals for
details of how to set that.
$messages->{'WelcomeToUpgrader'}->{en} =
heading('Welcome to the Koha Upgrader') . qq|
-You are attempting to upgrade to Koha %s.
+You are attempting to upgrade from Koha %s to Koha %s.
We recommend that you do a complete backup of all your files before upgrading.
This upgrade script will make a backup copy of your files for you.
$messages->{'Completed'}->{en} = heading('INSTALLATION COMPLETE') . qq|
Congratulations ... your Koha installation is complete!
+
You will be able to connect to your Librarian interface at:
+
http://%s\:%s/
+
use the koha admin mysql login and password to connect to this interface.
and the OPAC interface at:
+
http://%s\:%s/
NOTE: You need to add lines to your main httpd.conf to include
Press <ENTER> to exit the installer: |;
#'
+
+=item completeupgrade
+
+ completeupgrade
+
+Display a message describing what may need changing in httpd.conf
+and any other instructions
+
+=cut
+
+sub completeupgrade {
+ showmessage(getmessage('UpgradeCompleted',[$intranetdir,$intranetdir,$intranetdir,$opacdir,$opacdir,$intranetdir]),'PressEnter');
+}
+
sub releasecandidatewarning {
my $message=getmessage('ReleaseCandidateWarning', [$newversion, $newversion]);
my $answer=showmessage($message, 'yn', 'n');
if ($answer =~ /y/i) {
print getmessage('continuing');
} else {
- my $message=getmessage('WatchForReleaseAnnouncements','');
+ my $message=getmessage('WatchForReleaseAnnouncements');
print $message."\n";
exit;
};
Sets the sysconfdir, normally /etc.
This should be an absolute path; a trailing / is not required.
+Must be writeable, else we die.
=cut
sub setetcdir ($) {
($etcdir) = @_;
+ if (! ((-d $etcdir) && (-w $etcdir))) { die("Cannot write to $etcdir! Please set the etcdir environment variable to a writeable directory.\nFailed"); }
}
=item getkohaversion
sub getinstallationdirectories {
my ($auto_install) = @_;
- if (!$ENV{prefix}) { $ENV{prefix} = "/usr/local"; } #"
+ if (!$ENV{prefix}) { $ENV{prefix} = "/usr/local"; }
$opacdir = $ENV{prefix}.'/koha/opac';
$intranetdir = $ENV{prefix}.'/koha/intranet';
my $getdirinfo=1;
/usr/local
/usr
)) {
- if ( -d $mysql && -f "$mysql/bin/mysqladmin") { #"
+ if ( -d $mysql && -f "$mysql/bin/mysqladmin") {
$mysqldir=$mysql;
}
}
NOTE: You will need to add lines to your main httpd.conf to
include %s/koha-httpd.conf
+(using the Include directive)
and to make sure it is listening on the right ports
+and host names
(using the Listen directive).
Press <ENTER> to continue: |;
}
print SITE <<EOP
+# Koha 2.2 Apache Virtual Host Config File
+#
+# Please include this file in your apache configuration.
+# The best way to do that depends on your site setup.
+# Some like an Include adding to /etc/apache/httpd.conf
+# and some prefer a symlink to this file from some dir.
+# Please refer to your system manuals.
+
# Ports to listen to for Koha
# uncomment these if they aren't already in main httpd.conf
#$opaclisten
#$intranetlisten
# NameVirtualHost is used by one of the optional configurations detailed below
+# Please make sure this line is correct before uncommenting.
+# See http://httpd.apache.org/docs/vhosts/ for some guides.
#NameVirtualHost 11.22.33.44
DocumentRoot $opacdir/htdocs
ServerName $servername
ScriptAlias /cgi-bin/koha/ $opacdir/cgi-bin/
+ Redirect permanent index.html http://$servername\:$opacport/cgi-bin/koha/opac-main.pl
ErrorLog $logfiledir/opac-error_log
TransferLog $logfiledir/opac-access_log
SetEnv PERL5LIB "$intranetdir/modules"
DocumentRoot $intranetdir/htdocs
ServerName $servername
ScriptAlias /cgi-bin/koha/ "$intranetdir/cgi-bin/"
+ Redirect permanent index.html http://$servername\:$intranetport/cgi-bin/koha/mainpage.pl
ErrorLog $logfiledir/koha-error_log
TransferLog $logfiledir/koha-access_log
SetEnv PERL5LIB "$intranetdir/modules"
setmysqlclipass($mysqlpass);
# Set up permissions
startsysout();
- print system("$mysqldir/bin/mysql -u$mysqluser mysql -e \"insert into user (Host,User,Password) values ('$hostname','$user',password('$pass'))\"\;");#"
- system("$mysqldir/bin/mysql -u$mysqluser mysql -e \"insert into db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv, index_priv, alter_priv) values ('%','$database','$user','Y','Y','Y','Y','Y','Y','Y','Y')\"");
+ print system("$mysqldir/bin/mysql -u$mysqluser -e \"insert into user (Host,User,Password) values ('$hostname','$user',password('$pass'))\" mysql\;");
+ system("$mysqldir/bin/mysql -u$mysqluser -e \"insert into db (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv, index_priv, alter_priv) values ('%','$database','$user','Y','Y','Y','Y','Y','Y','Y','Y')\" mysql");
system("$mysqldir/bin/mysqladmin -u$mysqluser reload");
# Change to admin user login
setmysqlclipass($pass);
$ENV{"KOHA_CONF"}=$etcdir.'/koha.conf';
if (! -e $ENV{"KOHA_CONF"}) { $ENV{"KOHA_CONF"}=$etcdir.'/koha.conf.tmp'; }
startsysout();
+ setmysqlclipass($pass);
my $result=system ("perl -I $intranetdir/modules scripts/updater/updatedatabase -s");
if ($result) {
restoremycnf();
$branchcode or $branchcode='DEF';
startsysout();
- system("$mysqldir/bin/mysql -u$user $database -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\"");
- system("$mysqldir/bin/mysql -u$user $database -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\"");
- system("$mysqldir/bin/mysql -u$user $database -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\"");
+ system("$mysqldir/bin/mysql -u$user -e \"insert into branches (branchcode,branchname,issuing) values ('$branchcode', '$branch', 1)\" $database");
+ system("$mysqldir/bin/mysql -u$user -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'IS')\" $database");
+ system("$mysqldir/bin/mysql -u$user -e \"insert into branchrelations (branchcode,categorycode) values ('MAIN', 'CU')\" $database");
my $printername='lp';
my $printerqueue='/dev/lp0';
$printerqueue=~s/[^A-Za-z0-9]//g;
}
startsysout();
- system("$mysqldir/bin/mysql -u$user $database -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\"");
+ system("$mysqldir/bin/mysql -u$user -e \"insert into printers (printername,printqueue,printtype) values ('$printername', '$printerqueue', '')\" $database");
}
my $language;
if ($auto_install->{Language}) {
$language=showmessage(getmessage('Language'), 'free', 'en');
}
startsysout();
- system("$mysqldir/bin/mysql -u$user $database -e \"update systempreferences set value='$language' where variable='opaclanguages'\"");
+ system("$mysqldir/bin/mysql -u$user -e \"update systempreferences set value='$language' where variable='opaclanguages'\" $database");
my @dirs;
if (-d "scripts/misc/sql-datas") {
# ask for directory to look for files to append
$year+=1900;
my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, $day,$hr,$min,$sec;
-open (MD, "$mysqldir/bin/mysqldump --user=$user --password=$pass --host=$hostname $database|");
+setmysqlclipass($pass);
+open (MD, "$mysqldir/bin/mysqldump --user=$user --host=$hostname $database|");
(open BF, ">$backupdir/Koha.backup_$date") || (die "Error opening up backup file $backupdir/Koha.backup_$date: $!\n");