From a5475418b7cd135f1c3f098a4c63cfc1c6b711ef Mon Sep 17 00:00:00 2001 From: udkumar Date: Tue, 21 Nov 2023 16:16:39 +0530 Subject: [PATCH] stop or remove nginx form host after nginx container ssl configuration --- docker/auto_ssl_script.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docker/auto_ssl_script.sh b/docker/auto_ssl_script.sh index 6ca14623..f2130fd6 100644 --- a/docker/auto_ssl_script.sh +++ b/docker/auto_ssl_script.sh @@ -67,6 +67,14 @@ copy_ssl_certificate() { cp -r "$cert_path" "$docker_volume_path" || { echo "Failed to copy SSL certificate"; exit 1; } } +# Stop or remove Nginx on host +stop_or_remove_nginx_host() { + echo "Stopping or removing Nginx on host..." + systemctl stop nginx || { echo "Failed to stop Nginx on host"; exit 1; } + # Remove Nginx instead of just stopping it + # apt-get remove -y nginx || { echo "Failed to remove Nginx from host"; exit 1; } +} + # Start Nginx container start_nginx_container() { echo "Starting Nginx container: $1..." @@ -79,6 +87,8 @@ setup_automatic_ssl_renewal() { (crontab -l 2>/dev/null; echo "0 3 * * * certbot renew --quiet --renew-hook 'docker restart $NGINX_CONTAINER_NAME'") | crontab - || { echo "Failed to setup automatic SSL certificate renewal"; exit 1; } } + + # Main execution stop_nginx_container "$NGINX_CONTAINER_NAME" free_up_port_80