4 use strict; # please develop with the strict pragma
8 print "\n\nYou must run koha.upgrade as root.\n\n";
19 ($kohaversion) || ($kohaversion='unknown version');
20 my $newversion=`cat koha.version`;
22 if ($::kohaversion =~ /RC/) {
23 releasecandidatewarning();
32 You are attempting to upgrade from Koha $kohaversion to $newversion.
34 We recommend that you do a complete backup of all your files before upgrading.
35 This upgrade script will make a backup copy of your files for you.
37 Would you like to proceed? ([Y]/N):
43 if ($answer eq "Y" || $answer eq "y") {
44 print "Great! continuing upgrade... \n";
48 Aborting. Please re-run koha.upgrade when you are ready to upgrade Koha.
59 my $backupdir='/usr/local/koha/backups';
60 print "Please specify a backup directory [$backupdir]: ";
69 if (! -e $backupdir) {
70 my $result=mkdir ($backupdir, oct(770));
72 my @dirs = split(m#/#, $backupdir);
76 unless (-e "$checkdir") {
77 mkdir($checkdir, 0775);
83 chmod 0770, $backupdir;
85 # Backup MySql database
91 foreach my $mysql (qw(/usr/local/mysql
104 my ($sec, $min, $hr, $day, $month, $year) = (localtime(time))[0,1,2,3,4,5];
107 my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, $day,$hr,$min,$sec;
109 open (MD, "$mysqldir/bin/mysqldump --user=$user --password=$pass --host=$hostname $database|");
111 (open BF, ">$backupdir/Koha.backup_$date") || (die "Error opening up backup file $backupdir/Koha.backup_$date: $!\n");
115 my $biblioitemcounter=0;
119 (/insert into items /i) && ($itemcounter++);
120 (/insert into biblioitems /i) && ($biblioitemcounter++);
121 (/insert into biblio /i) && ($bibliocounter++);
122 (/insert into borrowers /i) && ($membercounter++);
130 my $filels=`ls -hl $backupdir/Koha.backup_$date`;
137 %6d biblioitems entries
143 Does this look right? ([Y]/N):
144 |, $bibliocounter, $biblioitemcounter, $itemcounter, $membercounter;
149 if ($answer=~/^n/i) {
152 Aborting. The database dump is located in:
154 $backupdir/Koha.backup_$date
159 print "Great! continuing upgrade... \n";
164 if ($opacdir && $intranetdir) {
167 I believe that your old files are located in:
170 INTRANET: $intranetdir
173 Does this look right? ([Y]/N):
178 if ($answer =~/n/i) {
182 print "Great! continuing upgrade... \n";
187 if (!$opacdir || !$intranetdir) {
190 while (!$intranetdir) {
191 print "Please specify the location of your INTRANET files: ";
197 $intranetdir=$answer;
199 if (! -e "$intranetdir/htdocs") {
200 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
205 print "Please specify the location of your OPAC files: ";
213 if (! -e "$opacdir/htdocs") {
214 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
222 print "\n\nBacking up old Koha scripts...\n";
223 print "===============================\n\n";
225 mkdir "$backupdir/kohafiles-$date", 0770;
226 mkdir "$backupdir/kohafiles-$date/intranet", 0770;
227 mkdir "$backupdir/kohafiles-$date/opac", 0770;
229 my $result=system("cp -R $intranetdir/* $backupdir/kohafiles-$date/intranet/");
231 print "Error encounted when copying $intranetdir to $backupdir/kohafiles-$date/intranet/\n";
234 system("rm -rf $intranetdir/*");
236 $result=system("cp -R $opacdir/* $backupdir/kohafiles-$date/opac/");
238 print "Error encounted when copying $opacdir to $backupdir/kohafiles-$date/opac/\n";
241 system("rm -rf $opacdir/*");
244 print "Creating $intranetdir/htdocs...\n";
245 mkdir ("$intranetdir/htdocs", oct(750));
246 print "Creating $intranetdir/cgi-bin...\n";
247 mkdir ("$intranetdir/cgi-bin", oct(750));
248 print "Creating $intranetdir/modules...\n";
249 mkdir ("$intranetdir/modules", oct(750));
250 print "Creating $intranetdir/scripts...\n";
251 mkdir ("$intranetdir/scripts", oct(750));
252 chmod (oct(770), "$opacdir");
253 print "Creating $opacdir/htdocs...\n";
254 mkdir ("$opacdir/htdocs", oct(750));
255 print "Creating $opacdir/cgi-bin...\n";
256 mkdir ("$opacdir/cgi-bin", oct(750));
261 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
262 /usr/local/etc/apache/httpd.conf
263 /usr/local/etc/apache/apache.conf
264 /var/www/conf/httpd.conf
265 /etc/apache/conf/httpd.conf
266 /etc/apache/conf/apache.conf
267 /etc/apache-ssl/conf/apache.conf
268 /etc/httpd/conf/httpd.conf
269 /etc/httpd/httpd.conf)) {
270 if ( -f $httpdconf ) {
271 $realhttpdconf=$httpdconf;
272 open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to open $httpdconf for reading.\n";
273 while (<HTTPDCONF>) {
274 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
282 unless ($httpduser) {
284 I was not able to determine the user that Apache is running as. This
285 information is necessary in order to set the access privileges correctly on
286 /etc/koha.conf. This user should be set in one of the Apache configuration
287 files using the "User" directive.
289 print "What is your Apache user? ";
290 chomp($input = <STDIN>);
295 $httpduser='Undetermined';
299 print "\n\nINSTALLING KOHA...\n";
300 print "\n\n==================\n";
301 print "Copying internet-html files to $intranetdir/htdocs...\n";
302 system("cp -R intranet-html/* $intranetdir/htdocs/");
303 print "Copying intranet-cgi files to $intranetdir/cgi-bin...\n";
304 system("cp -R intranet-cgi/* $intranetdir/cgi-bin/");
305 print "Copying script files to $intranetdir/scripts...\n";
306 system("cp -R scripts/* $intranetdir/scripts/");
307 print "Copying module files to $intranetdir/modules...\n";
308 system("cp -R modules/* $intranetdir/modules/");
309 print "Copying opac-html files to $opacdir/htdocs...\n";
310 system("cp -R opac-html/* $opacdir/htdocs/");
311 print "Copying opac-cgi files to $opacdir/cgi-bin...\n";
312 system("cp -R opac-cgi/* $opacdir/cgi-bin/");
314 system("chown -R root.$httpduser $opacdir");
315 system("chown -R root.$httpduser $intranetdir");
318 unless ($kohalogdir && -e $kohalogdir) {
319 $kohalogdir='/var/log/koha';
320 print "\n\nDirectory for logging by Z39.50 daemon [$kohalogdir]: ";
321 chomp($input = <STDIN>);
327 unless (-e "$kohalogdir") {
328 my $result = mkdir 0770, "$kohalogdir";
330 my @dirs = split(m#/#, $kohalogdir);
334 unless (-e "$checkdir") {
335 mkdir($checkdir, 0775);
341 chmod 0750, "$intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
342 chmod 0750, "$intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
343 chmod 0750, "$intranetdir/scripts/z3950daemon/processz3950queue";
344 chown(0, (getpwnam($httpduser)) [3], "$intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
345 chown(0, (getpwnam($httpduser)) [3], "$intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $intranetdir/scripts/z3950daemon/processz3950queue: $!";
348 open (KC, "/etc/koha.conf");
352 if (/^\s*includes\s*=/) {
353 $kccontents.="includes=$intranetdir/htdocs/includes\n";
355 } elsif (/^\s*httpduser\s*=/) {
356 $kccontents.="httpduser=$httpduser\n";
357 $kc->{'httpduser'}=1;
358 } elsif (/^\s*kohaversion\s*=/) {
359 $kccontents.="kohaversion=$newversion\n";
360 $kc->{'kohaversion'}=1;
361 } elsif (/^\s*kohalogdir\s*=/) {
362 $kccontents.="kohalogdir=$kohalogdir\n";
363 $kc->{'kohalogdir'}=1;
364 } elsif (/^\s*intranetdir\s*=/) {
365 $kccontents.="intranetdir=$intranetdir\n";
366 $kc->{'intranetdir'}=1;
367 } elsif (/^\s*opacdir\s*=/) {
368 $kccontents.="opacdir=$opacdir\n";
375 unless (defined($kc->{'kohaversion'})) {
376 $kccontents.="kohaversion=$newversion\n";
378 unless (defined($kc->{'includes'})) {
379 $kccontents.="includes=$intranetdir/htdocs/includes\n";
381 unless (defined($kc->{'httpduser'})) {
382 $kccontents.="httpduser=$httpduser\n";
384 unless (defined($kc->{'intranetdir'})) {
385 $kccontents.="intranetdir=$intranetdir\n";
387 unless (defined($kc->{'opacdir'})) {
388 $kccontents.="opacdir=$opacdir\n";
390 unless (defined($kc->{'kohalogdir'})) {
391 $kccontents.="kohalogdir=$kohalogdir\n";
395 system("mv /etc/koha.conf /etc/koha.conf.backup");
397 open (KC, ">/etc/koha.conf") || warn "Couldn't open /etc/koha.conf for writing.";
398 print KC $kccontents;
407 system ("perl -I $intranetdir/modules scripts/updater/updatedatabase");
416 This release of Koha has a new authentication module. If you are not already
417 using basic authentication on your intranet, you will be required to log in to
418 access some of the features of the intranet. You can log in using the userid
419 and password from the /etc/koha.conf configuration file at any time. Use the
420 "Members" module to add passwords for other accounts and set their permissions.
422 [NOTE PERMISSIONS ARE NOT COMPLETED AS OF 1.2.3RC1. Do not give passwords to
423 any patrons unless you want them to have full access to your intranet.]
425 print "Press the <ENTER> key to continue: ";
432 ==========================
433 = Koha Upgrade Completed =
434 ==========================
435 The Koha Upgrade is finished. If you are upgrading from a version of Koha
436 prior to 1.2.1, it is likely that you will have to modify your Apache
437 configuration to point it to the new files.
439 In your INTRANET VirtualHost section you should have:
440 DocumentRoot $intranetdir/htdocs
441 ScriptAlias /cgi-bin/koha/ $intranetdir/cgi-bin/
442 SetEnv PERL5LIB $intranetdir/modules
444 In the OPAC VirtualHost section you should have:
445 DocumentRoot $opacdir/htdocs
446 ScriptAlias /cgi-bin/koha/ $opacdir/cgi-bin/
447 SetEnv PERL5LIB $intranetdir/modules
449 You may also need to uncomment a "LoadModules env_module ... " line and restart
452 Please report any problems you encounter through http://bugs.koha.org/