[Mapbender-commits] r2834 - branches/spsneo_dev/mapbender/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Aug 15 16:18:55 EDT 2008


Author: spsneo
Date: 2008-08-15 16:18:54 -0400 (Fri, 15 Aug 2008)
New Revision: 2834

Added:
   branches/spsneo_dev/mapbender/update/Install.txt
Modified:
   branches/spsneo_dev/mapbender/update/commandLine.inc
   branches/spsneo_dev/mapbender/update/counter.php
   branches/spsneo_dev/mapbender/update/update.php
   branches/spsneo_dev/mapbender/update/verify_checksum.php
Log:
Documentation updated

Added: branches/spsneo_dev/mapbender/update/Install.txt
===================================================================
--- branches/spsneo_dev/mapbender/update/Install.txt	                        (rev 0)
+++ branches/spsneo_dev/mapbender/update/Install.txt	2008-08-15 20:18:54 UTC (rev 2834)
@@ -0,0 +1,35 @@
+ Requirements
+
+    * PHP 5.1.0 or greater
+    * PHP CLI (Command Line Interface)
+    * PostgreSQL 8.1.x or greater / MySQL 4.8.x
+    * A Mapbender Installation (which has not been customized) 
+
+[edit]
+Instructions
+
+In this whole tutorial, it is assumed that you have downloaded the new Mapbender version in your home directory ('~'), and your old Mapbender version is installed in the directory '/var/www/mapbender' . Replace these path in the following instructions according to your situation.
+
+    * Open a terminal and type in the following: 
+
+$ cd ~/mapbender/update/
+$ php update.php
+
+    * Then the script will ask you the path to the old Mapbender installation. Enter the path accordingly. Here in this example : 
+
+/var/www/mapbender/
+
+    * The script will then automatically check the version of PHP, PostgreSQL/MySQL installed on your system. If the minimum requirements are fulfilled the script will execute further otherwise it will abort giving you a warning message. 
+
+    * Next the script will check the version of Mapbender installed on your system, then it will verify whether it has been customized or not. If the installation has been customized, the routine will abort giving you a warning. 
+
+    * After verifying all the requirements, the script will do the required file-system update without altering your old configurations, followed by a database update. 
+
+    * The script will automatically create a backup of your old Mapbender files in a directory 'mapbender_backup_TIMESTAMP' (where TIMESTAMP is the timestamp when the backup was created). Here in this example backup directory may be : 
+
+/var/www/mapbender_backup_1218225369
+
+    * Your Mapbender installation is now updated. You can now safely delete the directory you downloaded. Here in this example: 
+
+$ rm -rf ~/mapbender
+

Modified: branches/spsneo_dev/mapbender/update/commandLine.inc
===================================================================
--- branches/spsneo_dev/mapbender/update/commandLine.inc	2008-08-15 17:40:26 UTC (rev 2833)
+++ branches/spsneo_dev/mapbender/update/commandLine.inc	2008-08-15 20:18:54 UTC (rev 2834)
@@ -18,11 +18,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# This file tests whether the update script has been called from command line or browser.
-# Aborts the update process if called from a web browser
 
 
+# This file tests whether the update script has been called from command line or browser.
+# Aborts the update process if called from a web browser
 if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
 	echo "This script must be executed from the command line ";
 	exit();

Modified: branches/spsneo_dev/mapbender/update/counter.php
===================================================================
--- branches/spsneo_dev/mapbender/update/counter.php	2008-08-15 17:40:26 UTC (rev 2833)
+++ branches/spsneo_dev/mapbender/update/counter.php	2008-08-15 20:18:54 UTC (rev 2834)
@@ -17,8 +17,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-#This function acts as a counter.
+
+
+#This function acts as a counter. A simple function.
 function print_count($last, $current) {
 	echo str_repeat( chr(8), strlen( $last ) ) . $current;
 	return TRUE;

Modified: branches/spsneo_dev/mapbender/update/update.php
===================================================================
--- branches/spsneo_dev/mapbender/update/update.php	2008-08-15 17:40:26 UTC (rev 2833)
+++ branches/spsneo_dev/mapbender/update/update.php	2008-08-15 20:18:54 UTC (rev 2834)
@@ -35,6 +35,9 @@
 fwrite(STDOUT, "Enter the path to the installed copy of the Mapbender directory.\nExample: /var/www/mapbender/\n");
 $rootdir_path = trim(fgets(STDIN));
 $dir_not_to_scan = array();
+
+# This array contains the list of directory which are not to be scanned for checksums.
+# This array should be consistent with a similar array in build-checksum.php in the build directory.
 array_push($dir_not_to_scan,".", "..", "conf", "license", "log", "update");
 
 //remove slash if it is there at the end of the path
@@ -87,6 +90,8 @@
 		verify_checksum($dir_to_scan_path);
 	}
 }
