4 use strict; # please develop with the strict pragma
10 print "\n\nYou must run koha.upgrade as root.\n\n";
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):
48 Aborting. Please re-run koha.upgrade when you are ready to upgrade Koha.
52 print "Great! continuing upgrade... \n";
61 my $backupdir='/usr/local/koha/backups';
62 print "Please specify a backup directory [$backupdir]: ";
71 if (! -e $backupdir) {
72 my $result=mkdir ($backupdir, oct(770));
74 my @dirs = split(m#/#, $backupdir);
78 unless (-e "$checkdir") {
79 mkdir($checkdir, 0775);
85 chmod 0770, $backupdir;
87 # Backup MySql database
93 foreach my $mysql (qw(/usr/local/mysql
106 my ($sec, $min, $hr, $day, $month, $year) = (localtime(time))[0,1,2,3,4,5];
109 my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, $day,$hr,$min,$sec;
111 open (MD, "$mysqldir/bin/mysqldump --user=$::user --password=$::pass --host=$::hostname $::database|");
113 (open BF, ">$backupdir/Koha.backup_$date") || (die "Error opening up backup file $backupdir/Koha.backup_$date: $!\n");
117 my $biblioitemcounter=0;
121 (/insert into items /i) && ($itemcounter++);
122 (/insert into biblioitems /i) && ($biblioitemcounter++);
123 (/insert into biblio /i) && ($bibliocounter++);
124 (/insert into borrowers /i) && ($membercounter++);
132 my $filels=`ls -hl $backupdir/Koha.backup_$date`;
139 %6d biblioitems entries
145 Does this look right? ([Y]/N):
146 |, $bibliocounter, $biblioitemcounter, $itemcounter, $membercounter;
151 if ($answer=~/^n/i) {
154 Aborting. The database dump is located in:
156 $backupdir/Koha.backup_$date
161 print "Great! continuing upgrade... \n";
166 if ($::opacdir && $::intranetdir) {
169 I believe that your old files are located in:
172 INTRANET: $::intranetdir
175 Does this look right? ([Y]/N):
180 if ($answer =~/n/i) {
184 print "Great! continuing upgrade... \n";
189 if (!$::opacdir || !$::intranetdir) {
192 while (!$::intranetdir) {
193 print "Please specify the location of your INTRANET files: ";
199 $::intranetdir=$answer;
201 if (! -e "$::intranetdir/htdocs") {
202 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
206 while (!$::opacdir) {
207 print "Please specify the location of your OPAC files: ";
215 if (! -e "$::opacdir/htdocs") {
216 print "\nCouldn't find the htdocs directory here. That doesn't look right.\nPlease enter another location.\n\n";
224 print "\n\nBacking up old Koha scripts...\n";
225 print "===============================\n\n";
227 mkdir "$backupdir/kohafiles-$date", 0770;
228 mkdir "$backupdir/kohafiles-$date/intranet", 0770;
229 mkdir "$backupdir/kohafiles-$date/opac", 0770;
231 my $result=system("cp -R $::intranetdir/* $backupdir/kohafiles-$date/intranet/");
233 print "Error encounted when copying $::intranetdir to $backupdir/kohafiles-$date/intranet/\n";
236 system("rm -rf $::intranetdir/*");
238 $result=system("cp -R $::opacdir/* $backupdir/kohafiles-$date/opac/");
240 print "Error encounted when copying $::opacdir to $backupdir/kohafiles-$date/opac/\n";
243 system("rm -rf $::opacdir/*");
246 print "Creating $::intranetdir/htdocs...\n";
247 mkdir ("$::intranetdir/htdocs", oct(750));
248 print "Creating $::intranetdir/cgi-bin...\n";
249 mkdir ("$::intranetdir/cgi-bin", oct(750));
250 print "Creating $::intranetdir/modules...\n";
251 mkdir ("$::intranetdir/modules", oct(750));
252 print "Creating $::intranetdir/scripts...\n";
253 mkdir ("$::intranetdir/scripts", oct(750));
254 chmod (oct(770), "$::opacdir");
255 print "Creating $::opacdir/htdocs...\n";
256 mkdir ("$::opacdir/htdocs", oct(750));
257 print "Creating $::opacdir/cgi-bin...\n";
258 mkdir ("$::opacdir/cgi-bin", oct(750));
263 foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
264 /usr/local/etc/apache/httpd.conf
265 /usr/local/etc/apache/apache.conf
266 /var/www/conf/httpd.conf
267 /etc/apache/conf/httpd.conf
268 /etc/apache/conf/apache.conf
269 /etc/apache-ssl/conf/apache.conf
270 /etc/httpd/conf/httpd.conf
271 /etc/httpd/httpd.conf)) {
272 if ( -f $httpdconf ) {
273 $realhttpdconf=$httpdconf;
274 open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to open $httpdconf for reading.\n";
275 while (<HTTPDCONF>) {
276 if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
284 unless ($httpduser) {
286 I was not able to determine the user that Apache is running as. This
287 information is necessary in order to set the access privileges correctly on
288 /etc/koha.conf. This user should be set in one of the Apache configuration
289 files using the "User" directive.
291 print "What is your Apache user? ";
292 chomp($input = <STDIN>);
297 $httpduser='Undetermined';
301 print "\n\nINSTALLING KOHA...\n";
302 print "\n\n==================\n";
303 print "Copying internet-html files to $::intranetdir/htdocs...\n";
304 system("cp -R intranet-html/* $::intranetdir/htdocs/");
305 print "Copying intranet-cgi files to $::intranetdir/cgi-bin...\n";
306 system("cp -R intranet-cgi/* $::intranetdir/cgi-bin/");
307 print "Copying script files to $::intranetdir/scripts...\n";
308 system("cp -R scripts/* $::intranetdir/scripts/");
309 print "Copying module files to $::intranetdir/modules...\n";
310 system("cp -R modules/* $::intranetdir/modules/");
311 print "Copying opac-html files to $::opacdir/htdocs...\n";
312 system("cp -R opac-html/* $::opacdir/htdocs/");
313 print "Copying opac-cgi files to $::opacdir/cgi-bin...\n";
314 system("cp -R opac-cgi/* $::opacdir/cgi-bin/");
315 system("touch $::opacdir/cgi-bin/opac");
317 system("chown -R root.$httpduser $::opacdir");
318 system("chown -R root.$httpduser $::intranetdir");
321 unless ($::kohalogdir && -e $::kohalogdir) {
322 $::kohalogdir='/var/log/koha';
323 print "\n\nDirectory for logging by Z39.50 daemon [$::kohalogdir]: ";
324 chomp($input = <STDIN>);
326 $::kohalogdir=$input;
330 unless (-e "$::kohalogdir") {
331 my $result = mkdir 0770, "$::kohalogdir";
333 my @dirs = split(m#/#, $::kohalogdir);
337 unless (-e "$checkdir") {
338 mkdir($checkdir, 0775);
344 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-launch.sh";
345 chmod 0750, "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh";
346 chmod 0750, "$::intranetdir/scripts/z3950daemon/processz3950queue";
347 chown(0, (getpwnam($httpduser)) [3], "$::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh") or warn "can't chown $::intranetdir/scripts/z3950daemon/z3950-daemon-shell.sh: $!";
348 chown(0, (getpwnam($httpduser)) [3], "$::intranetdir/scripts/z3950daemon/processz3950queue") or warn "can't chown $::intranetdir/scripts/z3950daemon/processz3950queue: $!";
351 open (KC, "/etc/koha.conf");
355 if (/^\s*includes\s*=/) {
356 $kccontents.="includes=$::intranetdir/htdocs/includes\n";
358 } elsif (/^\s*httpduser\s*=/) {
359 $kccontents.="httpduser=$httpduser\n";
360 $kc->{'httpduser'}=1;
361 } elsif (/^\s*kohaversion\s*=/) {
362 $kccontents.="kohaversion=$::newversion\n";
363 $kc->{'kohaversion'}=1;
364 } elsif (/^\s*kohalogdir\s*=/) {
365 $kccontents.="kohalogdir=$::kohalogdir\n";
366 $kc->{'kohalogdir'}=1;
367 } elsif (/^\s*intranetdir\s*=/) {
368 $kccontents.="intranetdir=$::intranetdir\n";
369 $kc->{'intranetdir'}=1;
370 } elsif (/^\s*opacdir\s*=/) {
371 $kccontents.="opacdir=$::opacdir\n";
378 unless (defined($kc->{'kohaversion'})) {
379 $kccontents.="kohaversion=$::newversion\n";
381 unless (defined($kc->{'includes'})) {
382 $kccontents.="includes=$::intranetdir/htdocs/includes\n";
384 unless (defined($kc->{'httpduser'})) {
385 $kccontents.="httpduser=$httpduser\n";
387 unless (defined($kc->{'intranetdir'})) {
388 $kccontents.="intranetdir=$::intranetdir\n";
390 unless (defined($kc->{'opacdir'})) {
391 $kccontents.="opacdir=$::opacdir\n";
393 unless (defined($kc->{'kohalogdir'})) {
394 $kccontents.="kohalogdir=$::kohalogdir\n";
398 system("mv /etc/koha.conf /etc/koha.conf.backup");
400 open (KC, ">/etc/koha.conf") || warn "Couldn't open /etc/koha.conf for writing.";
401 print KC $kccontents;
410 system ("perl -I $::intranetdir/modules scripts/updater/updatedatabase");
419 This release of Koha has a new authentication module. If you are not already
420 using basic authentication on your intranet, you will be required to log in to
421 access some of the features of the intranet. You can log in using the userid
422 and password from the /etc/koha.conf configuration file at any time. Use the
423 "Members" module to add passwords for other accounts and set their permissions.
425 [NOTE PERMISSIONS ARE NOT COMPLETED AS OF 1.2.3RC1. Do not give passwords to
426 any patrons unless you want them to have full access to your intranet.]
428 print "Press the <ENTER> key to continue: ";
435 ==========================
436 = Koha Upgrade Completed =
437 ==========================
438 The Koha Upgrade is finished. If you are upgrading from a version of Koha
439 prior to 1.2.1, it is likely that you will have to modify your Apache
440 configuration to point it to the new files.
442 In your INTRANET VirtualHost section you should have:
443 DocumentRoot $::intranetdir/htdocs
444 ScriptAlias /cgi-bin/koha/ $::intranetdir/cgi-bin/
445 SetEnv PERL5LIB $::intranetdir/modules
447 In the OPAC VirtualHost section you should have:
448 DocumentRoot $::opacdir/htdocs
449 ScriptAlias /cgi-bin/koha/ $::opacdir/cgi-bin/
450 SetEnv PERL5LIB $::intranetdir/modules
452 You may also need to uncomment a "LoadModules env_module ... " line and restart
455 Please report any problems you encounter through http://bugs.koha.org/
459 my $reply=showmessage('Would you like to complete a survey about your library?', 'yn', 'y');
461 system("perl kohareporter");