Skip to content
Merged
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
33 changes: 13 additions & 20 deletions src/Site_Command.php
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,6 +33,7 @@ class Site_Command extends EE_Command {
private $env;
private $site_conf_env;
private $proxy_type;
private $cache_type;
private $db;
private $docker;
private $level;
Expand DownExpand Up@@ -257,9 +258,7 @@ private function create_site_root() {
}

try {
$create_site_root = EE::launch( "mkdir $this->site_root", false, true );
default_debug( $create_site_root );
if ( $create_site_root->return_code ) {
if ( ! default_launch( "mkdir $this->site_root" ) ) {
return false;
}
$this->level = 1;
Expand DownExpand Up@@ -321,13 +320,12 @@ private function delete_site() {
}
}

// Cache disconnect
$network_disconnect = EE::launch( "docker network disconnect $this->site_name $this->cache_type", false, true );
default_debug( $network_disconnect );
if ( ! $network_disconnect->return_code ) {
EE::log( "[$this->site_name] Disconnected from Docker network $this->cache_type" );
} else {
EE::warning( "Error in disconnecting from Docker network $this->cache_type" );
if ( 'none' !== $this->cache_type ) {
if ( $this->docker::disconnect_network( $this->site_name, $this->cache_type ) ) {
EE::log( "[$this->site_name] Disconnected from Docker network $this->cache_type" );
} else {
EE::warning( "Error in disconnecting from Docker network $this->cache_type" );
}
}

if ( $this->docker::disconnect_network( $this->site_name, $this->proxy_type ) ) {
Expand All@@ -349,9 +347,7 @@ private function delete_site() {
}

if ( is_dir( $this->site_root ) ) {
$rmdir = EE::launch( "sudo rm -rf $this->site_root" );
if ( $rmdir ) {
EE::log( $rmdir );
if ( ! default_launch( "sudo rm -rf $this->site_root" ) ) {
EE::error( 'Could not remove site root. Please check if you have sufficient rights.' );
}
EE::log( "[$this->site_name] site root removed." );
Expand DownExpand Up@@ -442,13 +438,10 @@ private function create_etc_hosts_entry() {
$host_line = LOCALHOST_IP . "\t$this->site_name";
$etc_hosts = file_get_contents( '/etc/hosts' );
if ( ! preg_match( "/\s+$this->site_name\$/m", $etc_hosts ) ) {
$host_line .= "\n" . LOCALHOST_IP . "\tmail.$this->site_name";
$host_line .= "\n" . LOCALHOST_IP . "\tpma.$this->site_name";
$etc_hosts_entry = EE::launch(
"sudo /bin/bash -c 'echo \"$host_line\" >> /etc/hosts'", false, true
);
default_debug( $etc_hosts_entry );
if ( ! $etc_hosts_entry->return_code ) {
$host_line .= "\n" . LOCALHOST_IP . "\tmail.$this->site_name";
$host_line .= "\n" . LOCALHOST_IP . "\tpma.$this->site_name";

if ( default_launch( "sudo /bin/bash -c 'echo \"$host_line\" >> /etc/hosts'" ) ) {
EE::success( 'Host entry successfully added.' );
} else {
EE::warning( "Failed to add $this->site_name in host entry, Please do it manually!" );
Expand Down