-
Notifications
You must be signed in to change notification settings - Fork 9
/
start_stationeers.sh
executable file
·106 lines (88 loc) · 2.91 KB
/
start_stationeers.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
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
#!/usr/bin/env bash
# Enable debugging
#set -x
# Setup error handling
set -e
set -o pipefail
# Print the user we're currently running as
echo "Running as user: $(whoami)"
# Define the exit handler
exit_handler()
{
echo ""
echo "Waiting for server to shutdown.."
echo ""
kill -SIGINT "$child"
sleep 5
echo ""
echo "Terminating.."
echo ""
exit
}
# Trap specific signals and forward to the exit handler
trap 'exit_handler' SIGHUP SIGINT SIGQUIT SIGTERM
# Install/update steamcmd
echo ""
echo "Installing/updating steamcmd.."
echo ""
curl -s http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar -v -C /steamcmd -zx
# Check that Stationeers exists in the first place
if [ ! -f "/steamcmd/stationeers/rocketstation_DedicatedServer.x86_64" ]; then
# Install Stationeers from install.txt
echo ""
echo "Installing Stationeers.."
echo ""
bash /steamcmd/steamcmd.sh +runscript /app/install.txt
else
# Install Stationeers from install.txt
echo ""
echo "Updating Stationeers.."
echo ""
bash /steamcmd/steamcmd.sh +runscript /app/install.txt
fi
# Remove extra whitespace from startup command
STATIONEERS_STARTUP_COMMAND=$(echo "$STATIONEERS_SERVER_STARTUP_ARGUMENTS" | tr -s " ")
# Set the game port
if [ ! -z ${STATIONEERS_GAME_PORT+x} ]; then
STATIONEERS_STARTUP_COMMAND="${STATIONEERS_STARTUP_COMMAND} -gameport=${STATIONEERS_GAME_PORT}"
fi
# Set the query/update port
if [ ! -z ${STATIONEERS_QUERY_PORT+x} ]; then
STATIONEERS_STARTUP_COMMAND="${STATIONEERS_STARTUP_COMMAND} -updateport=${STATIONEERS_QUERY_PORT}"
fi
# Set the world name
if [ ! -z ${STATIONEERS_WORLD_NAME+x} ]; then
STATIONEERS_STARTUP_COMMAND="${STATIONEERS_STARTUP_COMMAND} -worldname=${STATIONEERS_WORLD_NAME} -loadworld=${STATIONEERS_WORLD_NAME}"
fi
# Set the auto-save interval
if [ ! -z ${STATIONEERS_SERVER_SAVE_INTERVAL+x} ]; then
STATIONEERS_STARTUP_COMMAND="${STATIONEERS_STARTUP_COMMAND} -autosaveinterval=${STATIONEERS_SERVER_SAVE_INTERVAL}"
fi
# Set the server name
if [ ! -z ${STATIONEERS_SERVER_NAME+x} ]; then
STATIONEERS_STARTUP_COMMAND="${STATIONEERS_STARTUP_COMMAND} -servername=\"${STATIONEERS_SERVER_NAME}\""
fi
# Set the server password
if [ ! -z ${STATIONEERS_SERVER_PASSWORD+x} ]; then
STATIONEERS_STARTUP_COMMAND="${STATIONEERS_STARTUP_COMMAND} -password=${STATIONEERS_SERVER_PASSWORD}"
fi
# Set the working directory
cd /steamcmd/stationeers || exit
# Run the server
echo ""
echo "Starting Stationeers with arguments: ${STATIONEERS_STARTUP_COMMAND}"
echo ""
./rocketstation_DedicatedServer.x86_64 \
${STATIONEERS_STARTUP_COMMAND} \
2>&1 &
# ./rocketstation_DedicatedServer.x86_64 \
# ${STATIONEERS_SERVER_STARTUP_ARGUMENTS} \
# -gameport=${STATIONEERS_GAME_PORT} \
# -updateport=${STATIONEERS_QUERY_PORT} \
# -worldname=${STATIONEERS_WORLD_NAME} \
# -loadworld=${STATIONEERS_WORLD_NAME} \
# -autosaveinterval=${STATIONEERS_SERVER_SAVE_INTERVAL} \
# -servername "${STATIONEERS_SERVER_NAME}" \
# 2>&1 &
child=$!
wait "$child"