Remnawave_Node/docker-entrypoint.sh
2026-03-03 05:54:20 +03:00

61 lines
No EOL
1.7 KiB
Bash

#!/bin/sh
rm -f /run/remnawave-internal-*.sock 2>/dev/null
rm -f /run/supervisord-*.sock 2>/dev/null
rm -f /run/supervisord-*.pid 2>/dev/null
echo "[Entrypoint] Starting entrypoint script..."
generate_random() {
local length="${1:-64}"
tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c "$length"
}
RNDSTR=$(generate_random 10)
SUPERVISORD_USER=$(generate_random 64)
SUPERVISORD_PASSWORD=$(generate_random 64)
INTERNAL_REST_TOKEN=$(generate_random 64)
INTERNAL_SOCKET_PATH=/run/remnawave-internal-${RNDSTR}.sock
SUPERVISORD_SOCKET_PATH=/run/supervisord-${RNDSTR}.sock
SUPERVISORD_PID_PATH=/run/supervisord-${RNDSTR}.pid
export SUPERVISORD_USER
export SUPERVISORD_PASSWORD
export INTERNAL_REST_TOKEN
export INTERNAL_SOCKET_PATH
export SUPERVISORD_SOCKET_PATH
export SUPERVISORD_PID_PATH
echo "[Entrypoint] Getting Supervisord version..."
echo "[Entrypoint] Supervisord version: $(supervisord --version | head -n 1)"
supervisord -c /etc/supervisord.conf &
echo "[Entrypoint] Supervisord started successfully"
sleep 1
if [ -n "$CUSTOM_CORE_URL" ]; then
echo "[Entrypoint] CUSTOM_CORE_URL is set, downloading custom core from: $CUSTOM_CORE_URL"
rm -f /usr/local/bin/xray
if wget -q -O /usr/local/bin/xray "$CUSTOM_CORE_URL"; then
chmod +x /usr/local/bin/xray
echo "[Entrypoint] Custom core downloaded and installed successfully"
else
echo "[Entrypoint] ERROR: Failed to download custom core from: $CUSTOM_CORE_URL"
exit 1
fi
fi
echo "[Entrypoint] Getting Xray version..."
XRAY_CORE_VERSION=$(/usr/local/bin/rw-core version | head -n 1)
export XRAY_CORE_VERSION
echo "[Entrypoint] Xray version: $XRAY_CORE_VERSION"
echo "[Ports] XTLS_API_PORT: $XTLS_API_PORT"
echo "[Entrypoint] Executing command: $@"
exec "$@"