4 use strict; # please develop with the strict pragma
9 print "\n\nYou must run koha.upgrade as root.\n\n";
20 ($::kohaversion) || ($::kohaversion='unknown version');
21 my $newversion=`cat koha.version`;
23 if ($::kohaversion =~ /RC/) {
24 releasecandidatewarning();
33 You are attempting to upgrade from Koha $::kohaversion to $newversion.
35 We recommend that you do a complete backup of all your files before upgrading.
36 This upgrade script will make a backup copy of your files for you.
38 Would you like to proceed? ([Y]/N):
44 if ($answer eq "Y" || $answer eq "y") {
45 print "Great! continuing upgrade... \n";
49 Aborting. Please re-run koha.upgrade when you are ready to upgrade Koha.
60 my $backupdir='/usr/local/koha/backups';
61 print "Please specify a backup directory [$backupdir]: ";
70 if (! -e $backupdir) {
71 my $result=mkdir ($backupdir, oct(770));
73 my @dirs = split(m#/#, $backupdir);
77 unless (-e "$checkdir") {
78 mkdir($checkdir, 0775);
84 chmod 0770, $backupdir;
86 # Backup MySql database
92 foreach my $mysql (qw(/usr/local/mysql
105 my ($sec, $min, $hr, $day, $month, $year) = (localtime(time))[0,1,2,3,4,5];
108 my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, $day,$hr,$min,$sec;
110 open (MD, "$mysqldir/bin/mysqldump --user=$::user --password=$::pass --host=$::hostname $::database|");
112 (open BF, ">$backupdir/Koha.backup_$date") || (die "Error opening up backup file $backupdir/Koha.backup_$date: $!\n");
116 my $biblioitemcounter=0;
120 (/insert into items /i) && ($itemcounter++);
121 (/insert into biblioitems /i) && ($biblioitemcounter++);
122 (/insert into biblio /i) && ($bibliocounter++);
123 (/insert into borrowers /i) && ($membercounter++);
131 my $filels=`ls -hl $backupdir/Koha.backup_$date`;
138 %6d biblioitems entries
144 Does this look right? ([Y]/N):
145 |, $bibliocounter, $biblioitemcounter, $itemcounter, $membercounter;
150 if ($answer=~/^n/i) {
153 Aborting. The database dump is located in:
155 $backupdir/Koha.backup_$date
160 print "Great! continuing upgrade... \n";
165 if ($::opacdir && $::intranetdir) {
168 I believe that your old files are located in:
171 INTRANET: $::intranetdir
174 Does this look right? ([Y]/N):
179 if ($answer =~/n/i) {
183 print "Great! continuing upgrade... \n";
188 if (!$::opacdir || !$::intranetdir) {
191 while (!$::intranetdir) {
192 print "Please specify the location of your INTRANET files: ";
198 $::intranetdir=$answer;
200 if (! -e "$::intranetdir/htdocs") {
201 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
205 while (!$::opacdir) {
206 print "Please specify the location of your OPAC files: ";
214 if (! -e "$::opacdir/htdocs") {
215 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
223 print "\n\nBacking up old Koha scripts...\n";
224 print "===============================\n\n";
226 mkdir "$backupdir/kohafiles-$date", 0770;
227 mkdir "$backupdir/kohafiles-$date/intranet", 0770;
228 mkdir "$backupdir/kohafiles-$date/opac", 0770;
230 my $result=system("cp -R $::intranetdir/* $backupdir/kohafiles-$date/intranet/");
232 print "Error encounted when copying $::intranetdir to $backupdir/kohafiles-$date/intranet/\n";
235 system("rm -rf $::intranetdir/*");
237 $result=system("cp -R $::opacdir/* $backupdir/kohafiles-$date/opac/");
239 print "Error encounted when copying $::opacdir to $backupdir/kohafiles-$date/opac/\n";
242 system("rm -rf $::opacdir/*");
245 print "Creating $::intranetdir/htdocs...\n";
246 mkdir ("$::intranetdir/htdocs", oct(750));
247 print "Creating $::intranetdir/cgi-bin...\n";
248 mkdir ("$::intranetdir/cgi-bin", oct(750));
249 print "Creating $::intranetdir/modules...\n";
250 mkdir ("$::intranetdir/modules", oct(750));
251 print "Creating $::intranetdir/scripts...\n";
252 mkdir ("$::intranetdir/scripts", oct(750));
253 chmod (oct(770), "$::opacdir");
254 print "Creating $::opacdir/htdocs...\n";
255 mkdir ("$::opacdir/htdocs", oct(750));
256 print "Creating $::opacdir/cgi-bin...\n";
257 mkdir ("$::opacdir/cgi-bin", oct(750));
262 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
263 /usr/local/etc/apache/httpd.conf
264 /usr/local/etc/apache/apache.conf
265 /var/www/conf/httpd.conf
266 /etc/apache/conf/httpd.conf
267 /etc/apache/conf/apache.conf
268 /etc/apache-ssl/conf/apache.conf
269 /etc/httpd/conf/httpd.conf
270 /etc/httpd/httpd.conf)) {
271 if ( -f $httpdconf ) {
272 $realhttpdconf=$httpdconf;
273 open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to open $httpdconf for reading.\n";
274 while (<HTTPDCONF>) {
275 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
283 unless ($httpduser) {
285 I was not able to determine the user that Apache is running as. This
286 information is necessary in order to set the access privileges correctly on
287 /etc/koha.conf. This user should be set in one of the Apache configuration
288 files using the "User" directive.
290 print "What is your Apache user? ";
291 chomp($input = <STDIN>);
296 $httpduser='Undetermined';
300 print "\n\nINSTALLING KOHA...\n";
301 print "\n\n==================\n";
302 print "Copying internet-html files to $::intranetdir/htdocs...\n";
303 system("cp -R intranet-html/* $::intranetdir/htdocs/");
304 print "Copying intranet-cgi files to $::intranetdir/cgi-bin...\n";
305 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
306 print "Copying script files to $::intranetdir/scripts...\n";
307 system("cp -R scripts/* $::intranetdir/scripts/");
308 print "Copying module files to $::intranetdir/modules...\n";
309 system("cp -R modules/* $::intranetdir/modules/");
310 print "Copying opac-html files to $::opacdir/htdocs...\n";
311 system("cp -R opac-html/* $::opacdir/htdocs/");
312 print "Copying opac-cgi files to $::opacdir/cgi-bin...\n";
313 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
314 system("touch $::opacdir/cgi-bin/opac");
316 system("chown -R root.$httpduser $::opacdir");
317 system("chown -R root.$httpduser $::intranetdir");
320 unless ($::kohalogdir && -e $::kohalogdir) {
321 $::kohalogdir='/var/log/koha';
322 print "\n\nDirectory for logging by Z39.50 daemon [$::kohalogdir]: ";
323 chomp($input = <STDIN>);
325 $::kohalogdir=$input;
329 unless (-e "$::kohalogdir") {
330 my $result = mkdir 0770, "$::kohalogdir";
332 my @dirs = split(m#/#, $::kohalogdir);
336 unless (-e "$checkdir") {
337 mkdir($checkdir, 0775);
343 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
344 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
345 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
346 chown(0, (getpwnam($httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
347 chown(0, (getpwnam($httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
350 open (KC, "/etc/koha.conf");
354 if (/^\s*includes\s*=/) {
355 $kccontents.="includes=$::intranetdir/htdocs/includes\n";
357 } elsif (/^\s*httpduser\s*=/) {
358 $kccontents.="httpduser=$httpduser\n";
359 $kc->{'httpduser'}=1;
360 } elsif (/^\s*kohaversion\s*=/) {
361 $kccontents.="kohaversion=$newversion\n";
362 $kc->{'kohaversion'}=1;
363 } elsif (/^\s*kohalogdir\s*=/) {
364 $kccontents.="kohalogdir=$::kohalogdir\n";
365 $kc->{'kohalogdir'}=1;
366 } elsif (/^\s*intranetdir\s*=/) {
367 $kccontents.="intranetdir=$::intranetdir\n";
368 $kc->{'intranetdir'}=1;
369 } elsif (/^\s*opacdir\s*=/) {
370 $kccontents.="opacdir=$::opacdir\n";
377 unless (defined($kc->{'kohaversion'})) {
378 $kccontents.="kohaversion=$newversion\n";
380 unless (defined($kc->{'includes'})) {
381 $kccontents.="includes=$::intranetdir/htdocs/includes\n";
383 unless (defined($kc->{'httpduser'})) {
384 $kccontents.="httpduser=$httpduser\n";
386 unless (defined($kc->{'intranetdir'})) {
387 $kccontents.="intranetdir=$::intranetdir\n";
389 unless (defined($kc->{'opacdir'})) {
390 $kccontents.="opacdir=$::opacdir\n";
392 unless (defined($kc->{'kohalogdir'})) {
393 $kccontents.="kohalogdir=$::kohalogdir\n";
397 system("mv /etc/koha.conf /etc/koha.conf.backup");
399 open (KC, ">/etc/koha.conf") || warn "Couldn't open /etc/koha.conf for writing.";
400 print KC $kccontents;
409 system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
418 This release of Koha has a new authentication module. If you are not already
419 using basic authentication on your intranet, you will be required to log in to
420 access some of the features of the intranet. You can log in using the userid
421 and password from the /etc/koha.conf configuration file at any time. Use the
422 "Members" module to add passwords for other accounts and set their permissions.
424 [NOTE PERMISSIONS ARE NOT COMPLETED AS OF 1.2.3RC1. Do not give passwords to
425 any patrons unless you want them to have full access to your intranet.]
427 print "Press the <ENTER> key to continue: ";
434 ==========================
435 = Koha Upgrade Completed =
436 ==========================
437 The Koha Upgrade is finished. If you are upgrading from a version of Koha
438 prior to 1.2.1, it is likely that you will have to modify your Apache
439 configuration to point it to the new files.
441 In your INTRANET VirtualHost section you should have:
442 DocumentRoot $::intranetdir/htdocs
443 ScriptAlias /cgi-bin/koha/ $::intranetdir/cgi-bin/
444 SetEnv PERL5LIB $::intranetdir/modules
446 In the OPAC VirtualHost section you should have:
447 DocumentRoot $::opacdir/htdocs
448 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
449 SetEnv PERL5LIB $::intranetdir/modules
451 You may also need to uncomment a "LoadModules env_module ... " line and restart
454 Please report any problems you encounter through http://bugs.koha.org/