71 lines
2.1 KiB
Bash
71 lines
2.1 KiB
Bash
#!/bin/bash
|
|
cd /home/container
|
|
|
|
# Set environment variable that holds the Internal Docker IP
|
|
INTERNAL_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
|
|
export INTERNAL_IP
|
|
|
|
# DotNet environment setup
|
|
export DOTNET_ROOT=/usr/share/
|
|
|
|
# Fix X11 permissions
|
|
mkdir -p /tmp/.X11-unix
|
|
chmod 1777 /tmp/.X11-unix
|
|
|
|
# Start Xvfb for Wine (virtual display)
|
|
Xvfb :99 -screen 0 1024x768x16 -ac &
|
|
export DISPLAY=:99.0
|
|
sleep 3
|
|
|
|
# Wine configuration
|
|
export WINEARCH=win64
|
|
export WINEPREFIX=/home/container/.wine
|
|
export WINEDLLOVERRIDES="mscoree,mshtml="
|
|
|
|
# Always reinitialize Wine prefix to ensure it works
|
|
echo "Reinitializing Wine prefix..."
|
|
rm -rf "$WINEPREFIX"
|
|
|
|
# Initialize Wine prefix with timeout to prevent hanging
|
|
echo "Creating Wine prefix..."
|
|
timeout 60 wine wineboot --init || echo "Wine initialization timed out, continuing..."
|
|
|
|
# Wait for Wine to settle
|
|
sleep 5
|
|
|
|
# Test if Wine works
|
|
echo "Testing Wine..."
|
|
if timeout 10 wine cmd /c "echo Wine works"; then
|
|
echo "Wine test successful"
|
|
|
|
# Install .NET Runtime for Windows in Wine
|
|
echo "Installing .NET Runtime for Windows..."
|
|
cd /tmp
|
|
wget -q https://download.microsoft.com/download/6/6/1/661c9a9c-9c54-4f8b-b1c6-89d88c0f3d68/dotnet-runtime-9.0.6-win-x64.exe
|
|
timeout 120 wine dotnet-runtime-9.0.6-win-x64.exe /quiet /install || echo "Runtime installation timed out"
|
|
rm -f dotnet-runtime-9.0.6-win-x64.exe
|
|
|
|
# Also install .NET SDK for Windows
|
|
echo "Installing .NET SDK for Windows..."
|
|
wget -q https://builds.dotnet.microsoft.com/dotnet/Sdk/9.0.301/dotnet-sdk-9.0.301-win-x64.exe
|
|
timeout 120 wine dotnet-sdk-9.0.301-win-x64.exe /quiet /install || echo "SDK installation timed out"
|
|
rm -f dotnet-sdk-9.0.301-win-x64.exe
|
|
|
|
cd /home/container
|
|
else
|
|
echo "Wine test failed, but continuing..."
|
|
fi
|
|
|
|
# Print versions
|
|
printf "\033[1m\033[33mcontainer@pelican~ \033[0mdotnet --version\n"
|
|
dotnet --version
|
|
|
|
printf "\033[1m\033[33mcontainer@pelican~ \033[0mwine --version\n"
|
|
wine --version
|
|
|
|
# Replace Startup Variables
|
|
MODIFIED_STARTUP=$(echo -e ${STARTUP} | sed -e 's/{{/${/g' -e 's/}}/}/g')
|
|
echo -e ":/home/container$ ${MODIFIED_STARTUP}"
|
|
|
|
# Run the Server
|
|
eval ${MODIFIED_STARTUP} |