Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions scripts/run-bungeecord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ function processConfigs {
fi
fi

downloadDefaultConfigs

# Replace environment variables in config files
if isTrue "${REPLACE_ENV_VARIABLES}"; then
log "Replacing env variables in configs that match the prefix $REPLACE_ENV_VARIABLE_PREFIX..."
Expand Down Expand Up @@ -281,6 +283,32 @@ function buildDownloadList() {
echo "$result"
}

function downloadDefaultConfigs() {
if isFalse "$SKIP_DOWNLOAD_DEFAULTS"; then
if [[ $DOWNLOAD_DEFAULTS ]]; then
log "Downloading default top-level configs, if needed"
if ! mc-image-helper mcopy \
--to /server \
--skip-existing --skip-up-to-date=false \
"$DOWNLOAD_DEFAULTS" 2> /dev/null; then
logWarning "One or more default files were not available from $DOWNLOAD_DEFAULTS"
fi
fi

if [[ "${family}" == "velocity" ]]; then
SECRET_FILE="/server/forwarding.secret"

if [ ! -f "$SECRET_FILE" ]; then
# generate 32 random alphanumeric characters
head /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 32 > "$SECRET_FILE"
log "Created $SECRET_FILE"
else
log "$SECRET_FILE already exists"
fi
fi
fi
}

### MAIN

handleDebugMode
Expand Down Expand Up @@ -346,30 +374,6 @@ if isTrue "$download_required"; then
fi
fi

if isFalse "$SKIP_DOWNLOAD_DEFAULTS"; then
if [[ $DOWNLOAD_DEFAULTS ]]; then
log "Downloading default top-level configs, if needed"
if ! mc-image-helper mcopy \
--to /server \
--skip-existing --skip-up-to-date=false \
"$DOWNLOAD_DEFAULTS" 2> /dev/null; then
logWarning "One or more default files were not available from $DOWNLOAD_DEFAULTS"
fi
fi

if [[ "${family}" == "velocity" ]]; then
SECRET_FILE="/server/forwarding.secret"

if [ ! -f "$SECRET_FILE" ]; then
# generate 32 random alphanumeric characters
head /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 32 > "$SECRET_FILE"
log "Created $SECRET_FILE"
else
log "$SECRET_FILE already exists"
fi
fi
fi

if [ -n "$ICON" ]; then
if [ ! -e server-icon.png ] || isTrue "${OVERRIDE_ICON}"; then
log "Using server icon from $ICON..."
Expand Down