Skip to content

Commit 5bf330b

Browse files
Merge pull request #1311 from EasyEngine/develop
Merge develop for v4.0.1
2 parents d2bd986 + d3289d0 commit 5bf330b

File tree

5 files changed

+62
-25
lines changed

5 files changed

+62
-25
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<img width="150" height="150" src="https://easyengine.io/wp-content/uploads/2015/11/cropped-favicon-easyengine.png" alt="EasyEngine Logo" align="right" />
44

55
[![Build Status](https://travis-ci.org/EasyEngine/easyengine.svg?branch=master-v4)](https://travis-ci.org/EasyEngine/easyengine)
6+
[![License](https://poser.pugx.org/phpunit/phpunit/license)](https://packagist.org/packages/phpunit/phpunit)
67
[![Join EasyEngine Slack Channel](http://slack.easyengine.io/badge.svg)](http://slack.easyengine.io/)
78

89
## Requirements
@@ -19,7 +20,7 @@
1920
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.
2021

2122
```bash
22-
wget -qO ee https://rt.cx/ee4beta && sudo bash ee
23+
wget -qO ee https://rt.cx/ee4 && sudo bash ee
2324
```
2425

2526
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
107108
## Donations
108109

109110
[![PayPal-Donate](https://cloud.githubusercontent.com/assets/4115/5297691/c7b50292-7bd7-11e4-987b-2dc21069e756.png)](http://rt.cx/eedonate)
110-
[![BitCoin-Donate](https://bitpay.com/img/donate-button.svg)](https://bitpay.com/417008/donate)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.0
1+
4.0.1

ci/prepare.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ if [[ "$TRAVIS_BRANCH" != $DEPLOY_BRANCH ]]; then
1010
sed -i 's/\:\ \"\(.*\)\"/\:\ \"\1-nightly\"/g' img-versions.json
1111
fi
1212

13-
php -dphar.readonly=0 ./utils/make-phar.php easyengine.phar --quiet
13+
php -dphar.readonly=0 ./utils/make-phar.php easyengine.phar --quiet
14+
15+
# Checking the phar is working.
16+
sudo ./easyengine.phar cli info
17+
docker ps -a

php/EE/Runner.php

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,54 @@ private function init_ee() {
6464

6565
if (
6666
! empty( $this->arguments ) &&
67-
( 'help' !== $this->arguments[0] )
68-
&& $this->arguments !== [ 'cli', 'version' ]
69-
)
70-
{
67+
( ! in_array( $this->arguments[0], [ 'cli', 'config', 'help' ], true ) )
68+
) {
69+
$this->check_requirements();
70+
$this->maybe_trigger_migration();
71+
}
72+
if ( [ 'cli', 'info' ] === $this->arguments && $this->check_requirements( false ) ) {
73+
$this->maybe_trigger_migration();
74+
}
75+
}
7176

72-
// Minimum requirement checks.
73-
$docker_running = 'docker ps > /dev/null';
74-
if ( ! EE::exec( $docker_running ) ) {
75-
EE::error( 'docker not installed or not running.' );
76-
}
77+
/**
78+
* Check EE requirements for required commands.
79+
*
80+
* @param bool $show_error To display error or to retutn status.
81+
*/
82+
public function check_requirements( $show_error = true ) {
7783

78-
$docker_compose_installed = 'command -v docker-compose > /dev/null';
79-
if ( ! EE::exec( $docker_compose_installed ) ) {
80-
EE::error( 'EasyEngine requires docker-compose.' );
81-
}
84+
$docker_running = true;
85+
$status = true;
86+
$error = [];
8287

83-
if ( version_compare( PHP_VERSION, '7.2.0' ) < 0 ) {
84-
EE::error( 'EasyEngine requires minimum PHP 7.2.0 to run.' );
85-
}
88+
$docker_running_cmd = 'docker ps > /dev/null';
89+
if ( ! EE::exec( $docker_running_cmd ) ) {
90+
$status = false;
91+
$docker_running = false;
92+
$error[] = 'Docker not installed or not running.';
93+
}
8694

87-
$this->maybe_trigger_migration();
95+
$docker_compose_installed = 'command -v docker-compose > /dev/null';
96+
if ( ! EE::exec( $docker_compose_installed ) ) {
97+
$status = false;
98+
$error[] = 'EasyEngine requires docker-compose.';
99+
}
100+
101+
if ( version_compare( PHP_VERSION, '7.2.0' ) < 0 ) {
102+
$status = false;
103+
$error[] = 'EasyEngine requires minimum PHP 7.2.0 to run.';
88104
}
105+
106+
if ( $show_error && ! $status ) {
107+
EE::error( reset( $error ), false );
108+
if ( IS_DARWIN && ! $docker_running ) {
109+
EE::log( 'For macOS docker can be installed using: `brew cask install docker`' );
110+
}
111+
die;
112+
}
113+
114+
return $status;
89115
}
90116

91117
/**

php/commands/src/CLI_Command.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ public function update( $_, $assoc_args ) {
286286
$download_url = $newest['package_url'];
287287
$md5_url = str_replace( '.phar', '.phar.md5', $download_url );
288288
}
289+
EE::get_runner()->check_requirements();
289290
EE::log( sprintf( 'Downloading from %s...', $download_url ) );
290291
$temp = \EE\Utils\get_temp_dir() . uniqid( 'ee_', true ) . '.phar';
291292
$headers = array();
@@ -493,21 +494,27 @@ public function cmd_dump() {
493494
*/
494495
public function self_uninstall( $args, $assoc_args ) {
495496

497+
if ( ! EE::get_runner()->check_requirements( false ) ) {
498+
EE::error( 'Unable to proceed with uninstallation. Seems there is a dependency down.', false );
499+
die;
500+
}
501+
496502
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 );
497503

498504
EE::exec( 'docker rm -f $(docker ps -aqf label=org.label-schema.vendor="EasyEngine")' );
499-
$home = Utils\get_home_dir();
500-
EE::exec( "rm -rf $home/.ee/" );
505+
EE::exec( 'docker network prune -f $(docker network ls -f "label=org.label-schema.vendor=EasyEngine")' );
506+
EE::exec( 'docker volume rm -f $(docker volume ls -f "label=org.label-schema.vendor=EasyEngine" -q)' );
507+
EE::exec( 'docker image rm $(docker image ls -f "label=org.label-schema.vendor=EasyEngine" -q)' );
501508

502509
$records = Site::all( [ 'site_fs_path' ] );
503510

511+
$fs = new Filesystem();
504512
if ( ! empty( $records ) ) {
505513
$sites_paths = array_column( $records, 'site_fs_path' );
506-
$fs = new Filesystem();
507514
$fs->remove( $sites_paths );
508515
}
509516

510-
EE::exec( "rm -rf " . EE_ROOT_DIR );
517+
$fs->remove( EE_ROOT_DIR );
511518

512519
if ( Utils\inside_phar() ) {
513520
unlink( realpath( $_SERVER['argv'][0] ) );

0 commit comments

Comments
 (0)