forked from lloesche/valheim-server-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
valheim-server
executable file
·40 lines (36 loc) · 1.03 KB
/
valheim-server
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
#!/bin/bash
cd /opt/valheim
valheim_server="/opt/valheim/valheim_server.x86_64"
valheim_server_pid=-1
SERVER_NAME=${SERVER_NAME:-My Server}
SERVER_PORT=${SERVER_PORT:-2456}
WORLD_NAME=${WORLD_NAME:-Dedicated}
SERVER_PASS=${SERVER_PASS:-secret}
SERVER_PUBLIC=${SERVER_PUBLIC:-1}
export SteamAppId=892970
export LD_LIBRARY_PATH="/opt/valheim/linux64/"
main() {
while :; do
if [ -f "$valheim_server" ]; then
break
else
echo "Valheim Server is not yet downloaded - waiting"
sleep 10
fi
done
echo "Running Valheim Server"
"$valheim_server" -name "$SERVER_NAME" -port $SERVER_PORT -world "$WORLD_NAME" -password "$SERVER_PASS" -public $SERVER_PUBLIC &
valheim_server_pid=$!
wait
}
shutdown() {
echo "Shutting down Valheim Server with PID $valheim_server_pid"
echo 1 > /opt/valheim/server_exit.drp
while [ -d "/proc/$valheim_server_pid" ]; do
echo "Waiting for Valheim Server shutdown"
sleep 1
done
exit
}
trap shutdown SIGINT SIGTERM
main