diff --git a/Updated_Cms/setup_linux_nginx.sh b/Updated_Cms/setup_linux_nginx.sh index b604671ff3..8c21ba398e 100644 --- a/Updated_Cms/setup_linux_nginx.sh +++ b/Updated_Cms/setup_linux_nginx.sh @@ -87,3 +87,23 @@ sudo systemctl enable --now "php${PHP_VERSION}-fpm" echo "Setup complete. If using a domain, update DNS. Visit http://${SERVER_NAME}/" +# SSL Setup Prompt +echo "" +read -p "Do you want to setup SSL with Let's Encrypt? (y/n) " SETUP_SSL +if [[ "$SETUP_SSL" =~ ^[Yy]$ ]]; then + if [ "${SERVER_NAME}" = "_" ] || [ "${SERVER_NAME}" = "localhost" ]; then + echo "Error: Cannot setup SSL for server name '${SERVER_NAME}'. Please provide a valid domain name when running the script." + echo "Usage: ./setup_linux_nginx.sh " + else + echo "Installing Certbot..." + sudo apt-get install -y certbot python3-certbot-nginx + + echo "Running Certbot for ${SERVER_NAME}..." + # Running non-interactively where possible, but certbot often requires email/tos interaction on first run. + # We assume the user is running this interactively. + sudo certbot --nginx -d "${SERVER_NAME}" + + echo "SSL setup complete!" + fi +fi +