2222: " ${MODRINTH_DOWNLOAD_DEPENDENCIES:= required} "
2323: " ${MODRINTH_ALLOWED_VERSION_TYPE:= release} "
2424: " ${CUSTOM_FAMILY:= bungeecord} "
25+ : " ${SKIP_DOWNLOAD_DEFAULTS:= false} "
26+ : " ${DEFAULT_CONFIG_REPO:= https:// raw.githubusercontent.com/ Shonz1/ minecraft-default-configs/ main} "
2527
2628BUNGEE_HOME=/server
2729RCON_JAR_URL=https://github.com/orblazer/bungee-rcon/releases/download/v${RCON_JAR_VERSION} /bungee-rcon-${RCON_JAR_VERSION} .jar
@@ -47,6 +49,17 @@ function isTrue() {
4749 return ${result}
4850}
4951
52+ function isFalse() {
53+ case " ${1,,} " in
54+ false | no | off | 0)
55+ return 0
56+ ;;
57+ * )
58+ return 1
59+ ;;
60+ esac
61+ }
62+
5063function isDebugging() {
5164 if isTrue " ${DEBUG} " ; then
5265 return 0
@@ -254,6 +267,20 @@ function getFromPaperMc() {
254267 BUNGEE_JAR=" $SERVER "
255268}
256269
270+ function buildDownloadList() {
271+ repoUrl=${1?}
272+ version=${2?}
273+ shift 2
274+ result=
275+ for c in " ${@ } " ; do
276+ if [[ $result ]]; then
277+ result+=" ,"
278+ fi
279+ result+=" ${repoUrl} /${version} /$c "
280+ done
281+ echo " $result "
282+ }
283+
257284# ## MAIN
258285
259286handleDebugMode
@@ -272,20 +299,23 @@ case "${TYPE^^}" in
272299 BUNGEE_JAR=$BUNGEE_HOME /${BUNGEE_JAR:= BungeeCord-${BUNGEE_JAR_REVISION} .jar}
273300 pruningPrefix=BungeeCord
274301 family=bungeecord
302+ DOWNLOAD_DEFAULTS=$( buildDownloadList " $DEFAULT_CONFIG_REPO " " bungeecord" " config.yml" )
275303 ;;
276304
277305 WATERFALL)
278306 getFromPaperMc waterfall " ${WATERFALL_VERSION:- latest} " " ${WATERFALL_BUILD_ID:- latest} "
279307 # downloaded by getFromPaperMc
280308 download_required=false
281309 family=bungeecord
310+ DOWNLOAD_DEFAULTS=$( buildDownloadList " $DEFAULT_CONFIG_REPO " " waterfall" " config.yml" " waterfall.yml" )
282311 ;;
283312
284313 VELOCITY)
285314 getFromPaperMc velocity " ${VELOCITY_VERSION:- latest} " " ${VELOCITY_BUILD_ID:- latest} "
286315 # downloaded by getFromPaperMc
287316 download_required=false
288317 family=velocity
318+ DOWNLOAD_DEFAULTS=$( buildDownloadList " $DEFAULT_CONFIG_REPO " " velocity" " velocity.toml" )
289319 ;;
290320
291321 CUSTOM)
@@ -316,6 +346,30 @@ if isTrue "$download_required"; then
316346 fi
317347fi
318348
349+ if isFalse " $SKIP_DOWNLOAD_DEFAULTS " ; then
350+ if [[ $DOWNLOAD_DEFAULTS ]]; then
351+ log " Downloading default top-level configs, if needed"
352+ if ! mc-image-helper mcopy \
353+ --to /server \
354+ --skip-existing --skip-up-to-date=false \
355+ " $DOWNLOAD_DEFAULTS " 2> /dev/null; then
356+ logWarning " One or more default files were not available from $DOWNLOAD_DEFAULTS "
357+ fi
358+ fi
359+
360+ if [[ " ${family} " == " velocity" ]]; then
361+ SECRET_FILE=" /server/forwarding.secret"
362+
363+ if [ ! -f " $SECRET_FILE " ]; then
364+ # generate 32 random alphanumeric characters
365+ head /dev/urandom | tr -dc ' A-Za-z0-9' | head -c 32 > " $SECRET_FILE "
366+ log " Created $SECRET_FILE "
367+ else
368+ log " $SECRET_FILE already exists"
369+ fi
370+ fi
371+ fi
372+
319373if [ -n " $ICON " ]; then
320374 if [ ! -e server-icon.png ] || isTrue " ${OVERRIDE_ICON} " ; then
321375 log " Using server icon from $ICON ..."
0 commit comments