Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ci/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ 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
php -dphar.readonly=0 ./utils/make-phar.php easyengine.phar --quiet

# Checking the phar is working.
./easyengine.phar cli info
54 changes: 37 additions & 17 deletions php/EE/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,48 @@ 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.' );
}
$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 = 'docker ps > /dev/null';
if ( ! EE::exec( $docker_running ) ) {
$status = 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 ) );
}

return $status;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions php/commands/src/CLI_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -493,6 +494,11 @@ 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")' );
Expand Down