Skip to content

Commit 6fb6205

Browse files
midwestEmidwestE
authored andcommitted
Fix rsync transfer when using ssh_config. Add cloudpanel recipe
1 parent 79a942a commit 6fb6205

File tree

3 files changed

+121
-7
lines changed

3 files changed

+121
-7
lines changed

contrib/filetransfer.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,20 @@ public function rsyncCommand(Host $source, string $sourcePath, Host $destination
6060
$port = '';
6161
if ($source instanceof Localhost || hostsOnSameServer($source, $destination)) {
6262
$sourceUri = parse($sourcePath);
63-
} else {
63+
} elseif (!is_null($source->get('config_file'))) {
64+
$port = "-e \"ssh -F " . $source->get('config_file') . "\"";
65+
} elseif (!is_null($source->getPort())) {
6466
$port = "-e \"ssh -p " . $source->getPort() . "\"";
65-
$sourceUri = $source->getRemoteUser() . '@' . $source->getHostname() . ':' . parse($sourcePath);
6667
}
6768

6869
// destination
70+
$destinationUri = $destination->getRemoteUser() . '@' . $destination->getHostname() . ':' . parse($destinationPath);
6971
if ($destination instanceof Localhost || hostsOnSameServer($source, $destination)) {
7072
$destinationUri = parse($destinationPath);
71-
} else {
72-
$destinationUri = $destination->getRemoteUser() . '@' . $destination->getHostname() . ':' . parse($destinationPath);
73+
} elseif (!is_null($destination->get('config_file'))) {
74+
$port = "-e \"ssh -F " . $destination->get('config_file') . "\"";
75+
} elseif (!is_null($destination->getPort())) {
76+
$port = "-e \"ssh -p " . $destination->getPort() . "\"";
7377
}
7478

7579
$command = "$rsync $port $switches $excludes $sourceUri $destinationUri";

recipe/cloudpanel.php

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
namespace Deployer;
4+
5+
require_once __DIR__ . '/common.php';
6+
7+
require_once __DIR__ . '/../contrib/clearserverpaths.php';
8+
require_once __DIR__ . '/../contrib/filetransfer.php';
9+
require_once __DIR__ . '/../contrib/hardening.php';
10+
require_once __DIR__ . '/../contrib/mysql.php';
11+
require_once __DIR__ . '/../contrib/wordpresscli.php';
12+
13+
add('recipes', ['cloudpanel']);
14+
15+
/**
16+
* Siteground configuration
17+
*/
18+
set('shared_dirs', ['wp-content/uploads']);
19+
set('writable_dirs', ['wp-content/uploads']);
20+
21+
/* ----------------- filesharden ----------------- */
22+
// for task 'deploy:harden'
23+
set('harden_dir_permissions', 'u=rx,g=rx,o=rx');
24+
set('harden_file_permissions', 'u=r,g=r,o=r');
25+
/* ----------------- clear_server_paths ----------------- */
26+
set('clear_server_paths', []);
27+
28+
/**
29+
* Deploy task
30+
*/
31+
// desc('Prepares a new release');
32+
// task('deploy:prepare', [
33+
// 'deploy:info',
34+
// 'deploy:setup',
35+
// 'deploy:lock',
36+
// 'deploy:release',
37+
// 'deploy:update_code',
38+
// 'deploy:shared',
39+
// 'deploy:writable',
40+
// ]);
41+
42+
// desc('Publishes the release');
43+
// task('deploy:publish', [
44+
// 'deploy:symlink',
45+
// 'deploy:unlock',
46+
// 'deploy:cleanup',
47+
// 'deploy:success',
48+
// ]);
49+
50+
task('deploy', [
51+
'deploy:prepare',
52+
'deploy:vendors',
53+
'deploy:clear_paths',
54+
'deploy:harden',
55+
'deploy:publish',
56+
'cp:purge'
57+
])->desc('Deploys your project');
58+
59+
/**
60+
* Hooks
61+
*/
62+
before('deploy:cleanup', function () {
63+
invoke('deploy:unharden');
64+
})->desc('Unharden previous site releases');
65+
66+
after('deploy:harden', function () {
67+
invoke('deploy:writablehardened');
68+
})->desc('Apply writable permissions to files/folders in harden_writable_files');
69+
70+
after('deploy:failed', function () {
71+
invoke('deploy:unlock');
72+
invoke('deploy:unharden');
73+
})->desc('Unlock after deploy:failed and unharded failed release');
74+
after('deploy:symlink', 'deploy:clear_server_paths');
75+
76+
task('pull-all', [
77+
'db:pull-replace',
78+
'files:pull',
79+
])->desc('Pull db from a remote stage, replaces instances of domain in db, and pulls writable files');
80+
81+
// task('cp', function () {
82+
// $wpcli = new WordpressCli(currentHost());
83+
// $command = $wpcli->command('cp');
84+
// run($command, ['real_time_output' => true]);
85+
// })->desc('Show the siteground cli options');
86+
87+
task('cp:purge:transient', function () {
88+
$wpcli = new WordpressCli(currentHost());
89+
$command = $wpcli->command('transient delete --all');
90+
run($command);
91+
})->desc('Purge wp transients');
92+
93+
task('cp:purge', function () {
94+
invoke('cp:purge:transient');
95+
invoke('wp:cache:flush');
96+
// invoke('sg:purge:memcached');
97+
// invoke('sg:purge:dynamic');
98+
})->desc('Purge the transients, wp cache, and Siteground dynamic and memcached caches');
99+
100+
// task('sg:purge:dynamic', function () {
101+
// $wpcli = new WordpressCli(currentHost());
102+
// $command = $wpcli->command('sg purge');
103+
// run($command);
104+
// })->desc('Purge the Siteground dynamic cache');
105+
106+
// task('sg:purge:memcached', function () {
107+
// $wpcli = new WordpressCli(currentHost());
108+
// $command = $wpcli->command('sg purge memcached');
109+
// run($command);
110+
// })->desc('Purge the Siteground memcached cache');

recipe/siteground.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@
112112
})->desc('Purge wp transients');
113113

114114
task('sg:purge', function () {
115-
invoke('sg:purge:transient');
115+
// invoke('sg:purge:transient');
116116
invoke('wp:cache:flush');
117-
invoke('sg:purge:memcached');
118-
invoke('sg:purge:dynamic');
117+
// invoke('sg:purge:memcached');
118+
// invoke('sg:purge:dynamic');
119119
})->desc('Purge the transients, wp cache, and Siteground dynamic and memcached caches');
120120

121121
task('sg:purge:dynamic', function () {

0 commit comments

Comments
 (0)