koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha koha.upgrade,1.1.2.1,1.1.2.2


From: Steve Tonnesen
Subject: [Koha-cvs] CVS: koha koha.upgrade,1.1.2.1,1.1.2.2
Date: Thu, 27 Jun 2002 13:50:39 -0700

Update of /cvsroot/koha/koha
In directory usw-pr-cvs1:/tmp/cvs-serv11769

Modified Files:
      Tag: rel-1-2
        koha.upgrade 
Log Message:
Functional upgrade script.  This script backs up the Koha database as well as
all of the intranet and opac scripts and html documents before installing new
scripts and html documents and updating the database.


Index: koha.upgrade
===================================================================
RCS file: /cvsroot/koha/koha/Attic/koha.upgrade,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -r1.1.2.1 -r1.1.2.2
*** koha.upgrade        27 Jun 2002 19:31:05 -0000      1.1.2.1
--- koha.upgrade        27 Jun 2002 20:50:37 -0000      1.1.2.2
***************
*** 61,72 ****
  };
  
  
  
  # Backup MySql database
  #
  
- system("mysqldump -u$user -p$pass -h$host $database > Koha.backup");
  open (MD, "mysqldump -u$user -p$pass -h$host $database|");
! open BF, ">Koha.backup";
  
  my $itemcounter=0;
--- 61,102 ----
  };
  
+ my $backupdir='/usr/local/koha/backups';
+ print "Please specify a backup directory [$backupdir]: ";  
  
