From 438b3111527eca4f8f67dbc68d5395cefae267ef Mon Sep 17 00:00:00 2001 From: Apoorv Parle <19315187+apparle@users.noreply.github.com> Date: Thu, 7 Nov 2024 03:22:37 -0800 Subject: [PATCH 1/3] Also connect mastercontainer to the docker network specified by APACHE_ADDITIONAL_NETWORK Signed-off-by: Apoorv Parle <19315187+apparle@users.noreply.github.com> --- Containers/mastercontainer/start.sh | 5 +++++ php/src/Docker/DockerActionManager.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index 7dc94809abd..cbf79d753d5 100644 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -200,6 +200,11 @@ It needs to be a string with letters, numbers, hyphens and underscores. It is set to '$APACHE_ADDITIONAL_NETWORK'." exit 1 fi + tmp_out=$(sudo -u www-data docker network connect $APACHE_ADDITIONAL_NETWORK nextcloud-aio-mastercontainer 2>&1) + if [ -n "$tmp_out" ] && [[ ! "$tmp_out" =~ "nextcloud-aio-mastercontainer already exists in network $APACHE_ADDITIONAL_NETWORK" ]]; then + print_red "Unable to connect to $APACHE_ADDITIONAL_NETWORK. Cannot continue. Error: \n $tmp_out" + exit 1 + fi fi if [ -n "$TALK_PORT" ]; then if ! check_if_number "$TALK_PORT"; then diff --git a/php/src/Docker/DockerActionManager.php b/php/src/Docker/DockerActionManager.php index 4456ff6996f..31f5bee4e8b 100644 --- a/php/src/Docker/DockerActionManager.php +++ b/php/src/Docker/DockerActionManager.php @@ -899,6 +899,11 @@ public function ConnectMasterContainerToNetwork() : void $this->ConnectContainerIdToNetwork('nextcloud-aio-mastercontainer', ''); // Don't disconnect here since it slows down the initial login by a lot. Is getting done during cron.sh instead. // $this->DisconnectContainerFromBridgeNetwork('nextcloud-aio-mastercontainer'); + + $apacheAdditionalNetwork = $this->configurationManager->GetApacheAdditionalNetwork(); + if ($apacheAdditionalNetwork !== '') { + $this->ConnectContainerIdToNetwork('nextcloud-aio-mastercontainer', '', $apacheAdditionalNetwork, false); + } } public function ConnectContainerToNetwork(Container $container) : void From c9a6b1b70fd7e5de1e804601e8755022b2637af1 Mon Sep 17 00:00:00 2001 From: Apoorv Parle <19315187+apparle@users.noreply.github.com> Date: Mon, 11 Nov 2024 02:31:40 -0800 Subject: [PATCH 2/3] Use exit code to check if network was connected. Signed-off-by: Apoorv Parle <19315187+apparle@users.noreply.github.com> --- Containers/mastercontainer/start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index cbf79d753d5..cfed91239b9 100644 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -200,9 +200,9 @@ It needs to be a string with letters, numbers, hyphens and underscores. It is set to '$APACHE_ADDITIONAL_NETWORK'." exit 1 fi - tmp_out=$(sudo -u www-data docker network connect $APACHE_ADDITIONAL_NETWORK nextcloud-aio-mastercontainer 2>&1) - if [ -n "$tmp_out" ] && [[ ! "$tmp_out" =~ "nextcloud-aio-mastercontainer already exists in network $APACHE_ADDITIONAL_NETWORK" ]]; then - print_red "Unable to connect to $APACHE_ADDITIONAL_NETWORK. Cannot continue. Error: \n $tmp_out" + tmp_out=$(sudo -u www-data docker network connect "$APACHE_ADDITIONAL_NETWORK" nextcloud-aio-mastercontainer 2>&1) + if [ "$?" -ne 0 ] && [[ ! "$tmp_out" == *"nextcloud-aio-mastercontainer already exists in network $APACHE_ADDITIONAL_NETWORK"* ]]; then + print_red "Unable to connect to $APACHE_ADDITIONAL_NETWORK. Cannot continue. Error: $tmp_out" exit 1 fi fi From 6e93fe4ef31f99c1a325d90bf7dcf9eefa817d6a Mon Sep 17 00:00:00 2001 From: Apoorv Parle <19315187+apparle@users.noreply.github.com> Date: Mon, 11 Nov 2024 03:23:16 -0800 Subject: [PATCH 3/3] Fix shellcheck issue Signed-off-by: Apoorv Parle <19315187+apparle@users.noreply.github.com> --- Containers/mastercontainer/start.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Containers/mastercontainer/start.sh b/Containers/mastercontainer/start.sh index cfed91239b9..9f73e47f5b9 100644 --- a/Containers/mastercontainer/start.sh +++ b/Containers/mastercontainer/start.sh @@ -200,10 +200,11 @@ It needs to be a string with letters, numbers, hyphens and underscores. It is set to '$APACHE_ADDITIONAL_NETWORK'." exit 1 fi - tmp_out=$(sudo -u www-data docker network connect "$APACHE_ADDITIONAL_NETWORK" nextcloud-aio-mastercontainer 2>&1) - if [ "$?" -ne 0 ] && [[ ! "$tmp_out" == *"nextcloud-aio-mastercontainer already exists in network $APACHE_ADDITIONAL_NETWORK"* ]]; then - print_red "Unable to connect to $APACHE_ADDITIONAL_NETWORK. Cannot continue. Error: $tmp_out" - exit 1 + if ! tmp_out=$(sudo -u www-data docker network connect "$APACHE_ADDITIONAL_NETWORK" nextcloud-aio-mastercontainer 2>&1); then + if [[ ! "$tmp_out" == *"nextcloud-aio-mastercontainer already exists in network $APACHE_ADDITIONAL_NETWORK"* ]]; then + print_red "Unable to connect to $APACHE_ADDITIONAL_NETWORK, cannot continue. Error: $tmp_out" + exit 1 + fi fi fi if [ -n "$TALK_PORT" ]; then