This commit is contained in:
parent
9091895058
commit
86e9625246
2 changed files with 21 additions and 7 deletions
|
@ -8,8 +8,12 @@ use Amp\Http\Client\Request;
|
||||||
|
|
||||||
function domainIsOnServer($domain)
|
function domainIsOnServer($domain)
|
||||||
{
|
{
|
||||||
$domainWithoutWww = preg_replace('/^www\./m', '', $domain);
|
return file_exists('/etc/nginx/conf.d/'.$domain.'.conf');
|
||||||
return file_exists('/etc/nginx/conf.d/'.$domainWithoutWww.'.conf');
|
}
|
||||||
|
|
||||||
|
function wikiIsOnServer($path)
|
||||||
|
{
|
||||||
|
return glob('/home/*/'.$path.'/wakka.config.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIP($domain, $withWww = false, $noip6 = false)
|
function checkIP($domain, $withWww = false, $noip6 = false)
|
||||||
|
|
|
@ -54,22 +54,32 @@ if (!filter_var($from, FILTER_VALIDATE_URL)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$fromUrl = parse_url($from);
|
$fromUrl = parse_url($from);
|
||||||
var_dump($fromUrl);
|
$fromDomainWithoutWww = preg_replace('/^www\./m', '', $fromUrl['host']);
|
||||||
if (!domainIsOnServer($fromUrl['host'])) {
|
|
||||||
|
if (!domainIsOnServer($fromDomainWithoutWww)) {
|
||||||
$climate->error('ERROR : Domain '.$fromUrl['host'].' was not found on the server.'."\n");
|
$climate->error('ERROR : Domain '.$fromUrl['host'].' was not found on the server.'."\n");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
if (!wikiIsOnServer($fromDomainWithoutWww.$fromUrl['path'])) {
|
||||||
|
$climate->error('ERROR : no Yeswiki found '.$fromDomainWithoutWww.$fromUrl['path'].' on the server.'."\n");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (!filter_var($to, FILTER_VALIDATE_URL)) {
|
if (!filter_var($to, FILTER_VALIDATE_URL)) {
|
||||||
$climate->error('ERROR : the destination url given with --to '.$to.' is not a valid url.'."\n");
|
$climate->error('ERROR : the destination url given with --to '.$to.' is not a valid url.'."\n");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$toUrl = parse_url($to);
|
$toUrl = parse_url($to);
|
||||||
var_dump($toUrl);
|
$toDomainWithoutWww = preg_replace('/^www\./m', '', $toUrl['host']);
|
||||||
if (!domainIsOnServer($toUrl['host'])) {
|
|
||||||
|
if (!domainIsOnServer($toDomainWithoutWww)) {
|
||||||
$climate->error('ERROR : Domain '.$toUrl['host'].' was not found on the server.'."\n");
|
$climate->error('ERROR : Domain '.$toUrl['host'].' was not found on the server.'."\n");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
if (!wikiIsOnServer($toDomainWithoutWww.$toUrl['path'])) {
|
||||||
|
$climate->error('ERROR : no Yeswiki found '.$toDomainWithoutWww.$toUrl['path'].' on the server.'."\n");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ($from === $to) {
|
if ($from === $to) {
|
||||||
$climate->error('ERROR : --from and --to parameters must be different.'."\n");
|
$climate->error('ERROR : --from and --to parameters must be different.'."\n");
|
||||||
|
@ -78,7 +88,7 @@ if ($from === $to) {
|
||||||
|
|
||||||
$climate->bold()->underline()->out('Move a YesWiki');
|
$climate->bold()->underline()->out('Move a YesWiki');
|
||||||
$climate->out('This will move yeswiki on <bold>'.$from.'</bold> to <bold>'.$to.'</bold>');
|
$climate->out('This will move yeswiki on <bold>'.$from.'</bold> to <bold>'.$to.'</bold>');
|
||||||
$climate->red('CAREFUL: the destination yeswiki will be replaced'."\n");
|
$climate->red('CAREFUL: the destination yeswiki will be replaced.'."\n");
|
||||||
$input = $climate->confirm('Is it all good ?');
|
$input = $climate->confirm('Is it all good ?');
|
||||||
if ($input->confirmed()) {
|
if ($input->confirmed()) {
|
||||||
$climate->shout(
|
$climate->shout(
|
||||||
|
|
Loading…
Add table
Reference in a new issue