mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
Remove xvfb code and wine related stuff
This commit is contained in:
parent
a24318eedc
commit
ca13076b03
|
|
@ -8,7 +8,6 @@ SERVER_PORT="25565"
|
||||||
SERVER_BIND_IP="0.0.0.0"
|
SERVER_BIND_IP="0.0.0.0"
|
||||||
|
|
||||||
PERSIST_DIR="/srv/persist"
|
PERSIST_DIR="/srv/persist"
|
||||||
WINE_CMD=""
|
|
||||||
|
|
||||||
ensure_persist_file() {
|
ensure_persist_file() {
|
||||||
local persist_path="$1"
|
local persist_path="$1"
|
||||||
|
|
@ -30,64 +29,6 @@ ensure_persist_file() {
|
||||||
ln -sfn "${persist_path}" "${runtime_path}"
|
ln -sfn "${persist_path}" "${runtime_path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_xvfb_ready() {
|
|
||||||
local display="$1"
|
|
||||||
local xvfb_pid="$2"
|
|
||||||
local wait_seconds="${XVFB_WAIT_SECONDS:-10}"
|
|
||||||
local wait_ticks=$((wait_seconds * 10))
|
|
||||||
local display_number="${display#:}"
|
|
||||||
display_number="${display_number%%.*}"
|
|
||||||
|
|
||||||
if [ -z "${display_number}" ] || ! [[ "${display_number}" =~ ^[0-9]+$ ]]; then
|
|
||||||
echo "[error] Invalid DISPLAY format for Xvfb wait: ${display}" >&2
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
local socket_path="/tmp/.X11-unix/X${display_number}"
|
|
||||||
local elapsed=0
|
|
||||||
|
|
||||||
while [ "${elapsed}" -lt "${wait_ticks}" ]; do
|
|
||||||
if ! kill -0 "${xvfb_pid}" 2>/dev/null; then
|
|
||||||
echo "[error] Xvfb exited before the display became ready." >&2
|
|
||||||
if [ -f /tmp/xvfb.log ]; then
|
|
||||||
echo "[error] ---- /tmp/xvfb.log ----" >&2
|
|
||||||
tail -n 200 /tmp/xvfb.log >&2 || true
|
|
||||||
echo "[error] ----------------------" >&2
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -S "${socket_path}" ]; then
|
|
||||||
# Keep a short extra delay so Wine does not race display handshake.
|
|
||||||
sleep 0.2
|
|
||||||
if kill -0 "${xvfb_pid}" 2>/dev/null && [ -S "${socket_path}" ]; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# One more liveness check after the ready probe branch.
|
|
||||||
if ! kill -0 "${xvfb_pid}" 2>/dev/null; then
|
|
||||||
echo "[error] Xvfb exited during display readiness probe." >&2
|
|
||||||
if [ -f /tmp/xvfb.log ]; then
|
|
||||||
echo "[error] ---- /tmp/xvfb.log ----" >&2
|
|
||||||
tail -n 200 /tmp/xvfb.log >&2 || true
|
|
||||||
echo "[error] ----------------------" >&2
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
sleep 0.1
|
|
||||||
elapsed=$((elapsed + 1))
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "[error] Timed out waiting for Xvfb display ${display}." >&2
|
|
||||||
if [ -f /tmp/xvfb.log ]; then
|
|
||||||
echo "[error] ---- /tmp/xvfb.log ----" >&2
|
|
||||||
tail -n 200 /tmp/xvfb.log >&2 || true
|
|
||||||
echo "[error] ----------------------" >&2
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ ! -d "$SERVER_DIR" ]; then
|
if [ ! -d "$SERVER_DIR" ]; then
|
||||||
echo "[error] Server directory not found: $SERVER_DIR" >&2
|
echo "[error] Server directory not found: $SERVER_DIR" >&2
|
||||||
|
|
@ -117,47 +58,13 @@ if [ -e "Windows64/GameHDD" ] && [ ! -L "Windows64/GameHDD" ]; then
|
||||||
fi
|
fi
|
||||||
ln -sfn "${PERSIST_DIR}/GameHDD" "Windows64/GameHDD"
|
ln -sfn "${PERSIST_DIR}/GameHDD" "Windows64/GameHDD"
|
||||||
|
|
||||||
# for compatibility with other images
|
# do umu-run stuff
|
||||||
if command -v wine64 >/dev/null 2>&1; then
|
|
||||||
WINE_CMD="wine64"
|
|
||||||
elif [ -x "/usr/lib/wine/wine64" ]; then
|
|
||||||
WINE_CMD="/usr/lib/wine/wine64"
|
|
||||||
elif command -v wine >/dev/null 2>&1; then
|
|
||||||
WINE_CMD="wine"
|
|
||||||
else
|
|
||||||
echo "[error] No Wine executable found (wine64/wine)." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "${WINEPREFIX}" ] || [ -z "$(ls -A "${WINEPREFIX}" 2>/dev/null)" ]; then
|
if [ ! -d "${WINEPREFIX}" ] || [ -z "$(ls -A "${WINEPREFIX}" 2>/dev/null)" ]; then
|
||||||
mkdir -p "${WINEPREFIX}"
|
mkdir -p "${WINEPREFIX}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# in the current implementation, a virtual screen is required because the client-side logic is being called for compatibility
|
|
||||||
if [ -z "${DISPLAY:-}" ]; then
|
|
||||||
export DISPLAY="${XVFB_DISPLAY:-:99}"
|
|
||||||
XVFB_SCREEN="${XVFB_SCREEN:-64x64x16}"
|
|
||||||
DISPLAY_NUMBER="${DISPLAY#:}"
|
|
||||||
DISPLAY_NUMBER="${DISPLAY_NUMBER%%.*}"
|
|
||||||
if [ -z "${DISPLAY_NUMBER}" ] || ! [[ "${DISPLAY_NUMBER}" =~ ^[0-9]+$ ]]; then
|
|
||||||
echo "[error] Invalid XVFB_DISPLAY format: ${DISPLAY}" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
XVFB_SOCKET="/tmp/.X11-unix/X${DISPLAY_NUMBER}"
|
|
||||||
XVFB_LOCK="/tmp/.X${DISPLAY_NUMBER}-lock"
|
|
||||||
# The check is performed assuming the same container will be restarted.
|
|
||||||
if [ -S "${XVFB_SOCKET}" ] || [ -e "${XVFB_LOCK}" ]; then
|
|
||||||
echo "[warn] Removing stale Xvfb state for ${DISPLAY} before startup." >&2
|
|
||||||
rm -f "${XVFB_SOCKET}" "${XVFB_LOCK}"
|
|
||||||
fi
|
|
||||||
Xvfb "${DISPLAY}" -nolisten tcp -screen 0 "${XVFB_SCREEN}" >/tmp/xvfb.log 2>&1 &
|
|
||||||
XVFB_PID=$!
|
|
||||||
wait_for_xvfb_ready "${DISPLAY}" "${XVFB_PID}"
|
|
||||||
echo "[info] Xvfb ready on ${DISPLAY} (pid=${XVFB_PID}, screen=${XVFB_SCREEN})"
|
|
||||||
else
|
|
||||||
echo "[info] Using existing DISPLAY=${DISPLAY}; skipping Xvfb startup"
|
|
||||||
fi
|
|
||||||
|
|
||||||
args=(
|
args=(
|
||||||
-port "${SERVER_PORT}"
|
-port "${SERVER_PORT}"
|
||||||
-bind "${SERVER_BIND_IP}"
|
-bind "${SERVER_BIND_IP}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue