diff --git a/bin/scheduler.php b/bin/scheduler.php index a6e622c..c01a094 100644 --- a/bin/scheduler.php +++ b/bin/scheduler.php @@ -42,6 +42,15 @@ require_once(KT_LIB_DIR . '/database/dbutil.inc'); // Set the time limit to 0 to prevent the script timing out set_time_limit(0); +global $default; + +// Check the lock file before starting +$lock = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; +if(file_exists($lock)){ + $default->log->debug('Scheduler: can\'t start - lock file exists'); + exit(0); +} + /* ** Set up functions ** */ @@ -107,11 +116,8 @@ function getTaskList() { return $result; } - /* ** Scheduler script ** */ -global $default; - $default->log->debug('Scheduler: starting'); // Get task list @@ -256,4 +262,4 @@ if (empty($aList)) $default->log->debug('Scheduler: stopping'); -?> +?> \ No newline at end of file diff --git a/setup/upgrade.php b/setup/upgrade.php index a55c100..0c36aeb 100644 --- a/setup/upgrade.php +++ b/setup/upgrade.php @@ -6,31 +6,31 @@ * Document Management Made Simple * Copyright (C) 2008 KnowledgeTree Inc. * Portions copyright The Jam Warehouse Software (Pty) Limited - * + * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, * California 94120-7775, or email info@knowledgetree.com. - * + * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. - * + * * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * KnowledgeTree" logo and retain the original copyright notice. If the display of the * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original + * must display the words "Powered by KnowledgeTree" and retain the original * copyright notice. * Contributor( s): ______________________________________ * @@ -120,24 +120,37 @@ function performAllUpgrades () { break; } } - + return $res; } function performPreUpgradeActions() { - + // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. // It should idealy work the same as the upgrades. - + + global $default; + + // Lock the scheduler + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; + touch($lockFile); return true; } function performPostUpgradeActions() { - + // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. // It should idealy work the same as the upgrades. - + + global $default; + + // Unlock the scheduler + $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; + if(file_exists($lockFile)){ + unlink($lockFile); + } + // Clean out the plugin_helper table $sql = "DELETE FROM plugin_helper"; $res = DBUtil::runQuery($sql); @@ -184,7 +197,7 @@ td { vertical-align: top; } - get('ui/mainLogo')){ echo $oKTConfig->get('ui/mainLogo'); }else{ @@ -219,31 +232,31 @@ switch ($action) case 'Backup': backup(); break; - case 'BackupDone': + case 'BackupDone': backupDone(); - break; - case 'RestoreConfirm': + break; + case 'RestoreConfirm': restoreConfirm(); - break; - case 'RestoreSelect': + break; + case 'RestoreSelect': restoreSelect(); - break; - case 'RestoreSelected': + break; + case 'RestoreSelected': restoreSelected(); - break; - case 'Restore': + break; + case 'Restore': restore(); - break; - case 'RestoreDone': + break; + case 'RestoreDone': restoreDone(); - break; + break; case 'Login': login(); break; case 'LoginProcess': loginProcess(); break; - default: + default: if (!isset($_SESSION['setup_user'])) login(); else @@ -268,26 +281,26 @@ Only administrator users may access the upgrade wizard. -get('backup/mysqlDirectory',$mysqldir); - $dirs[] = $mysqldir; - + $dirs[] = $mysqldir; + if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin'); } - + foreach($dirs as $dir) { if (is_file($dir . '/' . $mysqlname)) @@ -349,7 +362,7 @@ function resolveMysqlDir() return $dir; } } - + return ''; } @@ -362,18 +375,18 @@ function create_backup_stmt($targetfile=null) $adminPwd = $oKTConfig->get('db/dbAdminPass'); $dbHost = $oKTConfig->get('db/dbHost'); $dbName = $oKTConfig->get('db/dbName'); - + $dbPort = trim($oKTConfig->get('db/dbPort')); if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); if (empty($dbPort)) $dbPort='3306'; $dbSocket = trim($oKTConfig->get('db/dbSocket')); if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; - + $date=date('Y-m-d-H-i-s'); $dir=resolveMysqlDir(); - + $info['dir']=$dir; $prefix=''; @@ -381,28 +394,28 @@ function create_backup_stmt($targetfile=null) { $prefix .= "./"; } - + if (@stat($dbSocket) !== false) { $mechanism="--socket=\"$dbSocket\""; } - else + else { $mechanism="--port=\"$dbPort\""; } - + $tmpdir=resolveTempDir(); - + if (is_null($targetfile)) { $targetfile="$tmpdir/kt-backup-$date.sql"; } - + $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; $info['display']=$stmt; $info['target']=$targetfile; - + $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; $info['cmd']=$stmt; return $info; @@ -424,7 +437,7 @@ function create_restore_stmt($targetfile) if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; $dir=resolveMysqlDir(); - + $info['dir']=$dir; $prefix=''; @@ -432,29 +445,29 @@ function create_restore_stmt($targetfile) { $prefix .= "./"; } - + if (@stat($dbSocket) !== false) { $mechanism="--socket=\"$dbSocket\""; } - else + else { $mechanism="--port=\"$dbPort\""; } - + $tmpdir=resolveTempDir(); - + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
"; $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
"; - - + + $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; $info['display']=$stmt; - + $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; - + $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; $info['cmd']=$stmt; return $info; @@ -471,18 +484,18 @@ function title($title) function resolveTempDir() { - + if (OS_UNIX) { - $dir='/tmp/kt-db-backup'; + $dir='/tmp/kt-db-backup'; } - else + else { - $dir='c:/kt-db-backup'; + $dir='c:/kt-db-backup'; } $oKTConfig =& KTConfig::getSingleton(); $dir = $oKTConfig->get('backup/backupDirectory',$dir); - + if (!is_dir($dir)) { mkdir($dir); @@ -505,14 +518,14 @@ function upgradeConfirm() } ?>

