mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 09:35:39 +00:00
e855f5786d
Add a new betterdesk-server Go codebase (server, api, auth, db, relay, signal, metrics, audit, ratelimit, proto, tools, tests) and related deployment/migration scripts. Add a comprehensive SECURITY_AUDIT_2026-03-01 report and .gitattributes; update copilot-instructions (ALL-IN-ONE v2.4.0), README, VERSION, Dockerfiles, scripts, docker-compose and entrypoint. Large updates to web-nodejs (translations, routes, services, frontend assets and middleware) and numerous new utilities; remove legacy Flask web files and archive hbbs-patch-v2 artifacts. Prepares repository for PostgreSQL support, DB migration tooling and the new Go server as the production backend.
79 lines
2.8 KiB
Bash
79 lines
2.8 KiB
Bash
#!/bin/sh
|
|
# Docker Entrypoint for BetterDesk Console (Node.js)
|
|
# ---------------------------------------------------
|
|
# The Node.js application handles all database initialization,
|
|
# migration, and admin user creation automatically on startup.
|
|
# This script only provides logging and environment validation.
|
|
set -e
|
|
|
|
echo "========================================"
|
|
echo " BetterDesk Console - Container Startup"
|
|
echo " Version: 2.4.0 (Node.js)"
|
|
echo "========================================"
|
|
|
|
# Log configuration
|
|
echo ""
|
|
echo "Configuration:"
|
|
echo " NODE_ENV: ${NODE_ENV:-production}"
|
|
echo " PORT: ${PORT:-5000}"
|
|
echo " SERVER_BACKEND: ${SERVER_BACKEND:-betterdesk}"
|
|
echo " DB_TYPE: ${DB_TYPE:-sqlite}"
|
|
echo " RUSTDESK_PATH: ${RUSTDESK_PATH:-/opt/rustdesk}"
|
|
echo " DATA_DIR: ${DATA_DIR:-/app/data}"
|
|
echo ""
|
|
|
|
# Ensure data directories exist
|
|
mkdir -p "${DATA_DIR:-/app/data}" 2>/dev/null || true
|
|
|
|
# Wait for BetterDesk server (hbbs) to be available if using betterdesk backend
|
|
if [ "${SERVER_BACKEND}" = "betterdesk" ] && [ -n "${HBBS_API_URL}" ]; then
|
|
echo "Waiting for BetterDesk server..."
|
|
RETRIES=0
|
|
MAX_RETRIES=30
|
|
while [ "$RETRIES" -lt "$MAX_RETRIES" ]; do
|
|
if curl -sf "${HBBS_API_URL}/health" >/dev/null 2>&1 || \
|
|
curl -sf "${BETTERDESK_API_URL:-${HBBS_API_URL}}" >/dev/null 2>&1; then
|
|
echo " BetterDesk server is ready"
|
|
break
|
|
fi
|
|
RETRIES=$((RETRIES + 1))
|
|
echo " Waiting for server... ($RETRIES/$MAX_RETRIES)"
|
|
sleep 2
|
|
done
|
|
if [ "$RETRIES" -ge "$MAX_RETRIES" ]; then
|
|
echo " WARNING: BetterDesk server not reachable after ${MAX_RETRIES} attempts"
|
|
echo " Starting console anyway (some features may be unavailable)..."
|
|
fi
|
|
fi
|
|
|
|
# Wait for PostgreSQL if configured
|
|
if [ "${DB_TYPE}" = "postgresql" ] && [ -n "${DATABASE_URL}" ]; then
|
|
echo "Waiting for PostgreSQL..."
|
|
RETRIES=0
|
|
MAX_RETRIES=30
|
|
# Extract host:port from DATABASE_URL (postgres://user:pass@host:port/db)
|
|
PG_HOST=$(echo "$DATABASE_URL" | sed -n 's|.*@\([^:/]*\).*|\1|p')
|
|
PG_PORT=$(echo "$DATABASE_URL" | sed -n 's|.*:\([0-9]*\)/.*|\1|p')
|
|
PG_PORT=${PG_PORT:-5432}
|
|
while [ "$RETRIES" -lt "$MAX_RETRIES" ]; do
|
|
if nc -z "$PG_HOST" "$PG_PORT" 2>/dev/null; then
|
|
echo " PostgreSQL is ready ($PG_HOST:$PG_PORT)"
|
|
break
|
|
fi
|
|
RETRIES=$((RETRIES + 1))
|
|
echo " Waiting for PostgreSQL... ($RETRIES/$MAX_RETRIES)"
|
|
sleep 2
|
|
done
|
|
if [ "$RETRIES" -ge "$MAX_RETRIES" ]; then
|
|
echo " WARNING: PostgreSQL not reachable after ${MAX_RETRIES} attempts"
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "Starting BetterDesk Console..."
|
|
echo " Web Interface: http://localhost:${PORT:-5000}"
|
|
echo " Client API: port ${API_PORT:-21121}"
|
|
echo ""
|
|
|
|
# Start Node.js application
|
|
exec node server.js |