Skip to content
Merged
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
#!/bin/bash
s=/mnt/vrising/server
p=/mnt/vrising/persistentdata
echo "Setting timezone to $TZ"
echo $TZ > /etc/timezone 2>&1
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime 2>&1
dpkg-reconfigure -f noninteractive tzdata 2>&1

term_handler() {
echo "Shutting down Server"

PID=$(pgrep -f "^${s}/VRisingServer.exe")
kill -n 15 $PID
wait $PID
wineserver -k
sleep 1
exit
}

trap 'term_handler' SIGTERM

if [ ! -z $UID ]; then
usermod -u $UID docker 2>&1
fi
if [ ! -z $GID ]; then
groupmod -g $GID docker 2>&1
fi
if [ -z $SERVERNAME ]; then
if [ -z "$SERVERNAME" ]; then
SERVERNAME="trueosiris-V"
fi
if [ -z $WORLDNAME ]; then
if [ -z "$WORLDNAME" ]; then
WORLDNAME="world1"
fi
game_port=""
Expand All @@ -34,7 +44,7 @@ echo " "
echo "steam_appid: "`cat $s/steam_appid.txt`

echo " "
if ! grep -o 'avx[^ ]*' /proc/cpuinfo; then
if ! grep -q -o 'avx[^ ]*' /proc/cpuinfo; then
unsupported_file="VRisingServer_Data/Plugins/x86_64/lib_burst_generated.dll"
echo "AVX or AVX2 not supported; Check if unsupported ${unsupported_file} exists"
if [ -f "${s}/${unsupported_file}" ]; then
Expand All @@ -53,6 +63,14 @@ if [ ! -f "$p/Settings/ServerHostSettings.json" ]; then
echo "$p/Settings/ServerHostSettings.json not found. Copying default file."
cp "$s/VRisingServer_Data/StreamingAssets/Settings/ServerHostSettings.json" "$p/Settings/" 2>&1
fi

# Checks if log file exists, if not creates it
# Needed for fresh install
if ! [ -f "${p}/VRisingServer.log" ]; then
echo "Creating ${p}/VRisingServer.log"
touch $p/VRisingServer.log
fi

cd "$s"
echo "Starting V Rising Dedicated Server with name $SERVERNAME"
echo "Trying to remove /tmp/.X0-lock"
Expand All @@ -62,6 +80,11 @@ echo "Starting Xvfb"
Xvfb :0 -screen 0 1024x768x16 &
echo "Launching wine64 V Rising"
echo " "
DISPLAY=:0.0 wine64 /mnt/vrising/server/VRisingServer.exe -persistentDataPath $p -serverName "$SERVERNAME" -saveName "$WORLDNAME" -logFile "$p/VRisingServer.log" "$game_port" "$query_port" 2>&1
/usr/bin/tail -f /mnt/vrising/persistentdata/VRisingServer.log
DISPLAY=:0.0 wine64 /mnt/vrising/server/VRisingServer.exe -persistentDataPath $p -serverName "$SERVERNAME" -saveName "$WORLDNAME" -logFile "$p/VRisingServer.log" "$game_port" "$query_port" 2>&1 &

Comment on lines -66 to +85
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if its worth it, but can we have logs saved for last 3 runs?

like using VRisingServer-$(date +'%Y%m%d-%H%M').log (example: VRisingServer-20240513-2348.log)

We can maybe cleanup old logs when the script starts. This is helpful in case someone needs to go over old logs after starting a server.

Scenario:

  • User started server
  • Realized that the server didn't exit correctly / Crashed
  • Tries to figure out what happened by going over old logs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think VRisingServer.log is ever wiped, every time the server starts it seems that it just writes to the end of the file, that said, it would be better if each run had their logs split by files, i will see what i can come up with.

# Gets the PID of the last command
ServerPID=$!

# Tail log file and waits for Server PID to exit
/usr/bin/tail -n 0 -f $p/VRisingServer.log &
wait $ServerPID