Skip to content

Commit

Permalink
Merge branch '2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
mficzel committed May 29, 2018
2 parents 84bfd36 + 058e4b2 commit aff2cf2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
26 changes: 18 additions & 8 deletions Classes/Sitegeist/MagicWand/Command/CloneCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function presetCommand($presetName, $yes = false, $keepDb = false)
$keepDb,
(isset($this->clonePresets[$presetName]['flowCommand']) ?
$this->clonePresets[$presetName]['flowCommand'] : null
),
(isset($this->clonePresets[$presetName]['sshOptions']) ?
$this->clonePresets[$presetName]['sshOptions'] : ''
)
);
} else {
Expand All @@ -102,6 +105,7 @@ public function presetCommand($presetName, $yes = false, $keepDb = false)
* @param boolean $yes confirm execution without further input
* @param boolean $keepDb skip dropping of database during sync
* @param string $remoteFlowCommand the flow command to execute on the remote system
* @param string $sshOptions additional options for the ssh command
*/
public function remoteHostCommand(
$host,
Expand All @@ -112,7 +116,8 @@ public function remoteHostCommand(
$postClone = null,
$yes = false,
$keepDb = false,
$remoteFlowCommand = null
$remoteFlowCommand = null,
$sshOptions = ''
) {
// fallback
if ($remoteFlowCommand === null) {
Expand All @@ -127,11 +132,12 @@ public function remoteHostCommand(
// read remote configuration
$this->outputHeadLine('Fetch remote configuration');
$remotePersistenceConfigurationYaml = $this->executeLocalShellCommand(
'ssh -p %s %s@%s "cd %s; FLOW_CONTEXT=%s '
'ssh -p %s %s %s@%s "cd %s; FLOW_CONTEXT=%s '
. $remoteFlowCommand
. ' configuration:show --type Settings --path Neos.Flow.persistence.backendOptions;"',
[
$port,
$sshOptions,
$user,
$host,
$path,
Expand Down Expand Up @@ -189,7 +195,7 @@ public function remoteHostCommand(
# Fallback to default MySQL port if not given. #
################################################

if ( ! isset($remotePersistenceConfiguration['port'])) {
if (!isset($remotePersistenceConfiguration['port'])) {
$remotePersistenceConfiguration['port'] = 3306;
}

Expand Down Expand Up @@ -230,9 +236,10 @@ public function remoteHostCommand(

$this->outputHeadLine('Transfer Database');
$this->executeLocalShellCommand(
'ssh -p %s %s@%s \'mysqldump --add-drop-table --host=\'"\'"\'%s\'"\'"\' --port=\'"\'"\'%d\'"\'"\' --user=\'"\'"\'%s\'"\'"\' --password=\'"\'"\'%s\'"\'"\' \'"\'"\'%s\'"\'"\'\' | mysql --host=\'%s\' --port=\'%s\' --user=\'%s\' --password=\'%s\' \'%s\'',
'ssh -p %s %s %s@%s \'mysqldump --add-drop-table --host=\'"\'"\'%s\'"\'"\' --port=\'"\'"\'%d\'"\'"\' --user=\'"\'"\'%s\'"\'"\' --password=\'"\'"\'%s\'"\'"\' \'"\'"\'%s\'"\'"\'\' | mysql --host=\'%s\' --port=\'%s\' --user=\'%s\' --password=\'%s\' \'%s\'',
[
$port,
$sshOptions,
$user,
$host,
$remotePersistenceConfiguration['host'],
Expand All @@ -254,9 +261,10 @@ public function remoteHostCommand(

$this->outputHeadLine('Transfer Files');
$this->executeLocalShellCommand(
'rsync -e "ssh -p %s" -kLr %s@%s:%s/* %s',
'rsync -e "ssh -p %s %s" -kLr %s@%s:%s/* %s',
[
$port,
addslashes($sshOptions),
$user,
$host,
$remoteDataPersistentPath,
Expand All @@ -276,20 +284,22 @@ public function remoteHostCommand(
// If the translation directory is available print true - because we didn't get the return value here
$translationsAvailable = trim(
$this->executeLocalShellCommand(
'ssh %s@%s -p %s "[ -d %s ] && echo true"',
'ssh -p %s %s %s@%s "[ -d %s ] && echo true"',
[
$port,
$sshOptions,
$user,
$host,
$port,
$remoteDataTranslationsPath]
)
);

if ($translationsAvailable === 'true') {
$this->executeLocalShellCommand(
'rsync -e "ssh -p %s" -kLr %s@%s:%s/* %s',
'rsync -e "ssh -p %s %s" -kLr %s@%s:%s/* %s',
[
$port,
addslashes($sshOptions),
$user,
$host,
$remoteDataTranslationsPath,
Expand Down
2 changes: 2 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Sitegeist:
# user: ~
# # ssh port
# port: ~
# # ssh options
# sshOptions: ~
# # path on the remote server
# path: ~
# # flow-context on the remote server
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Sitegeist:
# user: ~
# # ssh port
# port: ~
# # ssh options
# sshOptions: ~
# # path on the remote server
# path: ~
# # flow-context on the remote server
Expand Down

0 comments on commit aff2cf2

Please sign in to comment.