From aa7b997697a9e7276e6f10c80b2958930f35cda3 Mon Sep 17 00:00:00 2001 From: chblodg Date: Sun, 6 Feb 2022 10:45:25 -0800 Subject: [PATCH 1/6] Adding support for crafting tweaks and resource packs (#1336) Co-authored-by: christopher blodgett Co-authored-by: Geoff Bourne Co-authored-by: Floyd Everest --- DEVELOPMENT.md | 22 ++- README.md | 44 +++++- scripts/start-setupVanillaTweaks | 148 +++++++++++------- .../vanillatweaks_file/docker-compose.yml | 9 +- .../vanillatweaks_file/verify.sh | 4 + .../vanillatweaks_file/vt-craftingtweaks.json | 12 ++ ...weaks-datapacks.json => vt-datapacks.json} | 0 .../vanillatweaks_file/vt-resourcepacks.json | 8 + .../docker-compose.yml | 6 +- .../vanillatweaks_sharecode/verify.sh | 4 + 10 files changed, 189 insertions(+), 68 deletions(-) create mode 100644 tests/setuponlytests/vanillatweaks_file/verify.sh create mode 100644 tests/setuponlytests/vanillatweaks_file/vt-craftingtweaks.json rename tests/setuponlytests/vanillatweaks_file/{vanillatweaks-datapacks.json => vt-datapacks.json} (100%) create mode 100644 tests/setuponlytests/vanillatweaks_file/vt-resourcepacks.json create mode 100644 tests/setuponlytests/vanillatweaks_sharecode/verify.sh diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 6fbce060..ce2df038 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -15,8 +15,24 @@ Individual scripts can be iteratively developed, debugged, and tested using the First, build a baseline of the image to include the packages needed by existing or new scripts: -```shell script -docker build -t mc-dev . +PowerShell: +```powershell +$env:IMAGE_TO_TEST="mc-dev" +docker build -t $env:IMAGE_TO_TEST . +pushd tests/setuponlytests/vanillatweaks_file/ +docker-compose run mc +docker-compose down --remove-orphans +popd +``` + +Bash: +```bash +export IMAGE_TO_TEST=mc-dev +docker build -t $IMAGE_TO_TEST . +pushd tests/setuponlytests/vanillatweaks_file/ +docker-compose run mc +docker-compose down --remove-orphans +popd ``` Using the baseline image, an interactive container can be started to iteratively run the scripts to be developed. By attaching the current workspace directory, you can use the local editor of your choice to iteratively modify scripts while using the container to run them. @@ -116,4 +132,4 @@ for b in "${branches[@]}"; do git merge -s ours -m "Track latest from master" master git push origin done -``` \ No newline at end of file +``` diff --git a/README.md b/README.md index 853664c0..e7ba4c33 100644 --- a/README.md +++ b/README.md @@ -896,6 +896,9 @@ Datapacks will be placed in `/data/$LEVEL/datapacks` VanillaTweaks datapacks can be installed with a share code from the website UI **OR** a json file to specify packs to download and install. +Datapacks will be placed in `/data/$LEVEL/datapacks` +Resourcepacks will be placed in `/data/resourcepacks` + Accepted Parameters: - `VANILLATWEAKS_FILE` @@ -906,13 +909,19 @@ Accepted Parameters: - `REMOVE_OLD_VANILLATWEAKS_EXCLUDE` Example of expected Vanillatweaks sharecode: + **Note**: ResourcePacks, DataPacks, and CraftingTweaks all have separate sharecodes ```yaml -VANILLATWEAKS_SHARECODE: MGr52E +VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT ``` Example of expected Vanillatweaks file format: +```yaml +VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json +``` + +Datapacks Json: ```json { "version": "1.18", @@ -920,18 +929,39 @@ Example of expected Vanillatweaks file format: "survival": [ "graves", "multiplayer sleep", - "afk display", - "armor statues", - "unlock all recipes", - "fast leaf decay", - "coordinates hud" ], "items": ["armored elytra"] } } ``` -Datapacks will be placed in `/data/$LEVEL/datapacks` +Resourcepacks Json: +```json +{ + "type": "resourcepacks", + "version": "1.18", + "packs": { + "aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"] + }, + "result": "ok" +} +``` + +CraftingTweaks Json: +```json +{ + "type": "craftingtweaks", + "version": "1.18", + "packs": { + "quality of life": [ + "dropper to dispenser", + "double slabs", + "back to blocks" + ] + }, + "result": "ok" +} +``` ## Server configuration diff --git a/scripts/start-setupVanillaTweaks b/scripts/start-setupVanillaTweaks index 4da67423..2e78d619 100644 --- a/scripts/start-setupVanillaTweaks +++ b/scripts/start-setupVanillaTweaks @@ -12,73 +12,115 @@ set -e -o pipefail . "${SCRIPTS:-/}start-utils" isDebugging && set -x -out_dir=/data/${LEVEL:-world}/datapacks +VT_VERSION="" +DATAPACKS_DIR="/data/${LEVEL:-world}/datapacks" +RESOURCEPACKS_DIR="/data/resourcepacks" # Remove old VANILLATWEAKS -if isTrue "${REMOVE_OLD_VANILLATWEAKS}" && [ -z "${VANILLATWEAKS_FILE}" ]; then - if [ -d "$out_dir" ]; then - find "$out_dir" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete +if isTrue "${REMOVE_OLD_VANILLATWEAKS}"; then + # NOTE: datapacks include crafting tweaks. + if [ -d "$DATAPACKS_DIR" ]; then + find "$DATAPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete + fi + if [ -d "$RESOURCEPACKS_DIR" ]; then + find "$RESOURCEPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete fi fi +# Gets the download url and downloads the actual files. +getUrlAndDownload(){ + VT_FILE=$1 + URL_SUFFIX=$2 + OUTPUT_FILE=$3 + PACKS=$(jq -jc '.packs // empty' $VT_FILE) + if [ ! "$PACKS" ]; then + log "ERROR: unable to retrieve ${URL_SUFFIX} from ${VT_FILE}" + exit 2 + fi + + ZIPDATA_URL="https://vanillatweaks.net/assets/server/zip${URL_SUFFIX}.php" + DOWNLOAD_URL=$(curl -X POST -F "packs=${PACKS}" -F "version=${VT_VERSION}" $ZIPDATA_URL | jq -r '.link // empty') + if [ ! "$DOWNLOAD_URL" ]; then + log "ERROR: unable to retrieve ${URL_SUFFIX} packs from vanillatweaks.net!" + exit 2 + fi + + if ! get -o $OUTPUT_FILE "https://vanillatweaks.net${DOWNLOAD_URL}"; then + log "ERROR: failed to download ${URL_SUFFIX} from ${DOWNLOAD_URL}" + exit 2 + fi +} + +# Datapacks Handler +downloadDatapacks(){ + VT_FILE=$1 + URL_SUFFIX="datapacks" + OUTPUT_FILE="/tmp/vanillatweaks.zip" + getUrlAndDownload $VT_FILE $URL_SUFFIX $OUTPUT_FILE + mkdir -p "$DATAPACKS_DIR" + if ! unzip -o -d "$DATAPACKS_DIR" $OUTPUT_FILE; then + log "ERROR: failed to unzip the datapacks ${DATAPACKS} from ${OUTPUT_FILE}" + fi + rm -f $OUTPUT_FILE +} + +# Crafting Tweaks Handler +downloadCraftingtweaks(){ + VT_FILE=$1 + mkdir -p "$DATAPACKS_DIR" + getUrlAndDownload $VT_FILE "craftingtweaks" "${DATAPACKS_DIR}/craftingtweaks.zip" +} + +# Resourcepacks Handler +downloadResourcepacks(){ + VT_FILE=$1 + mkdir -p "$RESOURCEPACKS_DIR" + getUrlAndDownload $VT_FILE "resourcepacks" "${RESOURCEPACKS_DIR}/resourcepacks.zip" +} + # Example: VANILLATWEAKS_SHARECODE=MGr52E # Code generated from the UI website, typically a alphanumeric 6 digit code. if [[ "$VANILLATWEAKS_SHARECODE" ]]; then - VANILLATWEAKS_FILE=/tmp/vanillatweaksfile.json - SHARECODE_LOOKUP_URL="https://vanillatweaks.net/assets/server/sharecode.php?code=${VANILLATWEAKS_SHARECODE}" - curl -f $SHARECODE_LOOKUP_URL -o $VANILLATWEAKS_FILE - if [ ! -f "$VANILLATWEAKS_FILE" ]; then - log "ERROR: Unable to use share code provided to retreive vanillatweaks file" - exit 2 - fi + VANILLATWEAKS_FILE=() + for SHARECODE in ${VANILLATWEAKS_SHARECODE//,/ }; do + TMP_FILE="/tmp/${SHARECODE}.json" + SHARECODE_LOOKUP_URL="https://vanillatweaks.net/assets/server/sharecode.php?code=${SHARECODE}" + if ! get -o "$TMP_FILE" "$SHARECODE_LOOKUP_URL"; then + log "ERROR: Unable to use ${SHARECODE} share code provided to retrieve vanillatweaks file" + exit 2 + fi + VANILLATWEAKS_FILE+="${TMP_FILE}," + done fi -# Use vanillatweaks file to specify VT and datapacks +# Use vanillatweaks file to specify VT and datapacks and crafting tweaks if [[ "$VANILLATWEAKS_FILE" ]]; then - if [ ! -f "$VANILLATWEAKS_FILE" ]; then - log "ERROR: given VANILLATWEAKS_FILE file does not exist" - exit 2 - fi + for VT_FILE in ${VANILLATWEAKS_FILE//,/ }; do + if [ ! -f "$VT_FILE" ]; then + log "ERROR: given VANILLATWEAKS_FILE file does not exist" + exit 2 + fi - PACKS=$(jq -jc '.packs' $VANILLATWEAKS_FILE) - if [ ! "$PACKS" ]; then - log "ERROR: unable to retrieve packs from $VANILLATWEAKS_FILE" - exit 2 - fi + VT_VERSION=$(jq -jc '.version // empty' $VT_FILE) + if [ ! "$VT_VERSION" ]; then + log "ERROR: unable to retrieve version from $VT_FILE" + exit 2 + fi - VT_VERSION=$(jq -jc '.version' $VANILLATWEAKS_FILE) - if [ ! "$VT_VERSION" ]; then - log "ERROR: unable to retrieve version from $VANILLATWEAKS_FILE" - exit 2 - fi -fi + TYPE=$(jq -jc '.type // empty' $VT_FILE) + if [[ "$TYPE" = "datapacks" ]]; then + downloadDatapacks $VT_FILE + elif [[ "$TYPE" = "craftingtweaks" ]]; then + downloadCraftingtweaks $VT_FILE + elif [[ "$TYPE" = "resourcepacks" ]]; then + downloadResourcepacks $VT_FILE + fi -# Download and unzip packs -if [[ "$PACKS" ]] && [[ "$VT_VERSION" ]]; then - VT_ZIPDATA_URL=https://vanillatweaks.net/assets/server/zipdatapacks.php - DOWNLOAD_URL=$(curl -X POST -F "packs=${PACKS}" -F "version=${VT_VERSION}" $VT_ZIPDATA_URL | jq -r '.link') - if [ ! "$DOWNLOAD_URL" ]; then - log "ERROR: unable to retrieve DOWNLOAD_URL from vanillatweaks.net!" - exit 2 - fi - - TEMPZIP=/tmp/vanillatweaks.zip - if ! get -o $TEMPZIP "https://vanillatweaks.net${DOWNLOAD_URL}"; then - log "ERROR: failed to download from ${DOWNLOAD_URL}" - exit 2 - fi - - mkdir -p "$out_dir" - if ! unzip -o -d "$out_dir" $TEMPZIP; then - log "ERROR: failed to unzip the ${PACKS} from ${$TEMPZIP}" - fi - - # clean up files time! - rm -f $TEMPZIP - # cleans up temp vanilla tweaks file download to get stored packs - if [[ "$VANILLATWEAKS_SHARECODE" ]]; then - rm -f $VANILLATWEAKS_FILE - fi + # cleans up temp vanilla tweaks file download to get stored packs + if [[ "$VANILLATWEAKS_SHARECODE" ]]; then + rm -f $VT_FILE + fi + done fi exec "${SCRIPTS:-/}start-setupDatapack" "$@" diff --git a/tests/setuponlytests/vanillatweaks_file/docker-compose.yml b/tests/setuponlytests/vanillatweaks_file/docker-compose.yml index b33292ee..494fb6f1 100644 --- a/tests/setuponlytests/vanillatweaks_file/docker-compose.yml +++ b/tests/setuponlytests/vanillatweaks_file/docker-compose.yml @@ -8,7 +8,10 @@ services: EULA: "TRUE" SETUP_ONLY: "TRUE" VERSION: ${MINECRAFT_VERSION:-LATEST} - VANILLATWEAKS_FILE: /config/vanillatweaks-datapacks.json - REMOVE_OLD_VANILLATWEAKS: "TRUE" + VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json + REMOVE_OLD_VANILLATWEAKS: "FALSE" volumes: - - ./vanillatweaks-datapacks.json:/config/vanillatweaks-datapacks.json:ro + - ./data:/data + - ./vt-datapacks.json:/config/vt-datapacks.json:ro + - ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro + - ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro diff --git a/tests/setuponlytests/vanillatweaks_file/verify.sh b/tests/setuponlytests/vanillatweaks_file/verify.sh new file mode 100644 index 00000000..be7c0136 --- /dev/null +++ b/tests/setuponlytests/vanillatweaks_file/verify.sh @@ -0,0 +1,4 @@ +mc-image-helper assert fileExists "/data/world/datapacks/afk*" +mc-image-helper assert fileExists "/data/world/datapacks/graves*" +mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*" +mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*" diff --git a/tests/setuponlytests/vanillatweaks_file/vt-craftingtweaks.json b/tests/setuponlytests/vanillatweaks_file/vt-craftingtweaks.json new file mode 100644 index 00000000..12d65f4b --- /dev/null +++ b/tests/setuponlytests/vanillatweaks_file/vt-craftingtweaks.json @@ -0,0 +1,12 @@ +{ + "type": "craftingtweaks", + "version": "1.18", + "packs": { + "quality of life": [ + "dropper to dispenser", + "double slabs", + "back to blocks" + ] + }, + "result": "ok" +} \ No newline at end of file diff --git a/tests/setuponlytests/vanillatweaks_file/vanillatweaks-datapacks.json b/tests/setuponlytests/vanillatweaks_file/vt-datapacks.json similarity index 100% rename from tests/setuponlytests/vanillatweaks_file/vanillatweaks-datapacks.json rename to tests/setuponlytests/vanillatweaks_file/vt-datapacks.json diff --git a/tests/setuponlytests/vanillatweaks_file/vt-resourcepacks.json b/tests/setuponlytests/vanillatweaks_file/vt-resourcepacks.json new file mode 100644 index 00000000..3917caf9 --- /dev/null +++ b/tests/setuponlytests/vanillatweaks_file/vt-resourcepacks.json @@ -0,0 +1,8 @@ +{ + "type": "resourcepacks", + "version": "1.18", + "packs": { + "aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"] + }, + "result": "ok" +} \ No newline at end of file diff --git a/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml b/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml index 66eac5b5..4e9b27ca 100644 --- a/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml +++ b/tests/setuponlytests/vanillatweaks_sharecode/docker-compose.yml @@ -8,5 +8,7 @@ services: EULA: "TRUE" SETUP_ONLY: "TRUE" VERSION: ${MINECRAFT_VERSION:-LATEST} - VANILLATWEAKS_SHARECODE: MGr52E - REMOVE_OLD_VANILLATWEAKS: "TRUE" + VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT + REMOVE_OLD_VANILLATWEAKS: "FALSE" + volumes: + - ./data:/data diff --git a/tests/setuponlytests/vanillatweaks_sharecode/verify.sh b/tests/setuponlytests/vanillatweaks_sharecode/verify.sh new file mode 100644 index 00000000..be7c0136 --- /dev/null +++ b/tests/setuponlytests/vanillatweaks_sharecode/verify.sh @@ -0,0 +1,4 @@ +mc-image-helper assert fileExists "/data/world/datapacks/afk*" +mc-image-helper assert fileExists "/data/world/datapacks/graves*" +mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*" +mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*" From 1dd9a2e6e0f5518c70a90776113c95b49fd4a1d8 Mon Sep 17 00:00:00 2001 From: itzg Date: Sun, 6 Feb 2022 18:45:40 +0000 Subject: [PATCH 2/6] docs: Auto update markdown TOC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7ba4c33..e0b89ae9 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,7 @@ By default, the container will download the latest version of the "vanilla" [Min * [Running on RaspberryPi](#running-on-raspberrypi) * [Contributing](#contributing) - + From b7bbe1b0a6cf33828313738fa02c84b8aa6ad153 Mon Sep 17 00:00:00 2001 From: Luc Ritchie Date: Sun, 6 Feb 2022 16:51:28 -0500 Subject: [PATCH 3/6] Support Spigot-style and vanilla-style world zips, for any server type (#1305) --- scripts/start-setupWorld | 63 +++++++++++++++--- .../docker-compose.yml | 15 +++++ .../verify.sh | 5 ++ .../worlds/world-for-testing.zip | Bin 0 -> 2460 bytes .../docker-compose.yml | 14 ++++ .../verify.sh | 5 ++ .../worlds/world-for-testing.zip | Bin 0 -> 2460 bytes .../docker-compose.yml | 15 +++++ .../spigot_world_for_spigot_server/verify.sh | 4 ++ .../worlds/world-for-testing.zip | Bin 0 -> 1674 bytes .../docker-compose.yml | 14 ++++ .../spigot_world_for_vanilla_server/verify.sh | 4 ++ .../worlds/world-for-testing.zip | Bin 0 -> 1674 bytes .../docker-compose.yml | 15 +++++ .../vanilla_world_for_spigot_server/verify.sh | 3 + .../worlds/world-for-testing.zip | Bin 0 -> 782 bytes .../docker-compose.yml | 14 ++++ .../verify.sh | 3 + .../worlds/world-for-testing.zip | Bin 0 -> 782 bytes 19 files changed, 163 insertions(+), 11 deletions(-) create mode 100644 tests/setuponlytests/conflicting_world_for_spigot_server/docker-compose.yml create mode 100644 tests/setuponlytests/conflicting_world_for_spigot_server/verify.sh create mode 100644 tests/setuponlytests/conflicting_world_for_spigot_server/worlds/world-for-testing.zip create mode 100644 tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml create mode 100644 tests/setuponlytests/conflicting_world_for_vanilla_server/verify.sh create mode 100644 tests/setuponlytests/conflicting_world_for_vanilla_server/worlds/world-for-testing.zip create mode 100644 tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml create mode 100644 tests/setuponlytests/spigot_world_for_spigot_server/verify.sh create mode 100644 tests/setuponlytests/spigot_world_for_spigot_server/worlds/world-for-testing.zip create mode 100644 tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml create mode 100644 tests/setuponlytests/spigot_world_for_vanilla_server/verify.sh create mode 100644 tests/setuponlytests/spigot_world_for_vanilla_server/worlds/world-for-testing.zip create mode 100644 tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml create mode 100644 tests/setuponlytests/vanilla_world_for_spigot_server/verify.sh create mode 100644 tests/setuponlytests/vanilla_world_for_spigot_server/worlds/world-for-testing.zip create mode 100644 tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml create mode 100644 tests/setuponlytests/vanilla_world_for_vanilla_server/verify.sh create mode 100644 tests/setuponlytests/vanilla_world_for_vanilla_server/worlds/world-for-testing.zip diff --git a/scripts/start-setupWorld b/scripts/start-setupWorld index dc3901e9..10c9b486 100755 --- a/scripts/start-setupWorld +++ b/scripts/start-setupWorld @@ -37,11 +37,7 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); exit 1 fi - if [ "$FAMILY" = "SPIGOT" ]; then - baseDirs=$(find /tmp/world-data -name "level.dat" -not -path "*_nether*" -not -path "*_the_end*" -exec dirname "{}" \;) - else - baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;) - fi + baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;) if ! [[ $baseDirs ]]; then log "ERROR world content is not valid since level.dat could not be found" @@ -50,20 +46,65 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); count=$(echo "$baseDirs" | wc -l) if [[ $count -gt 1 ]]; then - baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)" - baseName=$(basename "$baseDir") - log "WARN multiple levels found, picking: $baseName" + baseDirsNoSpigotSuffix=$(echo "$baseDirs" | sed -re 's:(_nether|_the_end)/?$::' | sort -u) + if [ $(echo "$baseDirsNoSpigotSuffix" | wc -l) -eq 1 ]; then + baseDir="$baseDirsNoSpigotSuffix" + baseName=$(basename "$baseDir") + log "Found Spigot naming conventions, taking $baseName as main dimension" + else + baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)" + baseName=$(basename "$baseDir") + log "WARN multiple levels found, picking: $baseName" + fi elif [[ $count -gt 0 ]]; then baseDir="$baseDirs" else log "ERROR invalid world content" exit 1 fi + + if [ -d "${baseDir}_nether/DIM-1" ]; then + if [ -d "$baseDir/DIM-1" ]; then + log "WARN found Nether dimension in both $baseDir and ${baseDir}_nether, picking ${baseDir}_nether" + rm -r "$baseDir/DIM-1" + fi + fi + if [ -d "${baseDir}_the_end/DIM1" ]; then + if [ -d "$baseDir/DIM1" ]; then + log "WARN found End dimension in both $baseDir and ${baseDir}_the_end, picking ${baseDir}_the_end" + rm -r "$baseDir/DIM1" + fi + fi + + log "Copying world..." rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest" + if [ "$FAMILY" = "SPIGOT" ]; then - log "Copying end and nether ..." - [ -d "${baseDir}_nether" ] && rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether" - [ -d "${baseDir}_the_end" ] && rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end" + if [ -d "${baseDir}_nether" ]; then + log "Copying Spigot Nether..." + rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether" + elif [ -d "$worldDest/DIM-1" ]; then + log "Moving Nether to Spigot location..." + mkdir -p "${worldDest}_nether" + mv -f "$worldDest/DIM-1" "${worldDest}_nether/" + fi + if [ -d "${baseDir}_the_end" ]; then + log "Copying Spigot End..." + rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end" + elif [ -d "$worldDest/DIM1" ]; then + log "Moving End to Spigot location..." + mkdir -p "${worldDest}_the_end" + mv -f "$worldDest/DIM1" "${worldDest}_the_end/" + fi + else + if [ -d "${baseDir}_nether/DIM-1" ]; then + log "Copying Spigot Nether to vanilla location..." + rsync --remove-source-files --recursive --delete "${baseDir}_nether/DIM-1" "${worldDest}/" + fi + if [ -d "${baseDir}_the_end/DIM1" ]; then + log "Copying Spigot End to vanilla location..." + rsync --remove-source-files --recursive --delete "${baseDir}_the_end/DIM1" "${worldDest}/" + fi fi elif [ -d "$WORLD" ]; then log "Cloning world directory from $WORLD ..." diff --git a/tests/setuponlytests/conflicting_world_for_spigot_server/docker-compose.yml b/tests/setuponlytests/conflicting_world_for_spigot_server/docker-compose.yml new file mode 100644 index 00000000..b8172d99 --- /dev/null +++ b/tests/setuponlytests/conflicting_world_for_spigot_server/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + VERSION: ${MINECRAFT_VERSION:-LATEST} + TYPE: "PAPER" + WORLD: /worlds/world-for-testing.zip + volumes: + - ./worlds:/worlds:ro + - ./data:/data diff --git a/tests/setuponlytests/conflicting_world_for_spigot_server/verify.sh b/tests/setuponlytests/conflicting_world_for_spigot_server/verify.sh new file mode 100644 index 00000000..75daef8d --- /dev/null +++ b/tests/setuponlytests/conflicting_world_for_spigot_server/verify.sh @@ -0,0 +1,5 @@ +mc-image-helper assert fileExists world/level.dat && \ +mc-image-helper assert fileExists world_nether/DIM-1/some_spigot_nether_file && \ +mc-image-helper assert fileExists world_the_end/DIM1/some_spigot_end_file && \ +! mc-image-helper assert fileExists world_nether/DIM-1/some_vanilla_nether_file && \ +! mc-image-helper assert fileExists world_the_end/DIM1/some_vanilla_end_file diff --git a/tests/setuponlytests/conflicting_world_for_spigot_server/worlds/world-for-testing.zip b/tests/setuponlytests/conflicting_world_for_spigot_server/worlds/world-for-testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..20520f029511e5279fdb2781468e9ff7f58c4223 GIT binary patch literal 2460 zcmai$K}#D!6vrnfDOhW1F?aU_ZvZvqw&2RJmr1~jec+BuKb+%Fy57F%@ zd&Tx!yZl?L9n_otF0X9XMp^#ryPz^0H>3UhynXvhE7#`f~`prfV_#SW8y{$&T#kiP&m-YPD zr@F^kk|5x%E^iC93jG5tI8DqLCQ1YiCKe(UM_DRNTG>L=Tr_!Shqu+tn1Yv8$E~4b z(oFF}WcdF2py0~&V<;O6UfOU86USL5swes@`{0HOA^Urc?N%omUip}w8~Sr_S$*6X zKBh<(2*#gWDC9g#$Wo>d$x~a>&l0j>2&q_y6wss)ZCOe-8@Z9!d0XvFM+NkZ4L;%{ z(vu}r3`>X@R!mw!lF8U*Z;db$g#>UcBnRAVkO?N?IPfWfN7@0LS{rI=6FeV-aq2(m zU~M^-`|LDYQ}P(XQO@)(g3Qu_7%VM^Ewf}w@uASx1&NVs3*^*VQMycWIVR%){#nSH zFRje76KR!6Wq6h^BZe|nY=FjMb7-QqmPGe$=!7jSIY$7kI2nMp{<{N&w6wy5gJI!0 za%tVkTy(Y#e;*JYueT@5YO@AxEI$XER$r2RZ)K~E#3FPA&>EBhDD6qXHoOQ(O4Ak- WOOb>YAHjaJarizjGIjuH#vTA4FE0oH literal 0 HcmV?d00001 diff --git a/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml b/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml new file mode 100644 index 00000000..4a30460e --- /dev/null +++ b/tests/setuponlytests/conflicting_world_for_vanilla_server/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + VERSION: ${MINECRAFT_VERSION:-LATEST} + WORLD: /worlds/world-for-testing.zip + volumes: + - ./worlds:/worlds:ro + - ./data:/data diff --git a/tests/setuponlytests/conflicting_world_for_vanilla_server/verify.sh b/tests/setuponlytests/conflicting_world_for_vanilla_server/verify.sh new file mode 100644 index 00000000..020b8637 --- /dev/null +++ b/tests/setuponlytests/conflicting_world_for_vanilla_server/verify.sh @@ -0,0 +1,5 @@ +mc-image-helper assert fileExists world/level.dat && \ +mc-image-helper assert fileExists world/DIM-1/some_spigot_nether_file && \ +mc-image-helper assert fileExists world/DIM1/some_spigot_end_file && \ +! mc-image-helper assert fileExists world/DIM-1/some_vanilla_nether_file && \ +! mc-image-helper assert fileExists world/DIM1/some_vanilla_end_file diff --git a/tests/setuponlytests/conflicting_world_for_vanilla_server/worlds/world-for-testing.zip b/tests/setuponlytests/conflicting_world_for_vanilla_server/worlds/world-for-testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..20520f029511e5279fdb2781468e9ff7f58c4223 GIT binary patch literal 2460 zcmai$K}#D!6vrnfDOhW1F?aU_ZvZvqw&2RJmr1~jec+BuKb+%Fy57F%@ zd&Tx!yZl?L9n_otF0X9XMp^#ryPz^0H>3UhynXvhE7#`f~`prfV_#SW8y{$&T#kiP&m-YPD zr@F^kk|5x%E^iC93jG5tI8DqLCQ1YiCKe(UM_DRNTG>L=Tr_!Shqu+tn1Yv8$E~4b z(oFF}WcdF2py0~&V<;O6UfOU86USL5swes@`{0HOA^Urc?N%omUip}w8~Sr_S$*6X zKBh<(2*#gWDC9g#$Wo>d$x~a>&l0j>2&q_y6wss)ZCOe-8@Z9!d0XvFM+NkZ4L;%{ z(vu}r3`>X@R!mw!lF8U*Z;db$g#>UcBnRAVkO?N?IPfWfN7@0LS{rI=6FeV-aq2(m zU~M^-`|LDYQ}P(XQO@)(g3Qu_7%VM^Ewf}w@uASx1&NVs3*^*VQMycWIVR%){#nSH zFRje76KR!6Wq6h^BZe|nY=FjMb7-QqmPGe$=!7jSIY$7kI2nMp{<{N&w6wy5gJI!0 za%tVkTy(Y#e;*JYueT@5YO@AxEI$XER$r2RZ)K~E#3FPA&>EBhDD6qXHoOQ(O4Ak- WOOb>YAHjaJarizjGIjuH#vTA4FE0oH literal 0 HcmV?d00001 diff --git a/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml b/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml new file mode 100644 index 00000000..b8172d99 --- /dev/null +++ b/tests/setuponlytests/spigot_world_for_spigot_server/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + VERSION: ${MINECRAFT_VERSION:-LATEST} + TYPE: "PAPER" + WORLD: /worlds/world-for-testing.zip + volumes: + - ./worlds:/worlds:ro + - ./data:/data diff --git a/tests/setuponlytests/spigot_world_for_spigot_server/verify.sh b/tests/setuponlytests/spigot_world_for_spigot_server/verify.sh new file mode 100644 index 00000000..233a8497 --- /dev/null +++ b/tests/setuponlytests/spigot_world_for_spigot_server/verify.sh @@ -0,0 +1,4 @@ +mc-image-helper assert fileExists world/level.dat && \ +mc-image-helper assert fileExists world/some_overworld_file && \ +mc-image-helper assert fileExists world_nether/DIM-1/some_nether_file && \ +mc-image-helper assert fileExists world_the_end/DIM1/some_end_file diff --git a/tests/setuponlytests/spigot_world_for_spigot_server/worlds/world-for-testing.zip b/tests/setuponlytests/spigot_world_for_spigot_server/worlds/world-for-testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..8f779b16b68f96481f74c5038b1a83471bd3a851 GIT binary patch literal 1674 zcmb7_ze>YU6o*fnR;YqF_@_`&oLVU=PHuweph!!Hb`F7FQAk^)Sah2c z#XBVy*&r0*g&icW2UgBuGEqdpo>#hEhw0dn2Ral6_9i3FRc0FhwS2z0P z(6SjSU3gOmA}FM2a{SIjENdaC!4~bNH}qqYiE5$=#X}XoiNz!n99oJUQbMH(968WH z2@^G>(rZ>+3-W#+7GQKhpS%-UuM^rC3z&K%6cgb2{#av%`hjrjhXJm)BMcvE@QGbX z-a&7QiXksQJSON3qNz8A4fp{sKp1_PV#*a-bqE9Kcux^f9tV*BfjL0$Q*xl*rtn68 zTA=DeqmFFqmSGuQf~c)Zn%h!rzh@XgEtn#p6tVSW4q%;&OUusSfq@*}m-GX{2jCwY CSa*W} literal 0 HcmV?d00001 diff --git a/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml b/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml new file mode 100644 index 00000000..4a30460e --- /dev/null +++ b/tests/setuponlytests/spigot_world_for_vanilla_server/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + VERSION: ${MINECRAFT_VERSION:-LATEST} + WORLD: /worlds/world-for-testing.zip + volumes: + - ./worlds:/worlds:ro + - ./data:/data diff --git a/tests/setuponlytests/spigot_world_for_vanilla_server/verify.sh b/tests/setuponlytests/spigot_world_for_vanilla_server/verify.sh new file mode 100644 index 00000000..a0d1a149 --- /dev/null +++ b/tests/setuponlytests/spigot_world_for_vanilla_server/verify.sh @@ -0,0 +1,4 @@ +mc-image-helper assert fileExists world/level.dat && \ +mc-image-helper assert fileExists world/some_overworld_file && \ +mc-image-helper assert fileExists world/DIM-1/some_nether_file && \ +mc-image-helper assert fileExists world/DIM1/some_end_file diff --git a/tests/setuponlytests/spigot_world_for_vanilla_server/worlds/world-for-testing.zip b/tests/setuponlytests/spigot_world_for_vanilla_server/worlds/world-for-testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..8f779b16b68f96481f74c5038b1a83471bd3a851 GIT binary patch literal 1674 zcmb7_ze>YU6o*fnR;YqF_@_`&oLVU=PHuweph!!Hb`F7FQAk^)Sah2c z#XBVy*&r0*g&icW2UgBuGEqdpo>#hEhw0dn2Ral6_9i3FRc0FhwS2z0P z(6SjSU3gOmA}FM2a{SIjENdaC!4~bNH}qqYiE5$=#X}XoiNz!n99oJUQbMH(968WH z2@^G>(rZ>+3-W#+7GQKhpS%-UuM^rC3z&K%6cgb2{#av%`hjrjhXJm)BMcvE@QGbX z-a&7QiXksQJSON3qNz8A4fp{sKp1_PV#*a-bqE9Kcux^f9tV*BfjL0$Q*xl*rtn68 zTA=DeqmFFqmSGuQf~c)Zn%h!rzh@XgEtn#p6tVSW4q%;&OUusSfq@*}m-GX{2jCwY CSa*W} literal 0 HcmV?d00001 diff --git a/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml b/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml new file mode 100644 index 00000000..b8172d99 --- /dev/null +++ b/tests/setuponlytests/vanilla_world_for_spigot_server/docker-compose.yml @@ -0,0 +1,15 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + VERSION: ${MINECRAFT_VERSION:-LATEST} + TYPE: "PAPER" + WORLD: /worlds/world-for-testing.zip + volumes: + - ./worlds:/worlds:ro + - ./data:/data diff --git a/tests/setuponlytests/vanilla_world_for_spigot_server/verify.sh b/tests/setuponlytests/vanilla_world_for_spigot_server/verify.sh new file mode 100644 index 00000000..89a74836 --- /dev/null +++ b/tests/setuponlytests/vanilla_world_for_spigot_server/verify.sh @@ -0,0 +1,3 @@ +mc-image-helper assert fileExists world/level.dat && \ +mc-image-helper assert fileExists world_nether/DIM-1/some_nether_file && \ +mc-image-helper assert fileExists world_the_end/DIM1/some_end_file diff --git a/tests/setuponlytests/vanilla_world_for_spigot_server/worlds/world-for-testing.zip b/tests/setuponlytests/vanilla_world_for_spigot_server/worlds/world-for-testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..cfdd882edcc677460ad106197059108cd911e1db GIT binary patch literal 782 zcmWIWW@h1H0D*uRb|GK}lwf0!VQ}&E)iu-)4dG;9mQeqms1C%X72FJrEH9WD7{EjT zPW@tV{l)pYsquNKB^jwj@oAYksc`c^X5uu@56wNS5c8nU5h3IpbnQYg?O@lW=A|H< z0x}DPaXY2P93^NtfoA2TmZj$Cr6iVseRE~^+eCS6MldqTG2;qf31~oh5Y7T>hy!8<1^}cZho%4k literal 0 HcmV?d00001 diff --git a/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml b/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml new file mode 100644 index 00000000..4a30460e --- /dev/null +++ b/tests/setuponlytests/vanilla_world_for_vanilla_server/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3" + +services: + mc: + restart: "no" + image: ${IMAGE_TO_TEST:-itzg/minecraft-server} + environment: + EULA: "TRUE" + SETUP_ONLY: "TRUE" + VERSION: ${MINECRAFT_VERSION:-LATEST} + WORLD: /worlds/world-for-testing.zip + volumes: + - ./worlds:/worlds:ro + - ./data:/data diff --git a/tests/setuponlytests/vanilla_world_for_vanilla_server/verify.sh b/tests/setuponlytests/vanilla_world_for_vanilla_server/verify.sh new file mode 100644 index 00000000..82e2044c --- /dev/null +++ b/tests/setuponlytests/vanilla_world_for_vanilla_server/verify.sh @@ -0,0 +1,3 @@ +mc-image-helper assert fileExists world/level.dat && \ +mc-image-helper assert fileExists world/DIM-1/some_nether_file && \ +mc-image-helper assert fileExists world/DIM1/some_end_file diff --git a/tests/setuponlytests/vanilla_world_for_vanilla_server/worlds/world-for-testing.zip b/tests/setuponlytests/vanilla_world_for_vanilla_server/worlds/world-for-testing.zip new file mode 100644 index 0000000000000000000000000000000000000000..cfdd882edcc677460ad106197059108cd911e1db GIT binary patch literal 782 zcmWIWW@h1H0D*uRb|GK}lwf0!VQ}&E)iu-)4dG;9mQeqms1C%X72FJrEH9WD7{EjT zPW@tV{l)pYsquNKB^jwj@oAYksc`c^X5uu@56wNS5c8nU5h3IpbnQYg?O@lW=A|H< z0x}DPaXY2P93^NtfoA2TmZj$Cr6iVseRE~^+eCS6MldqTG2;qf31~oh5Y7T>hy!8<1^}cZho%4k literal 0 HcmV?d00001 From f2f8d58d3b5fd9804ec9cc0627b91beed5f3dbff Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 6 Feb 2022 17:46:17 -0600 Subject: [PATCH 4/6] Only skip up-to-date files with MODS and MODS_FILE (#1338) Fixes #1254 --- scripts/start-setupModpack | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index cc421780..e3539eb3 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -92,7 +92,7 @@ elif [[ "$MODS" ]]; then do if isURL "$i"; then log "Downloading mod/plugin $i ..." - if ! get -o "${out_dir}" "$i"; then + if ! get --skip-up-to-date -o "${out_dir}" "$i"; then log "ERROR: failed to download from $i into $out_dir" exit 2 fi @@ -128,7 +128,7 @@ elif [[ "$MODS_FILE" ]]; then args=( -o "${out_dir}" --log-progress-each - --skip-existing + --skip-up-to-date --uris-file "${MODS_FILE}" ) if isTrue "${REMOVE_OLD_MODS}"; then @@ -200,7 +200,7 @@ if [[ "${GENERIC_PACKS}" ]]; then if isURL "${pack}"; then mkdir -p /data/packs log "Downloading generic pack from $pack" - if ! outfile=$(get -o /data/packs --output-filename --skip-existing "$pack"); then + if ! outfile=$(get -o /data/packs --output-filename --skip-up-to-date "$pack"); then log "ERROR: failed to download $pack" exit 2 fi From 932cd8f89e19fd09ac8adcfc222d34643f66caff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Feb 2022 06:54:56 -0600 Subject: [PATCH 5/6] build(deps): bump docker/build-push-action from 2.8.0 to 2.9.0 (#1339) --- .github/workflows/build-multiarch.yml | 4 ++-- .github/workflows/ci.yml | 2 +- .github/workflows/main.yml | 4 ++-- .github/workflows/pr.yml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml index 3f37ce8c..bcc9ce09 100644 --- a/.github/workflows/build-multiarch.yml +++ b/.github/workflows/build-multiarch.yml @@ -90,7 +90,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Build for test - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 with: platforms: linux/amd64 tags: ${{ env.IMAGE_TO_TEST }} @@ -112,7 +112,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 with: platforms: ${{ matrix.platforms }} push: ${{ github.ref_type == 'tag' || github.ref_name == 'master' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb720843..1c151670 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Build - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 with: context: . platforms: linux/amd64 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 269eff23..621af08a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,7 +53,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Build for test - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 if: github.ref_name == 'java8' with: context: . @@ -75,7 +75,7 @@ jobs: - name: Build and push id: docker_build - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 with: context: . file: ./Dockerfile diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b5580287..839a2ff8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -24,7 +24,7 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Build - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 with: context: . platforms: linux/amd64 @@ -53,7 +53,7 @@ jobs: - name: Push if: contains(github.event.pull_request.labels.*.name, 'ci/push-image') - uses: docker/build-push-action@v2.8.0 + uses: docker/build-push-action@v2.9.0 with: context: . platforms: linux/amd64,linux/arm/v7,linux/arm64 From 4cb227629f48509398f90035b83cfabb429d2081 Mon Sep 17 00:00:00 2001 From: Jordy Hulck Date: Wed, 9 Feb 2022 02:17:26 +0100 Subject: [PATCH 6/6] Distro aware checksum (#1345) --- scripts/start-setupModpack | 2 +- scripts/start-utils | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/start-setupModpack b/scripts/start-setupModpack index e3539eb3..1442e393 100755 --- a/scripts/start-setupModpack +++ b/scripts/start-setupModpack @@ -215,7 +215,7 @@ if [[ "${GENERIC_PACKS}" ]]; then log "Checking if generic packs are up to date" if isTrue "${SKIP_GENERIC_PACK_UPDATE_CHECK:-false}" && [ -f "$sum_file" ]; then log "Skipping generic pack update check" - elif isTrue "${FORCE_GENERIC_PACK_UPDATE}" || ! sha1sum -c "${sum_file}" --status 2> /dev/null; then + elif isTrue "${FORCE_GENERIC_PACK_UPDATE}" || ! checkSum "${sum_file}"; then log "Generic pack(s) are out of date. Re-applying..." base_dir=/tmp/generic_pack_base diff --git a/scripts/start-utils b/scripts/start-utils index d56d41f2..cdce61be 100755 --- a/scripts/start-utils +++ b/scripts/start-utils @@ -236,3 +236,20 @@ function extract() { ;; esac } + +function checkSum() { + local sum_file=${1?} + + # Get distro + distro=$(cat /etc/os-release | grep -E "^ID=" | cut -d= -f2 | sed -e 's/"//g') + + if [ "${distro}" == "debian" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then + return 0 + elif [ "${distro}" == "ubuntu" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then + return 0 + elif [ "${distro}" == "alpine" ] && sha1sum -c "${sum_file}" -s 2> /dev/null; then + return 0 + else + return 1 + fi +}