#!/usr/bin/env php description('yeswiki-move, move YesWiki like a professionnal 🌈🦄'); if (posix_getuid() != 0) { $climate->error('ERROR : this script needs root privilege to run.'); exit; } $absolutePathToEnvFile = __DIR__ . '/.env'; if (file_exists($absolutePathToEnvFile)) { (new DotEnv($absolutePathToEnvFile))->load(); } else { $climate->error('ERROR : No .env file found.'); exit; } $climate->arguments->add([ 'from' => [ 'prefix' => 'f', 'longPrefix' => 'from', 'description' => 'Url of source wiki', 'required' => true, 'defaultValue' => 'https://example.com' ], 'to' => [ 'prefix' => 't', 'longPrefix' => 'to', 'description' => 'Url of destination wiki', 'required' => true, 'defaultValue' => 'https://destination.com' ], ]); $climate->arguments->parse(); $from = $climate->arguments->get('from'); $to = $climate->arguments->get('to'); if (empty($from) || $from == 'https://example.com' || empty($to) || $to == 'https://destination.com') { $climate->error('ERROR : you need a --from (the source url) and a --to (the destination url).'."\n"); $climate->usage(); exit; } if (!filter_var($from, FILTER_VALIDATE_URL)) { $climate->error('ERROR : the source url given with --from '.$from.' is not a valid url.'."\n"); exit; } $fromUrl = parse_url($from); var_dump($fromUrl); if (!domainIsOnServer($fromUrl['host'])) { $climate->error('ERROR : Domain '.$fromUrl['host'].' was not found on the server.'."\n"); exit; } if (!filter_var($to, FILTER_VALIDATE_URL)) { $climate->error('ERROR : the destination url given with --to '.$to.' is not a valid url.'."\n"); exit; } $toUrl = parse_url($to); var_dump($toUrl); if (!domainIsOnServer($toUrl['host'])) { $climate->error('ERROR : Domain '.$toUrl['host'].' was not found on the server.'."\n"); exit; } if ($from === $to) { $climate->error('ERROR : --from and --to parameters must be different.'."\n"); exit; } $climate->bold()->underline()->out('Move a YesWiki'); $climate->out('This will move yeswiki on '.$from.' to '.$to.', CAREFULL the destination yeswiki will be replaced'."\n"); $input = $climate->confirm('Is it all good ?'); if ($input->confirmed()) { $climate->shout( 'The yeswiki '.$from.' was successfully moved to '.$to.', congrats ! 🎉'."\n" ); } else { $climate->info('Ok, let\'s stop here...'); }