Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=lf
54 changes: 54 additions & 0 deletions scripts/run-bungeecord.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
: "${MODRINTH_DOWNLOAD_DEPENDENCIES:=required}"
: "${MODRINTH_ALLOWED_VERSION_TYPE:=release}"
: "${CUSTOM_FAMILY:=bungeecord}"
: "${SKIP_DOWNLOAD_DEFAULTS:=false}"
: "${DEFAULT_CONFIG_REPO:=https://raw.githubusercontent.com/Shonz1/minecraft-default-configs/main}"

BUNGEE_HOME=/server
RCON_JAR_URL=https://github.com/orblazer/bungee-rcon/releases/download/v${RCON_JAR_VERSION}/bungee-rcon-${RCON_JAR_VERSION}.jar
Expand All @@ -47,6 +49,17 @@ function isTrue() {
return ${result}
}

function isFalse() {
case "${1,,}" in
false | no | off | 0)
return 0
;;
*)
return 1
;;
esac
}

function isDebugging() {
if isTrue "${DEBUG}"; then
return 0
Expand Down Expand Up @@ -254,6 +267,20 @@ function getFromPaperMc() {
BUNGEE_JAR="$SERVER"
}

function buildDownloadList() {
repoUrl=${1?}
version=${2?}
shift 2
result=
for c in "${@}"; do
if [[ $result ]]; then
result+=","
fi
result+="${repoUrl}/${version}/$c"
done
echo "$result"
}

### MAIN

handleDebugMode
Expand All @@ -272,20 +299,23 @@ case "${TYPE^^}" in
BUNGEE_JAR=$BUNGEE_HOME/${BUNGEE_JAR:=BungeeCord-${BUNGEE_JAR_REVISION}.jar}
pruningPrefix=BungeeCord
family=bungeecord
DOWNLOAD_DEFAULTS=$(buildDownloadList "$DEFAULT_CONFIG_REPO" "bungeecord" "config.yml")
;;

WATERFALL)
getFromPaperMc waterfall "${WATERFALL_VERSION:-latest}" "${WATERFALL_BUILD_ID:-latest}"
# downloaded by getFromPaperMc
download_required=false
family=bungeecord
DOWNLOAD_DEFAULTS=$(buildDownloadList "$DEFAULT_CONFIG_REPO" "waterfall" "config.yml" "waterfall.yml")
;;

VELOCITY)
getFromPaperMc velocity "${VELOCITY_VERSION:-latest}" "${VELOCITY_BUILD_ID:-latest}"
# downloaded by getFromPaperMc
download_required=false
family=velocity
DOWNLOAD_DEFAULTS=$(buildDownloadList "$DEFAULT_CONFIG_REPO" "velocity" "velocity.toml")
;;

CUSTOM)
Expand Down Expand Up @@ -316,6 +346,30 @@ 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