Refactor entrypoint script: enhance X11 permissions handling, streamline Wine initialization, and improve error handling for Wine test

This commit is contained in:
2025-07-07 13:57:52 +02:00
parent ec3cb05297
commit 8fc5c7c334

View File

@@ -8,12 +8,13 @@ export INTERNAL_IP
# set this variable, dotnet needs it even without it it reports to `dotnet --info` it can not start any aplication without this
export DOTNET_ROOT=/usr/share/
# Fix X11 permissions
mkdir -p /tmp/.X11-unix
chmod 1777 /tmp/.X11-unix
# Fix X11 permissions (run as root first)
sudo mkdir -p /tmp/.X11-unix
sudo chmod 1777 /tmp/.X11-unix
sudo chown root:root /tmp/.X11-unix
# Start Xvfb for Wine (virtual display)
Xvfb :99 -screen 0 1024x768x16 &
Xvfb :99 -screen 0 1024x768x16 -ac &
export DISPLAY=:99.0
# Wait for Xvfb to start
@@ -26,29 +27,28 @@ rm -rf "$WINEPREFIX"
# Set Wine architecture to 64-bit
export WINEARCH=win64
# Initialize Wine prefix
# Set Wine to run in headless mode
export WINE_VNC_NOVNC=1
export WINE_VNC_DEPTH=16
# Initialize Wine prefix with minimal configuration
echo "Creating new Wine prefix..."
wineboot --init
wineboot --init 2>/dev/null &
# Wait for wineboot to complete
sleep 10
# Test if Wine can load basic Windows DLLs
echo "Testing Wine installation..."
if ! wine cmd /c "echo Wine test successful"; then
echo "Wine initialization failed, trying again..."
rm -rf "$WINEPREFIX"
wineboot --init
# Wait for wineboot process to complete
sleep 15
# Try again
if ! wine cmd /c "echo Wine test successful"; then
echo "Wine installation appears to be broken"
exit 1
fi
fi
# Kill any remaining Wine processes
pkill -f wine
# Try a simple Wine command to verify it works
echo "Testing Wine installation..."
timeout 30 wine cmd /c "echo Wine test successful" 2>/dev/null
if [ $? -eq 0 ]; then
echo "Wine initialization complete and verified."
else
echo "Wine test failed, but continuing anyway..."
fi
# print the dotnet version on startup
printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n"