|
1 | 1 | <?php |
2 | 2 |
|
3 | 3 | use \Composer\Semver\Comparator; |
| 4 | +use \Symfony\Component\Filesystem\Filesystem; |
4 | 5 | use \EE\Utils; |
5 | | -use Mustangostang\Spyc; |
6 | 6 |
|
7 | 7 | /** |
8 | 8 | * Review current EE info, check for updates, or see defined aliases. |
@@ -162,7 +162,7 @@ public function info( $_, $assoc_args ) { |
162 | 162 | /** |
163 | 163 | * Function to run migrations required to upgrade to the newer version. Will always be invoked from the newer phar downloaded inside the /tmp folder |
164 | 164 | */ |
165 | | - public function migrate() { |
| 165 | + private function migrate() { |
166 | 166 | EE\Migration\Executor::execute_migrations(); |
167 | 167 | } |
168 | 168 |
|
@@ -488,6 +488,40 @@ public function cmd_dump() { |
488 | 488 | echo json_encode( $this->command_to_array( EE::get_root_command() ) ); |
489 | 489 | } |
490 | 490 |
|
| 491 | + /** |
| 492 | + * Uninstalls easyengine completely along with all sites |
| 493 | + * |
| 494 | + * ## OPTIONS |
| 495 | + * |
| 496 | + * [--yes] |
| 497 | + * : Do not prompt for confirmation. |
| 498 | + * |
| 499 | + * @subcommand self-uninstall |
| 500 | + */ |
| 501 | + public function self_uninstall( $args, $assoc_args ) { |
| 502 | + |
| 503 | + EE::confirm("Are you sure you want to remove EasyEngine and all its sites(along with their data)?\nThis is an irreversible action. No backup will be kept.", $assoc_args); |
| 504 | + |
| 505 | + Utils\default_launch("docker rm -f $(docker ps -aqf label=org.label-schema.vendor=\"EasyEngine\")"); |
| 506 | + $home = Utils\get_home_dir(); |
| 507 | + Utils\default_launch("rm -rf $home/.ee/"); |
| 508 | + |
| 509 | + $records = EE::db()->select(['site_path']); |
| 510 | + |
| 511 | + if( $records !== false ) { |
| 512 | + $sites_paths = array_column($records, 'site_path'); |
| 513 | + $fs = new Filesystem(); |
| 514 | + $fs->remove($sites_paths); |
| 515 | + } |
| 516 | + |
| 517 | + Utils\default_launch("rm -df $home/ee-sites/"); |
| 518 | + Utils\default_launch("rm -rf /opt/easyengine/"); |
| 519 | + |
| 520 | + if ( Utils\inside_phar() ) { |
| 521 | + unlink( realpath( $_SERVER['argv'][0] ) ); |
| 522 | + } |
| 523 | + } |
| 524 | + |
491 | 525 | /** |
492 | 526 | * Generate tab completion strings. |
493 | 527 | * |
|
0 commit comments