forked from jammsen/docker-palworld-dedicated-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
servermanager.sh
executable file
·76 lines (67 loc) · 2.1 KB
/
servermanager.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
#!/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_webhook_notification "$WEBHOOK_START_TITLE" "$WEBHOOK_START_DESCRIPTION" "$WEBHOOK_START_COLOR"
fi
./PalServer.sh "$START_OPTIONS"
}
function start_main() {
check_for_default_credentials
setup_crons
# Check if server is installed, if not try again
if [ ! -f "$GAME_PATH/PalServer.sh" ]; then
install_server
fi
if [ $ALWAYS_UPDATE_ON_START == "true" ]; then
update_server
fi
start_server
}
term_handler() {
if [[ ! -z ${RCON_ENABLED+x} ]]; then
rconcli 'broadcast Server_Shutdown_requested'
rconcli 'broadcast Saving...'
rconcli 'save'
rconcli 'broadcast Done...'
sleep 3
fi
kill -SIGTERM $(pidof PalServer-Linux-Test)
tail --pid=$(pidof PalServer-Linux-Test) -f 2>/dev/null
if [[ -n $WEBHOOK_ENABLED ]] && [[ $WEBHOOK_ENABLED == "true" ]]; then
send_webhook_notification "$WEBHOOK_STOP_TITLE" "$WEBHOOK_STOP_DESCRIPTION" "$WEBHOOK_STOP_COLOR"
fi
exit 143;
}
trap 'kill ${!}; term_handler' SIGTERM
start_main &
killpid="$!"
while true
do
wait $killpid
exit 0;
done