[Mapbender-commits] r2757 - branches/spsneo_dev/mapbender/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Aug 8 16:04:50 EDT 2008
Author: spsneo
Date: 2008-08-08 16:04:50 -0400 (Fri, 08 Aug 2008)
New Revision: 2757
Modified:
branches/spsneo_dev/mapbender/update/update.php
Log:
Filesystem update script integrated with db update script
Modified: branches/spsneo_dev/mapbender/update/update.php
===================================================================
--- branches/spsneo_dev/mapbender/update/update.php 2008-08-08 20:03:27 UTC (rev 2756)
+++ branches/spsneo_dev/mapbender/update/update.php 2008-08-08 20:04:50 UTC (rev 2757)
@@ -22,25 +22,118 @@
require_once("commandLine.inc");
require_once("update-utils.inc");
require_once("updaters.inc");
-include_once(dirname(__FILE__)."/../conf/mapbender.conf");
+require_once("counter.php");
+require_once("verify_checksum.php");
+
+
+#Some global variables
+$customized_modules = array();
+
+# Ask the user for the Installed Mapbender Directory
+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();
+array_push($dir_not_to_scan,".", "..", "conf", "license", "log", "resources", "update");
+
+//remove slash if it is there at the end of the path
+if(substr($rootdir_path, -1) == '/') {
+ $rootdir_path = substr($rootdir_path, 0 , -1);
+}
+
+#check whether this is a valid directory
+if(!is_dir($rootdir_path)) {
+ echo $rootdir_path." is not a valid directory\n";
+ return FALSE;
+}
+
+#check whether this directory is readable
+if(!is_readable($rootdir_path)) {
+ echo $rootdir_path." is not readable.\nPlease make sure you have privilege to update.\nAborting...\n";
+ exit();
+}
+
+#check whether the directory contains the conf file.
+if(!is_file($rootdir_path.'/conf/mapbender.conf')) {
+ echo $rootdir_path."/conf/mapbender.conf does not exist. This is the main configuration file for any installed mapbender directory.\nEither you have entered a wrong mapbender directory or the software is not installed properly on your system.\nPlease execute this update script again to enter the correct path.\nDieing....\n";
+ exit();
+}
+
+include_once($rootdir_path."/conf/mapbender.conf");
+
+#Starting the Mapbender Update Routine
echo "Mapbender Updater\n\n--------------------------\n\n";
-do_version_check();
-
-echo "\n---------------------------\nGoing to run database updates for mapbender\n";
-echo "Depending upon the size of your database this may take a while\n\n";
-echo "If you wish to abort press control ctrl+c within next 5 seconds...";
-require_once("counter.php");
+echo "Depending on the size of your database and filesystem This may take a while\n\n";
+echo "If you wish to abort please press ctrl+c within next 5 seconds...\n";
for ($i = 6; $i >= 1;) {
print_count($i, --$i);
sleep(1);
}
-echo "\n";
-echo "Updating Database...\n";
+#Check the version of PHP and Database
+echo "\n\n--------------------------\nMapbender Updater: Checking the PHP and Database version installed on your system...\n";
+do_version_check();
+
+#Check the file system consistency by verifying the checksums.
+echo "\n\n--------------------------\nMapbender Updater: Checking the installed version of Mapbender for inconsistency\n..........\n";
+#initialize the directory
+$rootdir = dir($rootdir_path);
+
+while(false !== ($dir_to_scan = $rootdir->read())) {
+ $dir_to_scan_path = $rootdir_path.'/'.$dir_to_scan;
+ #directories to scan, hidden directories excluded
+ if(is_dir($dir_to_scan_path) && !in_array($dir_to_scan, $dir_not_to_scan) && !preg_match("/^\./", $dir_to_scan)) {
+ verify_checksum($dir_to_scan_path);
+ }
+}
+$update_error = count($customized_modules);
+if($update_error > 0) {
+ echo "Some errors have been detected.\nProbably the administrator has customized the Mapbender Installation.\n";
+ echo "The update script cannot update your installation.\n";
+ echo "Errors in following directory has been detected :\n";
+ foreach($customized_modules as $error_module) {
+ echo $error_module."\n";
+ }
+ echo "\nAborting...\n";
+ exit(0);
+}
+
+//Create backup of the existing mapbender installation
+echo "\n\n--------------------------\nMapbender Updater: Creating backup of the current installation.\n";
+$rootdir_name = basename($rootdir_path);
+$backupdir_name = $rootdir_name."_backup_".time();
+$backupdir_path = dirname($rootdir_path)."/".$backupdir_name;
+rename($rootdir_path, $backupdir_path);
+mkdir($rootdir_path);
+chmod($rootdir_path, 0755);
+copydir($backupdir_path."/conf", $rootdir_path."/conf");
+copydir($backupdir_path."/log", $rootdir_path."/log");
+echo "\n\n--------------------------\nMapbender Updater: Backup created in directory ".$backupdir_path."\n";
+echo "\n\n--------------------------\nMapbender Updater: Copying new files in your installation directory ".$rootdir_path."\n";
+
+$dir_not_to_copy = array();
+array_push($dir_not_to_copy,".", "..", "conf", "log", "update");
+
+$root_dir_to_copy = dir(realpath(dirname(__FILE__)."/.."));
+
+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
+ if(is_dir($dir_to_copy_path) && !in_array($dir_to_copy, $dir_not_to_copy) && !preg_match("/^\./", $dir_to_copy)) {
+ copydir($dir_to_copy_path, $rootdir_path."/".$dir_to_copy);
+ }
+}
+
+echo "\n\n--------------------------\nMapbender Updater: New Mapbender files copied to your installation directory.\n"
+
+
+
+echo "\n\n--------------------------\nMapbender Updater:Updating Database...\n";
+
do_db_updates();
echo "\nAll Database Updates Done\n";
+echo "All updates successfully committed.\n";
?>
More information about the Mapbender_commits
mailing list