forked from thorkseng/pi4valheim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap
executable file
·124 lines (104 loc) · 4.85 KB
/
bootstrap
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Get parameters function
# This function will check all the parameters
# Return:
# string: params to run the server
# int: -1 is something is wrong.
getparams() {
# Basic + default params values same order that PDF:
## -nographics: basic param for the valheim documentation.
## -batchmode: basic param for the valheim documentation.
params="-nographics -batchmode"
## -name: Name of the server:
## Enter the name of your server that will be visible in the Server list.
if [[ -z "${NAME}" ]]; then
echo "The variable NAME is not defined. Please, fix and run again."
return -1
else
params="$params -name ${NAME}"
fi
## -port: used the value of the param if defined, if not it will use standard port (2456).
## Choose the Port which you want the server to communicate with. Please note that this has to
## correspond with the Port Forwarding settings on your Router. Valheim uses the specified Port AND
## specified Port+1. Default Ports are 2456-2457
params="$params -port ${PORT:-2456}"
## -world: Name of the world
## A World with the name entered will be created.
## You may also choose an already existing World by entering its name
if [[ -z "${WORLD}" ]]; then
echo "The variable WORLD is not defined. Fixed and run again."
return -1
else
params="$params -world ${WORLD}"
fi
## -password: Password for the server, if not defined, no password = free access:
if [[ -z "${PASSWORD}" ]]; then
echo "The variable PASSWORD is not defined. Running WITHOUT password."
else
params="$params -password ${PASSWORD}"
fi
## -savedir: Where the data will be saved.
## Overrides the default save path where Worlds and permission-files are stored.
## Save folder for the data (if not defined can run, but the world will be saved on the container, bad idea):
if [[ -z "${SAVEDIR}" ]]; then
echo "The variable SAVEDIR is not defined. Fixed and run again."
return -1
else
params="$params -savedir ${SAVEDIR}"
fi
## -public: used the value of the param if defined, if not it will be a public server (1).
## Sets the visibility of your server. 1 is default and will make the server visible in the browser.
## Set it to 0 to make the server invisible and only joinable via the ‘Join IP’-button.
## Setting public to 0 is a good option if you wish to run a local LAN server, where players can join via
## the local IP of the server.
params="$params -public ${PUBLIC:-1}"
## -logFile: Sets the location to save the log file.
if [[ -z "${LOGFILE}" ]]; then
echo "The variable LOGFILE is not defined. The messages will be displayed on standard output."
else
params="$params -logFile ${LOGFILE}"
fi
## -saveinterval: Change how often the world will save in seconds.
params="$params -saveinterval ${SAVEINTERVAL:-1800}"
## -backups: Sets how many automatic backups will be kept.
## The first is the ‘short’ backup length, and the rest are the ‘long’ backup length.
## By default that means one backup that is 2 hours old, and 3 backups that are 12 hours apart.
params="$params -backups ${BACKUPS:-4}"
## -backupshort: Sets the interval between the first automatic backups.
## Default is 2 hours (7200 seconds).
params="$params -backupshort ${SAVEINTERVAL:-7200}"
## -backuplong: Sets the interval between the subsequent automatic backups.
## Default is 12 hours (43200 seconds).
params="$params -backuplong ${SAVEINTERVAL:-43200}"
## -crossplay: Runs the Server on the Crossplay backend (PlayFab), which lets users from any platform join.
## If you do not include this argument (or set to FALSE in the env file), the Steam backend is used, which
## means only Steam users can see and join the Server.
if [ "${CROSSPLAY}" = "TRUE" ]; then
params="$params -crossplay"
fi
}
# Main function
main() {
# Basic export for the BOX64 emulator
echo "##############################"
echo "Basic variables running box64:"
echo "BOX64_LD_LIBRARY_PATH: ${BOX64_LD_LIBRARY_PATH}"
echo "BOX64_LOG: ${BOX64_LOG}"
echo "BOX64_TRACE_FILE: ${BOX64_TRACE_FILE}"
echo "BOX64_TRACE: ${BOX64_TRACE}"
echo "##############################"
# Part of the standar code startup of the server:
export templdpath="${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH=./linux64:"${LD_LIBRARY_PATH}"
export SteamAppId=${STEAMAPPID}
# Move to the execution folder
cd /root/valheim_server
## Checking the final parameters to use:
echo "##############################"
echo "Final Valheim parameters to run: $params"
echo "##############################"
# Starting the server:
box64 ./valheim_server.x86_64 $params
}
getparams
main