+
+# This indicates any file consistency error.
 $update_error = count($customized_modules);
 if($update_error > 0) {
 	echo "Some errors have been detected.\nProbably the administrator has customized the Mapbender Installation.\n";
@@ -113,10 +118,17 @@
 echo "\n\n--------------------------\nMapbender Updater: Copying new files in your installation directory ".$rootdir_path."\n";
 
 $dir_not_to_copy = array();
+
+# This is an array of directories which are not to be replaced in the old installation.
+# conf is not being replaced as it contains the configurations.
+# log is not being replaced as it contains the old log files.
+# update is not being copied. 
+# Any more directory can be further added.
 array_push($dir_not_to_copy,".", "..", "conf", "log", "update");
 
 $root_dir_to_copy = dir(realpath(dirname(__FILE__)."/.."));
 
+# This loop replaces the olde mb directory with the new ones.
 while(false !== ($dir_to_copy = $root_dir_to_copy->read())) {
 	$dir_to_copy_path = $root_dir_to_copy->path."/".$dir_to_copy;
 	#directories to scan, hidden directories excluded
@@ -131,6 +143,7 @@
 
 echo "\n\n--------------------------\nMapbender Updater:Updating Database...\n";
 
+# This function update the database.
 do_db_updates();
 
 echo "\nAll Database Updates Done\n";

Modified: branches/spsneo_dev/mapbender/update/verify_checksum.php
===================================================================
--- branches/spsneo_dev/mapbender/update/verify_checksum.php	2008-08-15 17:40:26 UTC (rev 2833)
+++ branches/spsneo_dev/mapbender/update/verify_checksum.php	2008-08-15 20:18:54 UTC (rev 2834)
@@ -20,24 +20,30 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 #This function verifies the checksum of each file scanning the directories recursively
+# $dir_path is the directory to scan
 function verify_checksum($dir_path) {
 	
+# Global variable, which defines the folder not to be scanned as they may be config folders or log folders.
 	global $customized_modules;
+	
+# Define two arrays. $file_arr for all the files in $dir_path and their current checksum.
+# $checksum_array for all the files and the corresponding original checksum as extracted from the file checksum.json . 
 	$file_arr = array();
 	$checksum_array = array();
 	
-	//remove slash if it is there at the end of the path
+# remove slash if it is there at the end of the path
 	if(substr($dir_path, -1) == '/') {
 		$dir_path = substr($dir_path, 0 , -1);
 	}
 	
-	
+# Verifies whether the directory is executable.
 	if(!is_readable($dir_path)) {
 		echo $dir_path." is not readable.\nPlease make sure you have privilege to update.\nAborting...\n";
 		exit();
 	}
 	
-	
+# Checks whether the file checksum.json exists or not. If it doesnt exist, the function returns back with a boolean false.
+# If the file checksum.json exists, entire filename and their original checksum values are stored in the array $checksum_array
 	if(!is_file($dir_path.'/checksum.json')) {
 		echo "The checksum.json file does not exist in ".$dir_path.". Probably the administrator has customized the installation.\n";
 		$customized_modules[] = $dir_path;
@@ -47,9 +53,13 @@
 		$checksum_array = json_decode($file_string, true);
 	}
 	
+# Opens the directory $dir_path 
 	$directory = dir($dir_path);
+# Scan the directory $dir_path
 	while(false !== ($file = $directory->read())) {
+# path of the file being scanned is stored in the variable $file_path
 		$file_path = $dir_path.'/'.$file;
+# If the file is checksum.json or if it starts with '.' or ends with '~' it is not considered. Otherwise its current checksum is stored in the variable $file_arr
 		if(is_file($file_path) && $file != 'checksum.json' && !preg_match("/~$/", $file) && !preg_match("/^\./", $file)) {
 			if(is_readable($file_path)) {
 				$file_arr[$file] = sha1_file($file_path);
@@ -57,6 +67,7 @@
 				echo $file_path."is not readable.\nPlease make sure you have privilege to update.\nAborting...\n";
 				exit();
 			}
+# If the file is a directory, it is further scanned. (Recursion !!)
 		} else if (is_dir($file_path) && !preg_match("/^\./", $file)) {
 			if($file != '.' && $file != '..' ) {
 				verify_checksum($file_path);



More information about the Mapbender_commits mailing list