4 use strict; # please develop with the strict pragma
9 ###############################################
10 # SET THE etcdir ENVIRONMENT VAR INSTEAD #
11 ###############################################
12 my $etcdir = $ENV{etcdir}||'/etc';
13 system("mkdir -p $etcdir");
15 Install::setetcdir $etcdir;
21 ($::kohaversion) || ($::kohaversion='unknown version');
22 $::newversion=`cat koha.version`;
24 if ($::newversion =~ /RC/) {
25 releasecandidatewarning();
34 You are attempting to upgrade from Koha $::kohaversion to $::newversion.
36 We recommend that you do a complete backup of all your files before upgrading.
37 This upgrade script will make a backup copy of your files for you.
39 Would you like to proceed? (Y/[N]):
45 unless ($answer =~/y/i) {
48 Aborting. Please re-run koha.upgrade when you are ready to upgrade Koha.
52 print "Great! continuing upgrade... \n";
57 my $backupdir=($ENV{prefix}||'/usr/local/koha').'/backups';
58 print "Please specify a backup directory [$backupdir]: ";
67 if (! -e $backupdir) {
68 my $result=mkdir ($backupdir, oct(770));
70 my @dirs = split(m#/#, $backupdir);
74 unless (-e "$checkdir") {
75 mkdir($checkdir, 0775);
81 chmod 0770, $backupdir;
83 # Backup MySql database
89 foreach my $mysql (qw(/usr/local/mysql
93 if ( -d $mysql && -f "$mysql/bin/mysqladmin") {
98 print "I don't see mysql in the usual places.\n";
100 print "Where have you installed mysql? ";
101 chomp($mysqldir = <STDIN>);
102 last if -f "$mysqldir/bin/mysqladmin";
105 I can't find it there either. If you compiled mysql yourself,
106 please give the value of --prefix when you ran configure.
108 The file mysqladmin should be in bin/mysqladmin under the directory that you
115 print "Doing backup\n";
118 my ($sec, $min, $hr, $day, $month, $year) = (localtime(time))[0,1,2,3,4,5];
121 my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, $day,$hr,$min,$sec;
123 open (MD, "$mysqldir/bin/mysqldump --user=$::user --password=$::pass --host=$::hostname $::database|");
125 (open BF, ">$backupdir/Koha.backup_$date") || (die "Error opening up backup file $backupdir/Koha.backup_$date: $!\n");
129 my $biblioitemcounter=0;
133 (/insert into items /i) && ($itemcounter++);
134 (/insert into biblioitems /i) && ($biblioitemcounter++);
135 (/insert into biblio /i) && ($bibliocounter++);
136 (/insert into borrowers /i) && ($membercounter++);
143 my $filels=`ls -hl $backupdir/Koha.backup_$date`;
150 %6d biblioitems entries
155 ---------------------------------------------------------------------
157 ---------------------------------------------------------------------
159 Does this look right? ([Y]/N):
160 |, $bibliocounter, $biblioitemcounter, $itemcounter, $membercounter;
165 if ($answer=~/^n/i) {
168 Aborting. The database dump is located in:
170 $backupdir/Koha.backup_$date
175 print "Great! continuing upgrade... \n";
180 if ($::opacdir && $::intranetdir) {
183 I believe that your old files are located in:
186 LIBRARIAN: $::intranetdir
189 Does this look right? ([Y]/N):
194 if ($answer =~/n/i) {
198 print "Great! continuing upgrade... \n";
203 if (!$::opacdir || !$::intranetdir) {
206 while (!$::intranetdir) {
207 print "Please specify the location of your LIBRARIAN files: ";
213 $::intranetdir=$answer;
215 if (! -e "$::intranetdir/htdocs") {
216 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
220 while (!$::opacdir) {
221 print "Please specify the location of your OPAC files: ";
229 if (! -e "$::opacdir/htdocs") {
230 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
238 print "\n\nBacking up old Koha scripts...\n";
239 print "===============================\n\n";
241 mkdir "$backupdir/kohafiles-$date", 0770;
242 mkdir "$backupdir/kohafiles-$date/intranet", 0770;
243 mkdir "$backupdir/kohafiles-$date/opac", 0770;
245 my $result=system("cp -R $::intranetdir/* $backupdir/kohafiles-$date/intranet/");
247 print "Error encounted when copying $::intranetdir to $backupdir/kohafiles-$date/intranet/\n";
250 system("rm -rf $::intranetdir/*");
252 $result=system("cp -R $::opacdir/* $backupdir/kohafiles-$date/opac/");
254 print "Error encounted when copying $::opacdir to $backupdir/kohafiles-$date/opac/\n";
257 system("rm -rf $::opacdir/*");
260 print "Creating $::intranetdir/htdocs...\n";
261 mkdir ("$::intranetdir/htdocs", oct(750));
262 print "Creating $::intranetdir/cgi-bin...\n";
263 mkdir ("$::intranetdir/cgi-bin", oct(750));
264 print "Creating $::intranetdir/modules...\n";
265 mkdir ("$::intranetdir/modules", oct(750));
266 print "Creating $::intranetdir/scripts...\n";
267 mkdir ("$::intranetdir/scripts", oct(750));
268 chmod (oct(770), "$::opacdir");
269 print "Creating $::opacdir/htdocs...\n";
270 mkdir ("$::opacdir/htdocs", oct(750));
271 print "Creating $::opacdir/cgi-bin...\n";
272 mkdir ("$::opacdir/cgi-bin", oct(750));
277 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
278 /usr/local/etc/apache/httpd.conf
279 /usr/local/etc/apache/apache.conf
280 /var/www/conf/httpd.conf
281 /etc/apache/conf/httpd.conf
282 /etc/apache/conf/apache.conf
283 /etc/apache-ssl/conf/apache.conf
284 /etc/httpd/conf/httpd.conf
285 /etc/httpd/conf/commonhttpd.conf
286 /etc/httpd/httpd.conf)) {
287 if ( -f $httpdconf ) {
288 $realhttpdconf=$httpdconf;
289 open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to open $httpdconf for reading.\n";
290 while (<HTTPDCONF>) {
291 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
299 unless ($httpduser) {
301 I was not able to determine the user that Apache is running as. This
302 information is necessary in order to set the access privileges correctly on
303 koha.conf. This user should be set in one of the Apache configuration
304 files using the "User" directive.
306 print "What is your Apache user? ";
307 chomp($input = <STDIN>);
312 $httpduser='Undetermined';
316 print "\n\nINSTALLING KOHA...\n";
317 print "\n\n==================\n";
318 print "Copying intranet-html files to $::intranetdir/htdocs...\n";
319 system("cp -R intranet-html/* $::intranetdir/htdocs/");
320 print "Copying intranet-cgi files to $::intranetdir/cgi-bin...\n";
321 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
322 print "Copying script files to $::intranetdir/scripts...\n";
323 system("cp -R scripts/* $::intranetdir/scripts/");
324 print "Copying module files to $::intranetdir/modules...\n";
325 system("cp -R modules/* $::intranetdir/modules/");
326 print "Copying opac-html files to $::opacdir/htdocs...\n";
327 system("cp -R opac-html/* $::opacdir/htdocs/");
328 print "Copying opac-cgi files to $::opacdir/cgi-bin...\n";
329 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
330 system("touch $::opacdir/cgi-bin/opac");
332 system("chown -R root:$httpduser $::opacdir");
333 system("chown -R root:$httpduser $::intranetdir");
336 # Copy custom templates and reports back in
338 opendir D, "$backupdir/kohafiles-$date/intranet/htdocs/";
339 my @dirlist=readdir D;
342 (next) if ($_ eq 'default');
343 (next) if ($_ eq 'doc');
344 (next) if ($_=~/^koha-/);
345 (next) if (-e "$::intranetdir/htdocs/$_");
346 print "Restoring custom intranet templates $_...\n";
347 system("cp -a $backupdir/kohafiles-$date/intranet/htdocs/$_ $::intranetdir/htdocs/");
350 opendir D, "$backupdir/kohafiles-$date/opac/htdocs/";
354 (next) if ($_ eq 'default');
355 (next) if ($_ eq 'doc');
356 (next) if ($_=~/^koha-/);
357 (next) if (-e "$::opacdir/htdocs/$_");
358 print "Restoring custom opac template $_...\n";
359 system("cp -a $backupdir/kohafiles-$date/opac/htdocs/$_ $::opacdir/htdocs/");
366 unless ($::kohalogdir && -e $::kohalogdir) {
367 $::kohalogdir='/var/log/koha';
368 print "\n\nDirectory for logging by Z39.50 daemon [$::kohalogdir]: ";
369 chomp($input = <STDIN>);
371 $::kohalogdir=$input;
375 unless (-e "$::kohalogdir") {
376 my $result = mkdir 0770, "$::kohalogdir";
378 my @dirs = split(m#/#, $::kohalogdir);
382 unless (-e "$checkdir") {
383 mkdir($checkdir, 0775);
389 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
390 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
391 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
392 chown(0, (getpwnam($httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
393 chown(0, (getpwnam($httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
397 my $kccontents='';open (KC, "/etc/koha.conf");
400 if (/^\s*includes\s*=/) {
401 $kccontents.="includes=$::intranetdir/htdocs/includes\n";
403 } elsif (/^\s*httpduser\s*=/) {
404 $kccontents.="httpduser=$httpduser\n";
405 $kc->{'httpduser'}=1;
406 } elsif (/^\s*kohaversion\s*=/) {
407 $kccontents.="kohaversion=$::newversion\n";
408 $kc->{'kohaversion'}=1;
409 } elsif (/^\s*kohalogdir\s*=/) {
410 $kccontents.="kohalogdir=$::kohalogdir\n";
411 $kc->{'kohalogdir'}=1;
412 } elsif (/^\s*intranetdir\s*=/) {
413 $kccontents.="intranetdir=$::intranetdir\n";
414 $kc->{'intranetdir'}=1;
415 } elsif (/^\s*opacdir\s*=/) {
416 $kccontents.="opacdir=$::opacdir\n";
423 unless (defined($kc->{'kohaversion'})) {
424 $kccontents.="kohaversion=$::newversion\n";
426 unless (defined($kc->{'includes'})) {
427 $kccontents.="includes=$::intranetdir/htdocs/includes\n";
429 unless (defined($kc->{'httpduser'})) {
430 $kccontents.="httpduser=$httpduser\n";
432 unless (defined($kc->{'intranetdir'})) {
433 $kccontents.="intranetdir=$::intranetdir\n";
435 unless (defined($kc->{'opacdir'})) {
436 $kccontents.="opacdir=$::opacdir\n";
438 unless (defined($kc->{'kohalogdir'})) {
439 $kccontents.="kohalogdir=$::kohalogdir\n";
443 system("mv /etc/koha.conf /etc/koha.conf.backup");
445 open (KC, ">/etc/koha.conf") || warn "Couldn't open /etc/koha.conf for writing.";
446 print KC $kccontents;
455 system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
464 This release of Koha has a new authentication module. If you are not already
465 using basic authentication on your intranet, you will be required to log in to
466 access some of the features of the intranet. You can log in using the userid
467 and password from the koha.conf configuration file at any time. Use the
468 "Members" module to add passwords for other accounts and set their permissions.
470 print "Press the <ENTER> key to continue: ";
477 ==========================
478 = Koha Upgrade Completed =
479 ==========================
480 The Koha Upgrade is finished.
481 If you are upgrading from a version of Koha
482 prior to 1.2.1, it is likely that you will have to modify your Apache
483 configuration to point it to the new files.
485 In your INTRANET VirtualHost section you should have:
486 DocumentRoot $::intranetdir/htdocs
487 ScriptAlias /cgi-bin/koha/ $::intranetdir/cgi-bin/
488 SetEnv PERL5LIB $::intranetdir/modules
490 In the OPAC VirtualHost section you should have:
491 DocumentRoot $::opacdir/htdocs
492 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
493 SetEnv PERL5LIB $::intranetdir/modules
495 You may also need to uncomment a "LoadModules env_module ... " line and restart
497 If you're upgrading from 1.2.x version of Koha note that the MARC DB is NOT populated.
500 * Go to Parameters >> Marc structure option and Koha-MARC links option.
501 * Modify default MARC structure to fit your needs.
504 cd /path/to/koha/misc
505 export PERL5LIB=/path/to/koha
507 the old DB is "copied" in the new MARC one.
508 Koha 2.0.0 is ready :-)
510 Please report any problems you encounter through http://bugs.koha.org/
514 my $reply=showmessage('Would you like to complete a survey about your library?', 'yn', 'y');
516 system("perl kohareporter");