From cb9cc21a71482ae7639818d8ad5deb9e630b2480 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Wed, 19 Aug 2026 10:10:27 +0530 Subject: [PATCH] FIX: #0 Move Nginx helper Python script out of workflow YAML to avoid syntax error --- .forgejo/workflows/beta.yml | 24 +----------------------- dev/setup/nginx/setup_nginx.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 dev/setup/nginx/setup_nginx.py diff --git a/.forgejo/workflows/beta.yml b/.forgejo/workflows/beta.yml index b910643240f..bea920977de 100644 --- a/.forgejo/workflows/beta.yml +++ b/.forgejo/workflows/beta.yml @@ -52,29 +52,7 @@ jobs: chmod 666 /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php # ── Configure Nginx ───────────────────────────────────────── - sudo python3 -c " -import sys -filepath = '/etc/nginx/sites-available/default' -content = open(filepath).read() -if 'location ^~ /dolibarrbeta' not in content: - idx = content.find('location / {') - if idx != -1: - block = r'''location ^~ /dolibarrbeta { - alias /home/ubuntu/dolibarrbeta/htdocs; - index index.php; - try_files \$uri \$uri/ /dolibarrbeta/index.php?\$args; - - location ~ \.php$ { - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME \$request_filename; - fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; - } - } - - ''' - content = content[:idx] + block + content[idx:] - open('/tmp/default', 'w').write(content) -" + sudo python3 /home/ubuntu/dolibarrbeta/dev/setup/nginx/setup_nginx.py if [ -f /tmp/default ]; then sudo mv /tmp/default /etc/nginx/sites-available/default sudo nginx -t diff --git a/dev/setup/nginx/setup_nginx.py b/dev/setup/nginx/setup_nginx.py new file mode 100644 index 00000000000..57d4fe1b2b5 --- /dev/null +++ b/dev/setup/nginx/setup_nginx.py @@ -0,0 +1,31 @@ +import os + +filepath = '/etc/nginx/sites-available/default' + +if os.path.exists(filepath): + content = open(filepath).read() + if 'location ^~ /dolibarrbeta' not in content: + idx = content.find('location / {') + if idx != -1: + block = """location ^~ /dolibarrbeta { + alias /home/ubuntu/dolibarrbeta/htdocs; + index index.php; + try_files $uri $uri/ /dolibarrbeta/index.php?$args; + + location ~ \.php$ { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $request_filename; + fastcgi_pass unix:/var/run/php/php8.3-fpm.sock; + } + } + + """ + content = content[:idx] + block + content[idx:] + open('/tmp/default', 'w').write(content) + print("Nginx config generated at /tmp/default") + else: + print("Error: Could not find 'location / {' in Nginx config") + else: + print("Dolibarrbeta location block already configured in Nginx") +else: + print(f"Error: {filepath} not found")