diff --git a/scripts/run-bungeecord.sh b/scripts/run-bungeecord.sh index 407698d..6b81752 100644 --- a/scripts/run-bungeecord.sh +++ b/scripts/run-bungeecord.sh @@ -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..." @@ -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 @@ -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..."