FIX: #0 Move Nginx helper Python script out of workflow YAML to avoid syntax error
Some checks failed
Deploy Beta (NATIVE) / deploy (push) Failing after 1m14s
Some checks failed
Deploy Beta (NATIVE) / deploy (push) Failing after 1m14s
This commit is contained in:
parent
99e45725bf
commit
cb9cc21a71
2 changed files with 32 additions and 23 deletions
|
|
@ -52,29 +52,7 @@ jobs:
|
||||||
chmod 666 /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php
|
chmod 666 /home/ubuntu/dolibarrbeta/htdocs/conf/conf.php
|
||||||
|
|
||||||
# ── Configure Nginx ─────────────────────────────────────────
|
# ── Configure Nginx ─────────────────────────────────────────
|
||||||
sudo python3 -c "
|
sudo python3 /home/ubuntu/dolibarrbeta/dev/setup/nginx/setup_nginx.py
|
||||||
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)
|
|
||||||
"
|
|
||||||
if [ -f /tmp/default ]; then
|
if [ -f /tmp/default ]; then
|
||||||
sudo mv /tmp/default /etc/nginx/sites-available/default
|
sudo mv /tmp/default /etc/nginx/sites-available/default
|
||||||
sudo nginx -t
|
sudo nginx -t
|
||||||
|
|
|
||||||
31
dev/setup/nginx/setup_nginx.py
Normal file
31
dev/setup/nginx/setup_nginx.py
Normal file
|
|
@ -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")
|
||||||
Loading…
Reference in a new issue