From 1a54b602754ab01e3ac9f9639fc13b0624871a87 Mon Sep 17 00:00:00 2001 From: RallyBlock Date: Sat, 7 Mar 2026 19:30:52 -0500 Subject: [PATCH] Upload files to "bin" --- bin/install-bl | 63 ++++++++++++++++++++++++++++++++++ bin/patch-bl | 22 ++++++++++++ bin/run-bl | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+) create mode 100644 bin/install-bl create mode 100644 bin/patch-bl create mode 100644 bin/run-bl diff --git a/bin/install-bl b/bin/install-bl new file mode 100644 index 0000000..bea3ccd --- /dev/null +++ b/bin/install-bl @@ -0,0 +1,63 @@ +#!/bin/bash +set -e + +cd /home/container + +echo "Installing Blockland..." + +curl -fsSL -A "blocklandWIN/2.0" \ + -o /tmp/latest-manifest.dat \ + http://update.blockland.us/latestVersion.php + +download_url=$(head -n 1 /tmp/latest-manifest.dat | cut -f 2) + +tail -n +2 /tmp/latest-manifest.dat | tr '\r\n\t' '\0' | \ +xargs -0 -n 2 -P "${BL_INST_NUM_PROC:-4}" sh -c ' +file="./$2" +curl -fsSL -A "blocklandWIN/2.0" --create-dirs -o "$file" "$1/$3" +' _ "$download_url" + +if [[ "${BL_PATCH_ENABLE:-0}" -eq 1 ]]; then + /usr/local/bin/patch-bl +fi + +if [ "${BL_UNZIP_ADDONS:-0}" -eq 1 ]; then + echo "Processing Add-Ons zips..." + + cd "$HOME/Add-Ons" || exit 1 + + for zip in *.zip; do + [ -f "$zip" ] || continue + + addon_name="${zip%.zip}" + + echo "Extracting $zip..." + + # Extract into a temp directory first + mkdir -p "__tmp_extract__" + unzip -o "$zip" -d "__tmp_extract__" >/dev/null + + # Count top-level items in extraction + item_count=$(find "__tmp_extract__" -mindepth 1 -maxdepth 1 | wc -l) + + if [ "$item_count" -eq 1 ]; then + first_item=$(find "__tmp_extract__" -mindepth 1 -maxdepth 1) + + if [ -d "$first_item" ]; then + # Proper folder structure, just move it + mv "$first_item" . + else + # Single loose file — fix structure + mkdir -p "$addon_name" + mv "$first_item" "$addon_name"/ + fi + else + # Multiple loose files — put them in folder + mkdir -p "$addon_name" + mv "__tmp_extract__"/* "$addon_name"/ + fi + + rm -rf "__tmp_extract__" + rm -f "$zip" + done +fi \ No newline at end of file diff --git a/bin/patch-bl b/bin/patch-bl new file mode 100644 index 0000000..8d92695 --- /dev/null +++ b/bin/patch-bl @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +cd /home/container + +echo "Patching Blockland..." + +if [ -n "$BL_PATCH_EXE_URL" ]; then + curl -fsSLJ --clobber -o Blockland.exe "$BL_PATCH_EXE_URL" +fi + +if [ -n "$BL_PATCH_LOADER_URL" ]; then + curl -fsSLJ --clobber -o RedBlocklandLoader.dll "$BL_PATCH_LOADER_URL" +fi + +if [ -n "$BL_PATCH_WINEFIX_URL" ]; then + mkdir -p ./modules + curl -fsSLJ --clobber \ + --output-dir ./modules/ \ + -o WineFix.dll \ + "$BL_PATCH_WINEFIX_URL" +fi \ No newline at end of file diff --git a/bin/run-bl b/bin/run-bl new file mode 100644 index 0000000..1b52f13 --- /dev/null +++ b/bin/run-bl @@ -0,0 +1,93 @@ +#!/bin/bash + +set -e + +cd /home/container || { + echo "ERROR: /home/container does not exist" + exit 1 +} + +# Install if needed +if [[ "$BL_INST_FORCE" == "1" ]] || [ ! -f "Blockland.exe" ]; then + source /usr/local/bin/install-bl +fi + +# Required vars +[ -z "$BL_PORT" ] && echo "Missing BL_PORT" && exit 1 +[ -z "$BL_GAMEMODE" ] && echo "Missing BL_GAMEMODE" && exit 1 +[ -z "$BL_SERVER_NAME" ] && echo "Missing BL_SERVER_NAME" && exit 1 + +if [[ "$BL_DEDI_LAN" == "1" ]]; then + dedi="dedicatedLAN" +else + [ -z "$BL_DTOKEN" ] && echo "Missing BL_DTOKEN" && exit 1 + dedi="dedicated" +fi + +# Create wine prefix if missing +if [ ! -d "$HOME/.wine" ]; then + echo "Creating wine prefix..." + wineboot -i + sleep 3 +fi + +if [ "${BL_UNZIP_ADDONS:-0}" -eq 1 ]; then + echo "Processing Add-Ons zips..." + + cd "$HOME/Add-Ons" || exit 1 + + for zip in *.zip; do + [ -f "$zip" ] || continue + + addon_name="${zip%.zip}" + + echo "Extracting $zip..." + + # Extract into a temp directory first + mkdir -p "__tmp_extract__" + unzip -o "$zip" -d "__tmp_extract__" >/dev/null + + # Count top-level items in extraction + item_count=$(find "__tmp_extract__" -mindepth 1 -maxdepth 1 | wc -l) + + if [ "$item_count" -eq 1 ]; then + first_item=$(find "__tmp_extract__" -mindepth 1 -maxdepth 1) + + if [ -d "$first_item" ]; then + # Proper folder structure, just move it + mv "$first_item" . + else + # Single loose file — fix structure + mkdir -p "$addon_name" + mv "$first_item" "$addon_name"/ + fi + else + # Multiple loose files — put them in folder + mkdir -p "$addon_name" + mv "__tmp_extract__"/* "$addon_name"/ + fi + + rm -rf "__tmp_extract__" + rm -f "$zip" + done +fi + +# Ensure we're in the correct directory +cd "$HOME" || exit 1 + +if [ ! -f "Blockland.exe" ]; then + echo "Blockland.exe not found!" + exit 1 +fi + +echo "Launching Blockland..." + +exec xvfb-run -a wine "Blockland.exe" \ + ptlaaxobimwroe \ + -${dedi} \ + -port "$BL_PORT" \ + -dtoken "$BL_DTOKEN" \ + -gamemode "$BL_GAMEMODE" \ + -serverName "$BL_SERVER_NAME" \ + -maxPlayers "$BL_MAX_PLAYERS" \ + $BL_EXTRA_ARGS \ No newline at end of file