Skip to content

Instantly share code, notes, and snippets.

@jamiemtdwyer
Created January 12, 2022 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiemtdwyer/f15bf2da95a94893ab61ea30f56be064 to your computer and use it in GitHub Desktop.
Save jamiemtdwyer/f15bf2da95a94893ab61ea30f56be064 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Connect to an RCON client listening on the port specified by RCON_PORT
RCON_DIR=~/rcon/
RCON_CONFIG_FILE=~/rcon/rcon.yaml
export RCON_PORT=27015
export PATH=$RCON_DIR:$PATH
echo "Waiting for RCON server on port ${RCON_PORT} to open..."
timeout 300 bash -c 'until echo > /dev/tcp/localhost/"${RCON_PORT}"; do sleep 0.5; done' 2>/dev/null
if [ $? = 124 ];
then
echo "Timed out waiting for RCON host on port ${RCON_PORT}"
else
rcon -c $RCON_CONFIG_FILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment