2016-08-01 08:09:50 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Define the exit handler
|
|
|
|
exit_handler()
|
|
|
|
{
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
|
|
|
echo "Waiting for server to shutdown.."
|
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
kill -SIGINT "$child"
|
2018-01-10 09:42:11 +00:00
|
|
|
sleep 5
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "Terminating.."
|
|
|
|
echo ""
|
|
|
|
exit
|
2016-08-01 08:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Trap specific signals and forward to the exit handler
|
|
|
|
trap 'exit_handler' SIGHUP SIGINT SIGQUIT SIGTERM
|
|
|
|
|
|
|
|
# Create the necessary folder structure
|
|
|
|
if [ ! -d "/steamcmd/starbound/linux" ]; then
|
|
|
|
echo "Creating folder structure.."
|
|
|
|
mkdir -p /steamcmd/starbound/linux
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install/update steamcmd
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
echo "Installing/updating steamcmd.."
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
curl -s http://media.steampowered.com/installer/steamcmd_linux.tar.gz | tar -v -C /steamcmd -zx
|
|
|
|
|
|
|
|
# Check that username and password are both set
|
|
|
|
if [ ! -z "$STEAM_USERNAME" ] || [ ! -z "$STEAM_PASSWORD" ]; then
|
|
|
|
# Setup username/password for Steam
|
|
|
|
sed -i "s/login anonymous/login $STEAM_USERNAME $STEAM_PASSWORD/g" /install.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that Starbound exists in the first place
|
|
|
|
if [ ! -f "/steamcmd/starbound/linux/starbound_server" ]; then
|
|
|
|
# Check that username and password are both set, otherwise quit with error
|
|
|
|
if [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
|
|
|
|
echo "Error: you must set both your Steam username and password to install the server"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# Install Starbound from install.txt
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
|
|
|
echo "Installing Starbound.."
|
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
bash /steamcmd/steamcmd.sh +runscript /install.txt
|
|
|
|
else
|
|
|
|
# Check that username and password are both set, otherwise skip update
|
|
|
|
if [ -z "$STEAM_USERNAME" ] || [ -z "$STEAM_PASSWORD" ]; then
|
2017-04-22 17:33:38 +00:00
|
|
|
if [ -z "$SKIP_STEAMCMD" ]; then
|
|
|
|
echo "Steam username or password not set, exiting.."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Steam username or password not set, skipping update.."
|
|
|
|
fi
|
2016-08-01 08:09:50 +00:00
|
|
|
else
|
|
|
|
# Install Starbound from install.txt
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
|
|
|
echo "Updating Starbound.."
|
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
bash /steamcmd/steamcmd.sh +runscript /install.txt
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set the working directory
|
2018-01-10 09:42:11 +00:00
|
|
|
cd /steamcmd/starbound/linux || exit
|
|
|
|
|
|
|
|
# Copy default configuration if necessary
|
|
|
|
if [ ! -f "/steamcmd/starbound/storage/starbound_server.config" ]; then
|
|
|
|
echo ""
|
|
|
|
echo "Copying default configuration.."
|
|
|
|
echo ""
|
|
|
|
mkdir -p /steamcmd/starbound/storage
|
|
|
|
cp -f /starbound_server.default.config /steamcmd/starbound/storage/starbound_server.config
|
|
|
|
fi
|
2016-08-01 08:09:50 +00:00
|
|
|
|
|
|
|
# Run the server
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
echo "Starting Starbound.."
|
2018-01-10 09:42:11 +00:00
|
|
|
echo ""
|
2016-08-01 08:09:50 +00:00
|
|
|
./starbound_server 2>&1 &
|
|
|
|
|
|
|
|
child=$!
|
|
|
|
wait "$child"
|