SquadDocker/scripts/entry.bash

47 lines
1.4 KiB
Bash
Raw Normal View History

2023-01-10 14:46:17 -06:00
#!/bin/bash
# If we want to persist the container and we don't want to update then we can save a whole lot of time if we mount this
2023-01-10 14:46:17 -06:00
# on a volume
main() {
2023-01-14 16:34:49 -06:00
local mount="/docker-mount/"
2023-01-14 21:48:36 -06:00
chown -R "${USER}:${USER}" "${mount}"
2023-01-14 16:34:49 -06:00
if [[ -r "${mount}/ServerConfig" ]]; then
2023-01-15 15:04:01 -06:00
printf "Linking ServerConfig from '%s' -> '%s'\n" "${mount}/ServerConfig/" "${SQUAD_SERVER_DIR}/SquadGame/ServerConfig/"
for file in "${mount}/ServerConfig/"*; do
ln -sf "${file}" "${SQUAD_SERVER_DIR}/SquadGame/ServerConfig/$(basename "${file}")"
done
2023-01-10 14:46:17 -06:00
fi
# Update RCON configuration based on the fed in environment value
while read -r line; do
if [[ "${line}" == Password=* ]]; then
# Overwrites the password
echo "${line//Password=*/Password="${RCON_PASSWORD}"}"
elif [[ "${line}" == Port=* ]]; then
# Overwrites the rcon port
echo "${line//Port=*/Port="${RCONPORT}"}"
else
echo "${line}"
fi
done < "${SQUAD_SERVER_DIR}/SquadGame/ServerConfig/Rcon.cfg" > "rcon.temp" && mv "rcon.temp" "${SQUAD_SERVER_DIR}/SquadGame/ServerConfig/Rcon.cfg"
2023-01-25 22:46:24 -06:00
chown -R "${USER}:${USER}" "${SQUAD_SERVER_DIR}/SquadGame/Saved/Logs"
2023-01-22 21:44:01 -06:00
2023-01-15 15:28:23 -06:00
su "${USER}" - <<- __EOC__
printf "Starting the Squad Server....\n"
2023-01-15 15:28:23 -06:00
"${SQUAD_SERVER_DIR}/SquadGameServer.sh" \
Port="${GAMEPORT}" \
QueryPort="${QUERYPORT}" \
FIXEDMAXTICKRATE="${FIXEDMAXTICKRATE}" \
2023-12-12 14:22:31 -06:00
FIXEDMAXPLAYERS="${FIXEDMAXPLAYERS}" \
beaconport="${BEACONPORT}" &
printf "Squad Server Started!\n"
wait
2023-01-15 15:28:23 -06:00
__EOC__
2023-01-10 14:46:17 -06:00
}
main