From: <lph...@us...> - 2008-08-10 01:59:51
|
Revision: 14139 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=14139&view=rev Author: lphuberdeau Date: 2008-08-10 01:59:58 +0000 (Sun, 10 Aug 2008) Log Message: ----------- [FIX] Site would not get locked using ext/ssh2 Modified Paths: -------------- trim/scripts/convert.php trim/scripts/update.php trim/src/instancelib.php Modified: trim/scripts/convert.php =================================================================== --- trim/scripts/convert.php 2008-08-10 01:37:22 UTC (rev 14138) +++ trim/scripts/convert.php 2008-08-10 01:59:58 UTC (rev 14139) @@ -29,27 +29,8 @@ continue; } - // Lock {{{ - $url = "{$instance->weburl}/maintenance.html"; - $htaccess = <<<HTACCESS -RewriteEngine On + $locked = $instance->lock(); -RewriteRule . maintenance.html -HTACCESS; - $htaccess = escapeshellarg( $htaccess ); - - info( "Locking website." ); - if( ! $access->fileExists( $instance->getWebPath( 'maintenance.html' ) ) ) - $access->uploadFile( dirname(__FILE__) . "/maintenance.html", "maintenance.html" ); - - $access->shellExec( - "cd " . escapeshellarg( $instance->webroot ), - "touch .htaccess", - "mv .htaccess .htaccess.bak", - "echo $htaccess > .htaccess" - ); - // }}} - $toKeep = array( 'db/local.php', 'img/wiki', @@ -89,14 +70,8 @@ $filesToResolve = $app->performUpdate( $instance ); - // Unlock {{{ - info( "Unlocking website." ); - warning('New .htaccess from 2.0 will be used. Re-apply changes made to .htaccess. Old file kept as .htaccess.bak'); - $access->shellExec( - "cd " . escapeshellarg( $instance->webroot ), - "mv _htaccess .htaccess" - ); - // }}} + if( $locked ) + $instance->unlock(); } ?> Modified: trim/scripts/update.php =================================================================== --- trim/scripts/update.php 2008-08-10 01:37:22 UTC (rev 14138) +++ trim/scripts/update.php 2008-08-10 01:59:58 UTC (rev 14139) @@ -21,32 +21,8 @@ foreach( $selection as $instance ) { - $access = $instance->getBestAccess( 'scripting' ); - if( ! $ok = $access instanceof ShellPrompt ) - echo "Site will not be disabled during the update. Shell access required.\n"; + $locked = $instance->lock(); - $url = "{$instance->weburl}/maintenance.html"; - $htaccess = <<<HTACCESS -RewriteEngine On - -RewriteRule . maintenance.html -HTACCESS; - $htaccess = escapeshellarg( $htaccess ); - - if( $ok ) - { - info( "Locking website." ); - if( ! $access->fileExists( $instance->getWebPath( 'maintenance.html' ) ) ) - $access->uploadFile( dirname(__FILE__) . "/maintenance.html", "maintenance.html" ); - - $access->shellExec( - "cd " . escapeshellarg( $instance->webroot ), - "touch .htaccess", - "mv .htaccess .htaccess.bak", - "echo $htaccess > .htaccess" - ); - } - $app = $instance->getApplication(); if( ARG_SWITCH ) @@ -83,14 +59,8 @@ handleCheckResult( $instance, $version, $filesToResolve ); } - if( $ok ) - { - info( "Unlocking website." ); - $access->shellExec( - "cd " . escapeshellarg( $instance->webroot ), - "mv .htaccess.bak .htaccess" - ); - } + if( $locked ) + $instance->unlock(); } ?> Modified: trim/src/instancelib.php =================================================================== --- trim/src/instancelib.php 2008-08-10 01:37:22 UTC (rev 14138) +++ trim/src/instancelib.php 2008-08-10 01:59:58 UTC (rev 14139) @@ -286,6 +286,54 @@ return array_reverse( glob( ARCHIVE_FOLDER . "/{$this->id}_*.tar.bz2" ) ); } // }}} + function lock() // {{{ + { + $access = $this->getBestAccess( 'scripting' ); + + if( ! $ok = $access instanceof ShellPrompt ) + echo "Site will not be disabled during the update. Shell access required.\n"; + + $url = "{$this->weburl}/maintenance.html"; + $htaccess = <<<HTACCESS + RewriteEngine On + + RewriteRule . maintenance.html +HTACCESS; + $htaccess = escapeshellarg( $htaccess ); + + if( $ok ) + { + info( "Locking website." ); + if( ! $access->fileExists( $this->getWebPath( 'maintenance.html' ) ) ) + $access->uploadFile( dirname(__FILE__) . "/../scripts/maintenance.html", "maintenance.html" ); + + $access->shellExec( + "touch " + . escapeshellarg( $this->getWebPath( '.htaccess' ) ), + "mv " + . escapeshellarg( $this->getWebPath( '.htaccess' ) ) + . ' ' + . escapeshellarg( $this->getWebPath( '.htaccess.bak' ) ), + "echo $htaccess > " + . escapeshellarg( $this->getWebPath( '.htaccess' ) ) + ); + } + + return $ok; + } // }}} + + function unlock() // {{{ + { + info( "Unlocking website." ); + $access = $this->getBestAccess( 'scripting' ); + $access->shellExec( + "mv " + . escapeshellarg( $this->getWebPath( '.htaccess.bak' ) ) + . ' ' + . escapeshellarg( $this->getWebPath( '.htaccess' ) ) + ); + } // }}} + function __get( $name ) // {{{ { if( isset( $this->$name ) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |