-
Notifications
You must be signed in to change notification settings - Fork 4
/
run.sh
96 lines (82 loc) · 2.79 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Load environment variables from .env file
source /home/steam/config/.env
# Set the correct Wine prefix to use user's home directory
export WINEPREFIX=/home/steam/.wine
# Remove X Server lock
rm -rf /tmp/.X1-lock
# Set up virtual X server using Xvfb
Xvfb :1 -screen 0 1024x768x16 &
# Set the DISPLAY environment variable
export DISPLAY=:1
# Check if SteamCMD directory exists
if [ ! -d "/home/steam/steamcmd" ]; then
echo "SteamCMD directory not found. Make sure you have set up the volume correctly."
exit 1
fi
# Fix windows newline characters for steam credentials
steamusername=$(echo -n "$STEAM_USERNAME" | sed $'s/\r//')
steampassword=$(echo -n "$STEAM_PASSWORD" | sed $'s/\r//')
betaname=$(echo -n "$BETA_NAME" | sed $'s/\r//')
# Log in to SteamCMD using the provided credentials
if [ "$ENABLE_BETA" = "true" ]; then
/home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir /home/steam/battlebit +login "$steamusername" "$steampassword" +app_update 671860 -beta "$betaname" validate +quit
else
/home/steam/steamcmd/steamcmd.sh +@sSteamCmdForcePlatformType windows +force_install_dir /home/steam/battlebit +login "$steamusername" "$steampassword" +app_update 671860 validate +quit
fi
# Check if the game directory exists
if [ ! -d "/home/steam/battlebit" ]; then
echo "Game directory not found. There might be an issue with downloading the game."
exit 1
fi
# Read server configurations from /config/server.conf
if [ -f "/home/steam/config/server.conf" ]; then
source /home/steam/config/server.conf
else
echo "Server config file not found: /home/steam/config/server.conf"
exit 1
fi
# Formulate the arguments for BattleBit executable
battlebit_args=(
-batchmode
-nographics
-lowmtumode
"-Name=$Name"
"-Password=$Password"
"-AntiCheat=$AntiCheat"
"-Hz=$Hz"
"-Port=$Port"
"-MaxPing=$MaxPing"
"-LocalIP=$LocalIP"
"-VoxelMode=$VoxelMode"
"-ConfigPath=$ConfigPath"
"-ApiEndpoint=$ApiEndpoint"
"-FixedSize=$FixedSize"
"-FirstSize=$FirstSize"
"-MaxSize=$MaxSize"
"-FirstGamemode=$FirstGamemode"
"-FirstMap=$FirstMap"
)
echo "/-----------------------------/"
echo "Server Settings:"
echo "Name: $Name"
echo "Password: $Password"
echo "AntiCheat: $AntiCheat"
echo "Hz: $Hz"
echo "Port: $Port"
echo "MaxPing: $MaxPing"
echo "LocalIP: $LocalIP"
echo "VoxelMode: $VoxelMode"
echo "ConfigPath: $ConfigPath"
echo "ApiEndpoint: $ApiEndpoint"
echo "FixedSize: $FixedSize"
echo "FirstSize: $FirstSize"
echo "MaxSize: $MaxSize"
echo "FirstGamemode: $FirstGamemode"
echo "FirstMap: $FirstMap"
echo "/-----------------------------/"
echo "Launching the BattleBit game server..."
# Run the BattleBit game server using Wine with the formulated arguments
cd /home/steam/battlebit
# Redirect stdout to the log file
exec wine ./BattleBit.exe "${battlebit_args[@]}"