コード例 #1
0
ファイル: MysqlTask.php プロジェクト: primat/deployer-org
 /**
  * @param \Cogeco\Build\Entity\Database $db
  * @param \Cogeco\Build\Entity\File $dumpFile
  * @param $dbName
  * @param array $tables
  * @throws \Cogeco\Build\Exception
  */
 public static function mysqlDump(Database $db, $dbName, array $tables = array(), File $dumpFile)
 {
     if (!is_array($tables) || count($tables) === 0) {
         $tablesParam = '';
     } else {
         $tablesParam = explode(' ', $tables) . ' ';
     }
     // Presentation
     self::log("- Getting dump of {$dbName}");
     if ($db->isRemote()) {
         Task::log(" from {$db->host->hostname}");
     }
     self::log("\n");
     // For use when converting a dump to SQLite
     // --compatible=ansi --skip-extended-insert --compact
     // Build the command
     $cmd = Config::get('mysqldump.bin') . " -vf -P {$db->port}";
     if ($db->isRemote()) {
         $cmd .= " -h {$db->host->hostname}";
     }
     // Create the folder if it doesn't exist already
     FileSystemTask::mkdir($dumpFile->dir->getPath());
     $cmd .= " -u {$db->account->username} -p{$db->account->password} {$dbName} {$tablesParam}| sed '/^\\/\\*\\!50013 DEFINER/d' > {$dumpFile->getPath()}";
     //$cmd .= " --result-file={$dumpFile->getPath()} -u {$db->account->username} -p{$db->account->password} {$dbName} {$tablesParam} 2>&1";
     self::runCmd($cmd);
     self::log("\n");
 }
コード例 #2
0
ファイル: SshTask.php プロジェクト: primat/deployer-org
 /**
  * Tests if a given file exists on the remote server
  * @param \Cogeco\Build\Entity\File $file
  * @return bool
  */
 public static function fileExists(File $file)
 {
     // Make sure there is a connection
     if (!$file->isRemote()) {
         echo "Warning: Testing for file existence on local machine rather than a remote one";
         return file_exists($file->getPath());
     }
     $command = '[ -f ' . $file->getPath() . ' ] && echo "1" || echo "0"';
     $ssh = self::connect($file->getHost());
     $output = trim($ssh->exec($command));
     self::checkCmdExceptions($ssh);
     return $output === "1";
 }
コード例 #3
0
ファイル: send-orders.php プロジェクト: primat/deployer-org
// *** Initial output
//
Task::log("\n---------------------------------------\n");
Task::log("- Move cogeco.ca orders.log to secured shared drive\n\n");
// Prompt for user password, if it's not hardcoded
CliTask::promptAccountPassword($cogecoAccount);
// ********************
// *** Move the file to the shared drive
//
// Firstly, move it on the remote server
SshTask::moveFile($remoteFileOld, $remoteFileNew->getPath());
//SshTask::copyFile($remoteFileOld, $remoteFileNew->getPath());
// Sync from the remote server to the shared drive
FileSyncTask::sync($rsyncOptions);
// Verify that the file was created on the shared drive and then delete it on the remote server if it exists
if (!is_file($destinationFile->getPath())) {
    throw new \Exception('File was not successfully copied to the shared drive!');
}
//If the file was successfully transferred, delete it on the remote host
//SshTask::deleteFile($remoteFileNew);
// ********************
// *** Notify
//
$pathsHtml = <<<HTML
<p>
\t<a href="file:{$sharedDestinationDir}">
\t\t{$sharedDestinationDir}
\t</a>
\t<br />
\t<a href="file:{$sharedDestinationDir}\\{$destinationFile->name}">
\t\t{$sharedDestinationDir}\\{$destinationFile->name}