-We are about to start the upgrade process. +We are about to start the upgrade process.

- -       -       + +       +       - + Are you sure you want to perform the backup? - +

Your mysql installation has been resolved. Manually, you would do the following:

@@ -537,7 +550,7 @@ Your mysql installation has been resolved. Manually, you would do the following: cd ""
-

- -              + +              - + There don't seem to be any backups to restore from the "" directory.

@@ -618,22 +631,22 @@ function restoreSelect() $i=0; foreach($files as $file) { - $color=((($i++)%2)==0)?'white':'lightgrey'; + $color=((($i++)%2)==0)?'white':'lightgrey'; ?> - -

-       +       @@ -659,10 +672,10 @@ function restoreConfirm() restoreSelect(); exit; } - + title('Confirm Restore'); $status = $_SESSION['backupStatus']; - $filename=$_SESSION['backupFile']; + $filename=$_SESSION['backupFile']; $stmt=create_restore_stmt($filename); $dir=$stmt['dir']; @@ -678,7 +691,7 @@ Manually, you would do the following to restore the backup: cd ""
-continue to restore to attempt the command(s) above. - -       -       + +       +       -       +       cd
- - + It appears as though the backup process has failed.

Unfortunately, it is difficult to diagnose these problems automatically @@ -792,19 +805,19 @@ We appologise for the inconvenience. -
- -       +
+ +       -       - - + + - The restore of
"" has been completed. + The restore of "" has been completed.

It appears as though the restore has been successful.

- + It appears as though the restore process has failed.

@@ -843,16 +856,16 @@ We appologise for the inconvenience. -
- -       +
+ +       + + 0) { $_SESSION['backupStatus'] = true; - + } - else + else { $_SESSION['backupStatus'] = false; } @@ -924,18 +937,18 @@ function backup() -

The mysqldump utility was not found in the subdirectory. - -       - + The restore is now underway. Please wait till it completes. -

The mysql utility was not found in the subdirectory. - -       - + until your the database

If you have already done this, you may skip this step can continue directly to the upgrade.

- - -       -       -       -       + + +       +       +       +       -
- -       -       +
+ +       +      

The table below describes the upgrades that have occurred to upgrade your installation to systemVersion;?>. - + Pre-Upgrade actions failed.

@@ -1091,13 +1104,13 @@ function Upgrade()

Upgrade failed.

@@ -1108,13 +1121,13 @@ function Upgrade()

Post-Upgrade actions failed.

@@ -1126,14 +1139,14 @@ function Upgrade() } ?> -       -       - +       + -get('ui/poweredByDisabled') == '0'){ ?> align="right">