-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathserver.sh
74 lines (62 loc) · 1.87 KB
/
server.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
#!/bin/bash
# Stop on errors, comment in, if needed
#set -e
source /config.sh
source /cron.sh
source /install.sh
source /rcon.sh
source /security.sh
source /webhook.sh
GAME_PATH="/palworld"
function start_server() {
# IF Bash extension used:
# https://stackoverflow.com/a/13864829
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02
echo ">>> Starting the gameserver"
cd $GAME_PATH
setup_engine_ini
setup_pal_world_settings_ini
START_OPTIONS=""
if [[ -n $COMMUNITY_SERVER ]] && [[ $COMMUNITY_SERVER == "true" ]]; then
echo "> Setting Community-Mode to enabled"
START_OPTIONS="$START_OPTIONS EpicApp=PalServer"
fi
if [[ -n $MULTITHREAD_ENABLED ]] && [[ $MULTITHREAD_ENABLED == "true" ]]; then
echo "> Setting Multi-Core-Enchancements to enabled"
START_OPTIONS="$START_OPTIONS -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS"
fi
if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then
send_start_notification
fi
./PalServer.sh "$START_OPTIONS"
}
function start_main() {
check_for_default_credentials
setup_crons
if [ ! -f "$GAME_PATH/PalServer.sh" ]; then
install_server
fi
if [ $ALWAYS_UPDATE_ON_START == "true" ]; then
update_server
fi
start_server
}
term_handler() {
local stopnotification=${1:"true"}
if [ -z "$(pidof PalServer-Linux-Test)" ]; then
exit $exit_code
fi
if [[ ! -z ${RCON_ENABLED+x} ]]; then
save_and_shutdown_server
fi
kill -SIGTERM $(pidof PalServer-Linux-Test)
tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null
if [ ${REMOTE_CONTROL:false} != "true" ]; then
kill -SIGTERM $(pidof /remotestart.sh)
tail --pid=$(pidof remotestart) -f 2>/dev/null
fi
if [ $stopnotification == "true"]; then
send_stop_notification
fi
exit $exit_code;
}