diff --git a/package/secubox/secubox-app-jabber/files/usr/sbin/jabberctl b/package/secubox/secubox-app-jabber/files/usr/sbin/jabberctl index ca436408..fac57788 100755 --- a/package/secubox/secubox-app-jabber/files/usr/sbin/jabberctl +++ b/package/secubox/secubox-app-jabber/files/usr/sbin/jabberctl @@ -226,6 +226,9 @@ SOURCES # Create startup script create_startup_script + # Create webchat interface + create_webchat + # Clean up apt cache chroot "$LXC_ROOTFS" /bin/sh -c " apt-get clean @@ -257,12 +260,14 @@ if [ ! -f /etc/prosody/prosody.cfg.lua.configured ]; then -- Global settings admins = { "${ADMIN_USER}@${XMPP_DOMAIN}" } --- Network settings +-- Network settings - bind to all interfaces interfaces = { "*" } c2s_ports = { 5222 } s2s_ports = { 5269 } http_ports = { 5280 } https_ports = { 5281 } +http_interfaces = { "*" } +https_interfaces = { "*" } -- Modules enabled globally modules_enabled = { @@ -311,8 +316,6 @@ authentication = "internal_hashed" -- Storage storage = "internal" --- storage = "sql" --- sql = { driver = "SQLite3", database = "/var/lib/prosody/prosody.sqlite" } -- Archiving (MAM) archive_expires_after = "1w" @@ -328,9 +331,15 @@ log = { -- HTTP server http_default_host = "${XMPP_DOMAIN}" http_external_url = "https://${XMPP_DOMAIN}/" -trusted_proxies = { "127.0.0.1", "::1" } +trusted_proxies = { "127.0.0.1", "::1", "192.168.255.1" } --- BOSH/Websocket +-- Static files (webchat) +http_files_dir = "/var/www/prosody" +http_paths = { + files = "/chat"; +} + +-- BOSH/Websocket CORS cross_domain_bosh = true consider_bosh_secure = true cross_domain_websocket = true @@ -382,16 +391,75 @@ fi # Ensure proper permissions chown -R prosody:prosody /var/lib/prosody chown -R prosody:prosody /var/log/prosody +chown -R prosody:prosody /var/www/prosody 2>/dev/null echo "[JABBER] Starting Prosody XMPP server..." -# Run Prosody in foreground -exec /usr/bin/prosody --no-daemonize +# Run Prosody as prosody user in foreground +exec su -s /bin/sh prosody -c "/usr/bin/prosody" STARTUP chmod +x "$LXC_ROOTFS/opt/start-jabber.sh" } +create_webchat() { + # Create webchat directory and Converse.js files + mkdir -p "$LXC_ROOTFS/var/www/prosody" + + # Download Converse.js if not exists + if [ ! -f "$LXC_ROOTFS/var/www/prosody/converse.min.js" ]; then + log_info "Downloading Converse.js web client..." + local converse_version="10.1.6" + local cdn_base="https://cdn.conversejs.org/10.1.6/dist" + + wget -q -O "$LXC_ROOTFS/var/www/prosody/converse.min.js" \ + "${cdn_base}/converse.min.js" || true + wget -q -O "$LXC_ROOTFS/var/www/prosody/converse.min.css" \ + "${cdn_base}/converse.min.css" || true + fi + + # Create index.html + defaults + cat > "$LXC_ROOTFS/var/www/prosody/index.html" < + + + + + SecuBox Chat - XMPP Web Client + + + + + + + + +WEBCHAT + + log_info "Webchat interface created at /chat/" +} + lxc_create_config() { defaults local mem_bytes=$((memory_limit * 1024 * 1024)) @@ -400,6 +468,7 @@ lxc_create_config() { ensure_dir "$data_path" ensure_dir "$data_path/data" ensure_dir "$data_path/certs" + ensure_dir "$data_path/webchat" cat > "$LXC_CONF" < your-ip"