+ $answer = <STDIN>;
+ chomp $answer;
+ 
+ if ($answer) {
+     $backupdir=$answer;
+ }
+ 
+ if (! -e $backupdir) {
+    my $result=mkdir ($backupdir, oct(770));
+    if ($result==0) {
+        my @dirs = split(m#/#, $backupdir);
+       my $checkdir='';
+       foreach (@dirs) {
+           $checkdir.="$_/";
+           unless (-e "$checkdir") {
+               mkdir($checkdir, 0775);
+           }
+       }
+    }
+ }
+ 
+ chmod 0770, $backupdir;
  
  # Backup MySql database
  #
+ #
+ 
+ my ($sec, $min, $hr, $day, $month, $year) = (localtime(time))[0,1,2,3,4,5];
+ $month++;
+ $year+=1900;
+ my $date= sprintf "%4d-%02d-%02d_%02d:%02d:%02d", $year, $month, 
$day,$hr,$min,$sec;
  
  open (MD, "mysqldump -u$user -p$pass -h$host $database|");
! 
! open BF, ">$backupdir/Koha.backup_$date";
  
  my $itemcounter=0;
***************
*** 87,90 ****
--- 117,122 ----
  
  
+ my $filels=`ls -hl $backupdir/Koha.backup_$date`;
+ chomp $filels;
  printf qq|
  
***************
*** 96,116 ****
  %6d borrowers
  
  Does this look right? ([Y]/N):
  |, $bibliocounter, $biblioitemcounter, $itemcounter, $membercounter;
  
! my $answer = <STDIN>;
  chomp $answer;
  
! if ($answer eq "Y" || $answer eq "y") {
!       print "Great! continuing upgrade... \n";
!     } else {
      print qq|
  
! Aborting.  The database dump is located in the Koha.backup file. 
  |;
      exit;
  };
  
  
  
  
--- 128,297 ----
  %6d borrowers
  
+ $filels
+ 
  Does this look right? ([Y]/N):
  |, $bibliocounter, $biblioitemcounter, $itemcounter, $membercounter;
  
! $answer = <STDIN>;
  chomp $answer;
  
! if ($answer=~/^n/i) {
      print qq|
  
! Aborting.  The database dump is located in:
! 
!       $backupdir/Koha.backup_$date
! 
  |;
      exit;
+ } else {
+       print "Great! continuing upgrade... \n";
  };
  
  
  
+ if ($opacdir && $intranetdir) {
+     print qq|
+ 
+ I believe that your old files are located in:
+ 
+   OPAC:      $opacdir
+   INTRANET:  $intranetdir
+ 
+ 
+ Does this look right?  ([Y]/N):
+ |;
+     $answer = <STDIN>;
+     chomp $answer;
+ 
+     if ($answer =~/n/i) {
+       $intranetdir='';
+       $opacdir='';
+     } else {
+       print "Great! continuing upgrade... \n";
+     }
+ }
+ 
+ 
+ if (!$opacdir || !$intranetdir) {
+     $intranetdir='';
+     $opacdir='';
+     while (!$intranetdir) {
+       print "Please specify the location of your INTRANET files: ";  
+ 
+       $answer = <STDIN>;
+       chomp $answer;
+ 
+       if ($answer) {
+           $intranetdir=$answer;
+       }
+       if (! -e "$intranetdir/htdocs") {
+           print "\nCouldn't find the htdocs directory here.  That doesn't 
look right.\nPlease enter another location.\n\n";
+           $intranetdir='';
+       }
+     }
+     while (!$opacdir) {
+       print "Please specify the location of your OPAC files: ";  
+ 
+       $answer = <STDIN>;
+       chomp $answer;
+ 
+       if ($answer) {
+           $opacdir=$answer;
+       }
+       if (! -e "$opacdir/htdocs") {
+           print "\nCouldn't find the htdocs directory here.  That doesn't 
look right.\nPlease enter another location.\n\n";
+           $opacdir='';
+       }
+     }
+ }
+ 
+ 
+ 
+ print "\n\nBacking up old Koha scripts...\n";
+ print     "===============================\n\n";
+ 
+ mkdir "$backupdir/kohafiles-$date", 0770;
+ mkdir "$backupdir/kohafiles-$date/intranet", 0770;
+ mkdir "$backupdir/kohafiles-$date/opac", 0770;
+ 
+ my $result=system("cp -R $intranetdir/* 
$backupdir/kohafiles-$date/intranet/");
+ if ($result) {
+     print "Error encounted when copying $intranetdir to 
$backupdir/kohafiles-$date/intranet/\n";
+     exit;
+ } else {
+     system("rm -rf $intranetdir/*");
+ }
+ $result=system("cp -R $opacdir/* $backupdir/kohafiles-$date/opac/");
+ if ($result) {
+     print "Error encounted when copying $opacdir to 
$backupdir/kohafiles-$date/opac/\n";
+     exit;
+ } else {
+     system("rm -rf $opacdir/*");
+ }
+ 
+    print "Creating $intranetdir/htdocs...\n";
+    mkdir ("$intranetdir/htdocs", oct(750));
+    print "Creating $intranetdir/cgi-bin...\n";
+    mkdir ("$intranetdir/cgi-bin", oct(750));
+    print "Creating $intranetdir/modules...\n";
+    mkdir ("$intranetdir/modules", oct(750));
+    print "Creating $intranetdir/scripts...\n";
+    mkdir ("$intranetdir/scripts", oct(750));
+    chmod (oct(770), "$opacdir");
+    print "Creating $opacdir/htdocs...\n";
+    mkdir ("$opacdir/htdocs", oct(750));
+    print "Creating $opacdir/cgi-bin...\n";
+    mkdir ("$opacdir/cgi-bin", oct(750));
+ 
+ my $httpduser;
+ my $realhttpdconf;
+ 
+ foreach my $httpdconf (qw(/usr/local/apache/conf/httpd.conf
+                       /usr/local/etc/apache/httpd.conf
+                       /usr/local/etc/apache/apache.conf
+                       /var/www/conf/httpd.conf
+                       /etc/apache/conf/httpd.conf
+                       /etc/apache/conf/apache.conf
+                       /etc/apache-ssl/conf/apache.conf
+                       /etc/httpd/conf/httpd.conf
+                       /etc/httpd/httpd.conf)) {
+    if ( -f $httpdconf ) {
+             $realhttpdconf=$httpdconf;
+             open (HTTPDCONF, $httpdconf) or warn "Insufficient privileges to 
open $httpdconf for reading.\n";
+       while (<HTTPDCONF>) {
+          if (/^\s*User\s+"?([-\w]+)"?\s*$/) {
+             $httpduser = $1;
+          }
+       }
+       close(HTTPDCONF);
+    }
+ }
+ $httpduser ||= 'Undetermined';
+ 
+ print "\n\nINSTALLING KOHA...\n";
+ print "\n\n==================\n";
+ print "Copying internet-html files to $intranetdir/htdocs...\n";
+ system("cp -R intranet-html/* $intranetdir/htdocs/");
+ print "Copying intranet-cgi files to $intranetdir/cgi-bin...\n";
+ system("cp -R intranet-cgi/* $intranetdir/cgi-bin/");
+ print "Copying script files to $intranetdir/scripts...\n";
+ system("cp -R scripts/* $intranetdir/scripts/");
+ print "Copying module files to $intranetdir/modules...\n";
+ system("cp -R modules/* $intranetdir/modules/");
+ print "Copying opac-html files to $opacdir/htdocs...\n";
+ system("cp -R opac-html/* $opacdir/htdocs/");
+ print "Copying opac-cgi files to $opacdir/cgi-bin...\n";
+ system("cp -R opac-cgi/* $opacdir/cgi-bin/");
+ 
+ system("chown -R root.$httpduser $opacdir");
+ system("chown -R root.$httpduser $intranetdir");
+ 
+ 
+ print qq|
+ 
+ Upgrading Database
+ ==================
+ |;
+ system ("perl -I $intranetdir/modules scripts/updater/updatedatabase");
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]