[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/data/tasks/ -> sfPakeEnvironment.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the symfony package.
   5   * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
   6   * 
   7   * For the full copyright and license information, please view the LICENSE
   8   * file that was distributed with this source code.
   9   */
  10  
  11  pake_desc('synchronise project with another machine');
  12  pake_task('sync', 'project_exists');
  13  
  14  function run_sync($task, $args)
  15  {
  16    if (!count($args))
  17    {
  18      throw new Exception('You must provide an environment to synchronize.');
  19    }
  20  
  21    $env = $args[0];
  22  
  23    $dryrun = isset($args[1]) ? $args[1] : false;
  24  
  25    if (!file_exists('config/rsync_exclude.txt'))
  26    {
  27      throw new Exception('You must create a rsync_exclude file for your project.');
  28    }
  29  
  30    $host = $task->get_property('host', $env);
  31    $dir  = $task->get_property('dir', $env);
  32    try
  33    {
  34      $user = $task->get_property('user', $env).'@';
  35    }
  36    catch (pakeException $e)
  37    {
  38      $user = '';
  39    }
  40  
  41    if (substr($dir, -1) != '/')
  42    {
  43      $dir .= '/';
  44    }
  45  
  46    $ssh = 'ssh';
  47  
  48    try
  49    {
  50      $port = $task->get_property('port', $env);
  51      $ssh = '"ssh -p'.$port.'"';
  52    }
  53    catch (pakeException $e) {}
  54  
  55    try
  56    {
  57      $parameters = $task->get_property('parameters', $env);
  58    }
  59    catch (pakeException $e)
  60    {
  61      $parameters = '-azC --force --delete';
  62      if (file_exists('config/rsync_exclude.txt'))
  63      {
  64        $parameters .= ' --exclude-from=config/rsync_exclude.txt';
  65      }
  66  
  67      if (file_exists('config/rsync_include.txt'))
  68      {
  69        $parameters .= ' --include-from=config/rsync_include.txt';
  70      }
  71  
  72      if (file_exists('config/rsync.txt'))
  73      {
  74        $parameters .= ' --files-from=config/rsync.txt';
  75      }
  76    }
  77  
  78    $dry_run = ($dryrun == 'go' || $dryrun == 'ok') ? '' : '--dry-run';
  79    $cmd = "rsync --progress $dry_run $parameters -e $ssh ./ $user$host:$dir";
  80  
  81    echo pake_sh($cmd);
  82  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7