-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from loganintech/logan/revert-to-only-upstrea…
…m-changes Fix breaking changes in #161
- Loading branch information
Showing
2 changed files
with
54 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,53 @@ | ||
#!/bin/bash | ||
|
||
if [ $(jq -r '.Settings.StorageType' $CONFIG_PATH/config.json) = "mysql" ]; then | ||
DATABASE_SERVER=$(jq -r '.Settings.MySqlHost' $CONFIG_PATH/config.json | cut -f1 -d':') | ||
DATABASE_PORT=$(jq -r '.Settings.MySqlHost' $CONFIG_PATH/config.json | cut -f2 -d':') | ||
DATABASE_USER_NAME=$(jq -r '.Settings.MySqlUsername' $CONFIG_PATH/config.json) | ||
DATABASE_USER_PASSWORD=$(jq -r '.Settings.MySqlPassword' $CONFIG_PATH/config.json) | ||
echo "\nBootstrap:\nworld_file_name=$WORLD_FILENAME\nconfigpath=$CONFIGPATH\nlogpath=$LOGPATH\n" | ||
|
||
# Copy plugins if the folder is empty (like on first run) | ||
if [ -z "$(ls -A /tshock/ServerPlugins)" ]; then | ||
echo "Copying plugins..." | ||
cp /plugins/* /tshock/ServerPlugins | ||
fi | ||
|
||
|
||
if [ $(jq -r '.Settings.StorageType' $CONFIGPATH/config.json) = "mysql" ]; then | ||
DATABASE_SERVER=$(jq -r '.Settings.MySqlHost' $CONFIGPATH/config.json | cut -f1 -d':') | ||
DATABASE_PORT=$(jq -r '.Settings.MySqlHost' $CONFIGPATH/config.json | cut -f2 -d':') | ||
DATABASE_USER_NAME=$(jq -r '.Settings.MySqlUsername' $CONFIGPATH/config.json) | ||
DATABASE_USER_PASSWORD=$(jq -r '.Settings.MySqlPassword' $CONFIGPATH/config.json) | ||
echo "Waiting for the database server." | ||
while ! mysql -h$DATABASE_SERVER -P$DATABASE_PORT -u$DATABASE_USER_NAME -p$DATABASE_USER_PASSWORD -e ";" ; do | ||
sleep 0.1; | ||
done | ||
fi | ||
|
||
if [ -z "$(ls -A /tshock/ServerPlugins)" ]; then | ||
echo "Copying plugins..." | ||
cp /plugins/* /tshock/ServerPlugins | ||
fi | ||
WORLD_PATH="/root/.local/share/Terraria/Worlds/$WORLD_FILENAME" | ||
|
||
echo "./TShock.Server -config \"$CONFIG_PATH/serverconfig.txt\" -configpath \"$CONFIG_PATH\" -logpath \"$LOG_PATH\" -worldpath /root/.local/share/Terraria/Worlds/ \"$@\"" | ||
./TShock.Server -config "$CONFIG_PATH/serverconfig.txt" -configpath "$CONFIG_PATH" -logpath "$LOG_PATH" -worldpath /root/.local/share/Terraria/Worlds/ "$@" | ||
autocreate_flag=false | ||
for arg in "$@"; do | ||
if [ "$arg" = "-autocreate" ]; then | ||
autocreate_flag=true | ||
break | ||
fi | ||
done | ||
|
||
|
||
if [ -z "$WORLD_FILENAME" ]; then | ||
echo "No world file specified in environment WORLD_FILENAME." | ||
if [ -z "$@" ]; then | ||
echo "Running server setup..." | ||
else | ||
echo "Running server with command flags: $@" | ||
fi | ||
./TShock.Server -configpath "$CONFIGPATH" -logpath "$LOGPATH" "$@" | ||
else | ||
echo "Environment WORLD_FILENAME specified" | ||
if [ -f "$WORLD_PATH" ] || [ "$autocreate_flag" = true ]; then | ||
echo "Loading to world $WORLD_FILENAME..." | ||
./TShock.Server -configpath "$CONFIGPATH" -logpath "$LOGPATH" -world "$WORLD_PATH" "$@" | ||
else | ||
echo "Unable to locate $WORLD_PATH and -autocreate flag is not set." | ||
echo "Please make sure your world file is volumed into docker: -v <path_to_world_file>:/root/.local/share/Terraria/Worlds" | ||
echo "Alternatively, use the -autocreate flag to create a new world." | ||
exit 1 | ||
fi | ||
fi |