diff --git a/README.md b/README.md index fa2981b85..8de7874da 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ EasyEngine Logo [![Build Status](https://travis-ci.org/EasyEngine/easyengine.svg?branch=master-v4)](https://travis-ci.org/EasyEngine/easyengine) +[![License](https://poser.pugx.org/phpunit/phpunit/license)](https://packagist.org/packages/phpunit/phpunit) [![Join EasyEngine Slack Channel](http://slack.easyengine.io/badge.svg)](http://slack.easyengine.io/) ## Requirements @@ -19,7 +20,7 @@ For Linux, we have created an installer script which will install all the dependencies for you. We have tested this on Ubuntu 14.04, 16.04, 18.04 and Debian 8. ```bash -wget -qO ee https://rt.cx/ee4beta && sudo bash ee +wget -qO ee https://rt.cx/ee4 && sudo bash ee ``` Even if the script doesn't work for your distribution, you can manually install the dependencies and then run the following commands to install EasyEngine @@ -107,4 +108,3 @@ We warmheartedly welcome all contributions however and in whatever capacity you ## Donations [![PayPal-Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)](http://rt.cx/eedonate) -[![BitCoin-Donate](https://bitpay.com/img/donate-button.svg)](https://bitpay.com/417008/donate) diff --git a/VERSION b/VERSION index fcdb2e109..1454f6ed4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.0 +4.0.1 diff --git a/ci/prepare.sh b/ci/prepare.sh index 7ae98d55f..a3fd49a41 100755 --- a/ci/prepare.sh +++ b/ci/prepare.sh @@ -10,4 +10,8 @@ if [[ "$TRAVIS_BRANCH" != $DEPLOY_BRANCH ]]; then sed -i 's/\:\ \"\(.*\)\"/\:\ \"\1-nightly\"/g' img-versions.json fi -php -dphar.readonly=0 ./utils/make-phar.php easyengine.phar --quiet \ No newline at end of file +php -dphar.readonly=0 ./utils/make-phar.php easyengine.phar --quiet + +# Checking the phar is working. +sudo ./easyengine.phar cli info +docker ps -a \ No newline at end of file diff --git a/php/EE/Runner.php b/php/EE/Runner.php index c7227ae16..3a83acfea 100644 --- a/php/EE/Runner.php +++ b/php/EE/Runner.php @@ -64,28 +64,54 @@ private function init_ee() { if ( ! empty( $this->arguments ) && - ( 'help' !== $this->arguments[0] ) - && $this->arguments !== [ 'cli', 'version' ] - ) - { + ( ! in_array( $this->arguments[0], [ 'cli', 'config', 'help' ], true ) ) + ) { + $this->check_requirements(); + $this->maybe_trigger_migration(); + } + if ( [ 'cli', 'info' ] === $this->arguments && $this->check_requirements( false ) ) { + $this->maybe_trigger_migration(); + } + } - // Minimum requirement checks. - $docker_running = 'docker ps > /dev/null'; - if ( ! EE::exec( $docker_running ) ) { - EE::error( 'docker not installed or not running.' ); - } + /** + * Check EE requirements for required commands. + * + * @param bool $show_error To display error or to retutn status. + */ + public function check_requirements( $show_error = true ) { - $docker_compose_installed = 'command -v docker-compose > /dev/null'; - if ( ! EE::exec( $docker_compose_installed ) ) { - EE::error( 'EasyEngine requires docker-compose.' ); - } + $docker_running = true; + $status = true; + $error = []; - if ( version_compare( PHP_VERSION, '7.2.0' ) < 0 ) { - EE::error( 'EasyEngine requires minimum PHP 7.2.0 to run.' ); - } + $docker_running_cmd = 'docker ps > /dev/null'; + if ( ! EE::exec( $docker_running_cmd ) ) { + $status = false; + $docker_running = false; + $error[] = 'Docker not installed or not running.'; + } - $this->maybe_trigger_migration(); + $docker_compose_installed = 'command -v docker-compose > /dev/null'; + if ( ! EE::exec( $docker_compose_installed ) ) { + $status = false; + $error[] = 'EasyEngine requires docker-compose.'; + } + + if ( version_compare( PHP_VERSION, '7.2.0' ) < 0 ) { + $status = false; + $error[] = 'EasyEngine requires minimum PHP 7.2.0 to run.'; } + + if ( $show_error && ! $status ) { + EE::error( reset( $error ), false ); + if ( IS_DARWIN && ! $docker_running ) { + EE::log( 'For macOS docker can be installed using: `brew cask install docker`' ); + } + die; + } + + return $status; } /** diff --git a/php/commands/src/CLI_Command.php b/php/commands/src/CLI_Command.php index c1bafea71..6ab58af42 100644 --- a/php/commands/src/CLI_Command.php +++ b/php/commands/src/CLI_Command.php @@ -286,6 +286,7 @@ public function update( $_, $assoc_args ) { $download_url = $newest['package_url']; $md5_url = str_replace( '.phar', '.phar.md5', $download_url ); } + EE::get_runner()->check_requirements(); EE::log( sprintf( 'Downloading from %s...', $download_url ) ); $temp = \EE\Utils\get_temp_dir() . uniqid( 'ee_', true ) . '.phar'; $headers = array(); @@ -493,21 +494,27 @@ public function cmd_dump() { */ public function self_uninstall( $args, $assoc_args ) { + if ( ! EE::get_runner()->check_requirements( false ) ) { + EE::error( 'Unable to proceed with uninstallation. Seems there is a dependency down.', false ); + die; + } + 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 ); EE::exec( 'docker rm -f $(docker ps -aqf label=org.label-schema.vendor="EasyEngine")' ); - $home = Utils\get_home_dir(); - EE::exec( "rm -rf $home/.ee/" ); + EE::exec( 'docker network prune -f $(docker network ls -f "label=org.label-schema.vendor=EasyEngine")' ); + EE::exec( 'docker volume rm -f $(docker volume ls -f "label=org.label-schema.vendor=EasyEngine" -q)' ); + EE::exec( 'docker image rm $(docker image ls -f "label=org.label-schema.vendor=EasyEngine" -q)' ); $records = Site::all( [ 'site_fs_path' ] ); + $fs = new Filesystem(); if ( ! empty( $records ) ) { $sites_paths = array_column( $records, 'site_fs_path' ); - $fs = new Filesystem(); $fs->remove( $sites_paths ); } - EE::exec( "rm -rf " . EE_ROOT_DIR ); + $fs->remove( EE_ROOT_DIR ); if ( Utils\inside_phar() ) { unlink( realpath( $_SERVER['argv'][0] ) );