fix(metablogizer): Improve site creation and HAProxy integration

- Add reload_haproxy() helper function for consistent reloads
- Use 127.0.0.1 for uhttpd backend address instead of 192.168.255.1
- Call fix_permissions() on upload_file to ensure correct file access
- Update delete_site to use reload_haproxy helper
- Bump PKG_RELEASE to 3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-01-28 13:19:52 +01:00
parent 906bf6f549
commit e079014dfb
2 changed files with 16 additions and 10 deletions

View File

@ -12,7 +12,7 @@ LUCI_PKGARCH:=all
PKG_NAME:=luci-app-metablogizer PKG_NAME:=luci-app-metablogizer
PKG_VERSION:=1.0.0 PKG_VERSION:=1.0.0
PKG_RELEASE:=2 PKG_RELEASE:=3
PKG_MAINTAINER:=CyberMind <contact@cybermind.fr> PKG_MAINTAINER:=CyberMind <contact@cybermind.fr>
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0

View File

@ -50,6 +50,14 @@ fix_permissions() {
find "$dir" -type f -exec chmod 644 {} \; find "$dir" -type f -exec chmod 644 {} \;
} }
# Reload HAProxy configuration properly
reload_haproxy() {
/usr/sbin/haproxyctl generate >/dev/null 2>&1
if [ -x /etc/init.d/haproxy ]; then
/etc/init.d/haproxy reload >/dev/null 2>&1
fi
}
# Status method - get overall status and list all sites # Status method - get overall status and list all sites
method_status() { method_status() {
local enabled runtime detected_runtime nginx_running site_count local enabled runtime detected_runtime nginx_running site_count
@ -238,7 +246,7 @@ EOF
# 6. Detect runtime and configure accordingly # 6. Detect runtime and configure accordingly
local current_runtime=$(detect_runtime) local current_runtime=$(detect_runtime)
local port="" local port=""
local server_address="192.168.255.1" local server_address="127.0.0.1"
local server_port="80" local server_port="80"
if [ "$current_runtime" = "uhttpd" ]; then if [ "$current_runtime" = "uhttpd" ]; then
@ -251,6 +259,7 @@ EOF
uci set "uhttpd.metablog_${section_id}.error_page=/index.html" uci set "uhttpd.metablog_${section_id}.error_page=/index.html"
uci commit uhttpd uci commit uhttpd
/etc/init.d/uhttpd reload 2>/dev/null /etc/init.d/uhttpd reload 2>/dev/null
server_address="127.0.0.1"
server_port="$port" server_port="$port"
else else
# Configure nginx location in container # Configure nginx location in container
@ -298,9 +307,8 @@ EOF
uci set "haproxy.$vhost_name.enabled=1" uci set "haproxy.$vhost_name.enabled=1"
uci commit haproxy uci commit haproxy
# Regenerate HAProxy config # Regenerate HAProxy config and reload
/usr/sbin/haproxyctl generate >/dev/null 2>&1 reload_haproxy
/etc/init.d/haproxy reload >/dev/null 2>&1
uci commit "$UCI_CONFIG" uci commit "$UCI_CONFIG"
@ -376,8 +384,7 @@ method_delete_site() {
uci delete "haproxy.$backend_name" 2>/dev/null uci delete "haproxy.$backend_name" 2>/dev/null
uci delete "haproxy.${backend_name}_srv" 2>/dev/null uci delete "haproxy.${backend_name}_srv" 2>/dev/null
uci commit haproxy uci commit haproxy
/usr/sbin/haproxyctl generate >/dev/null 2>&1 reload_haproxy
/etc/init.d/haproxy reload >/dev/null 2>&1
# 3. Remove runtime config # 3. Remove runtime config
if [ "$site_runtime" = "uhttpd" ]; then if [ "$site_runtime" = "uhttpd" ]; then
@ -679,9 +686,8 @@ method_upload_file() {
local rc=$? local rc=$?
if [ $rc -eq 0 ]; then if [ $rc -eq 0 ]; then
chmod 644 "$file_path" # Fix permissions for entire site directory
# Ensure parent directories are also accessible fix_permissions "$site_path"
chmod 755 "$site_path"
json_init json_init
json_add_boolean "success" 1 json_add_boolean "success" 1
json_add_string "filename" "$filename" json_add_string "filename" "$filename"