secubox-deb/scripts/update-debian-nginx.sh
CyberMind-FR 7c42a80baf feat: modular nginx config + hub roadmap + new modules
Nginx architecture:
- Modular config: each module installs /etc/nginx/secubox.d/<module>.conf
- Auto-register on install, auto-remove on purge
- Main config includes from secubox.d/*.conf
- 27 module snippets for dynamic component management

Hub enhancements:
- Add roadmap widget showing migration progress (84% complete)
- Add /api/v1/hub/roadmap endpoint with category breakdown
- Shared sidebar.css for consistent styling across modules

New modules:
- secubox-portal: JWT authentication, session management
- secubox-dns: DNS server management
- secubox-mail: Mail server (Postfix) management
- secubox-webmail: Roundcube webmail
- secubox-users: User account management
- secubox-publish: Content publishing
- secubox-waf: Web Application Firewall
- secubox-mail-lxc: Mail LXC container
- secubox-webmail-lxc: Webmail LXC container

Debian packaging:
- All modules updated with modular nginx support
- postinst: creates secubox.d/, reloads nginx
- prerm: removes snippet, reloads nginx
- rules: installs nginx/<module>.conf

Scripts:
- new-package.sh: generates modular nginx files for new modules
- retrofit-nginx-modular.sh: updates existing packages

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-03-21 20:34:01 +01:00

68 lines
2.6 KiB
Bash

#!/bin/bash
# Update debian packaging for modular nginx configuration
# Each module installs /etc/nginx/secubox.d/<module>.conf
BASEDIR="/home/reepost/CyberMindStudio/secubox-deb/secubox-deb"
modules="hub crowdsec netdata wireguard dpi netmodes nac auth qos mediaflow cdn vhost system waf portal dns haproxy droplet metablogizer publish streamlit streamforge mail webmail mail-lxc webmail-lxc users"
for mod in $modules; do
PKG_DIR="$BASEDIR/packages/secubox-$mod"
PKG_NAME="secubox-$mod"
if [ ! -d "$PKG_DIR/debian" ]; then
echo "SKIP: $mod (no debian dir)"
continue
fi
# ── Update debian/rules ──
RULES="$PKG_DIR/debian/rules"
if [ -f "$RULES" ]; then
# Check if nginx install already exists
if ! grep -q "nginx/secubox.d" "$RULES"; then
# Add nginx snippet installation before the last line
sed -i '/^override_dh_auto_install:/,/^[a-z]/ {
/\[ -d menu.d \]/ a\
install -d debian/'"$PKG_NAME"'/etc/nginx/secubox.d\
[ -f nginx/'"$mod"'.conf ] \&\& cp nginx/'"$mod"'.conf debian/'"$PKG_NAME"'/etc/nginx/secubox.d/ || true
}' "$RULES"
echo "OK: $mod - debian/rules updated"
else
echo "SKIP: $mod - debian/rules already has nginx"
fi
fi
# ── Update debian/postinst ──
POSTINST="$PKG_DIR/debian/postinst"
if [ -f "$POSTINST" ]; then
# Check if secubox.d mkdir already exists
if ! grep -q "secubox.d" "$POSTINST"; then
# Add before systemctl reload nginx
sed -i 's|systemctl reload nginx|install -d -m 755 /etc/nginx/secubox.d\n systemctl reload nginx|' "$POSTINST"
echo "OK: $mod - debian/postinst updated"
else
echo "SKIP: $mod - debian/postinst already has secubox.d"
fi
fi
# ── Update debian/prerm ──
PRERM="$PKG_DIR/debian/prerm"
if [ -f "$PRERM" ]; then
# Check if nginx snippet removal already exists
if ! grep -q "secubox.d/$mod.conf" "$PRERM"; then
# Add snippet removal before systemctl stop
sed -i "/systemctl stop/i\\ rm -f /etc/nginx/secubox.d/$mod.conf" "$PRERM"
# Add nginx reload after systemctl stop
if ! grep -q "reload nginx" "$PRERM"; then
sed -i "/systemctl stop/a\\ systemctl reload nginx 2>/dev/null || true" "$PRERM"
fi
echo "OK: $mod - debian/prerm updated"
else
echo "SKIP: $mod - debian/prerm already handles nginx"
fi
fi
done
echo ""
echo "Done. Verify changes with: git diff packages/*/debian/"