mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-11-21 22:32:39 +00:00
Determine SPIGET file type from API (#1427)
This commit is contained in:
1 parent
2042450f9b
commit
5ae5733741
4 files changed
+13
-9
No files matched your search
@@ -89,24 +89,27 @@ downloadResourceFromSpiget() {
|
|||||||
|
|
||||||
resourceUrl="https://api.spiget.org/v2/resources/${resource}"
|
resourceUrl="https://api.spiget.org/v2/resources/${resource}"
|
||||||
if ! outfile=$(get --output-filename -o /tmp "${acceptArgs[@]}" "${resourceUrl}/download"); then
|
if ! outfile=$(get --output-filename -o /tmp "${acceptArgs[@]}" "${resourceUrl}/download"); then
|
||||||
log "ERROR: failed to download resource '${resource}' from ${resourceUrl}/download"
|
log "ERROR: failed to download resource '${resource}' from ${resourceUrl}/download"
|
||||||
if externalUrl=$(get --json-path '$.file.externalUrl' "${resourceUrl}"); then
|
if externalUrl=$(get --json-path '$.file.externalUrl' "${resourceUrl}"); then
|
||||||
log " Visit $externalUrl to pre-download the resource"
|
log " Visit $externalUrl to pre-download the resource"
|
||||||
log " instead of using SPIGET_RESOURCES"
|
log " instead of using SPIGET_RESOURCES"
|
||||||
fi
|
fi
|
||||||
exit 2
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
contentType=$(file -b --mime-type "$outfile")
|
if ! fileType=$(get --json-path '.file.type' "${resourceUrl}"); then
|
||||||
if [[ $contentType == application/zip ]]; then
|
log "ERROR: failed to retrieve file type of resource $resource"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ $fileType == .zip ]]; then
|
||||||
log "Extracting contents of resource ${resource} into plugins"
|
log "Extracting contents of resource ${resource} into plugins"
|
||||||
extract "$outfile" /data/plugins
|
extract "$outfile" /data/plugins
|
||||||
rm "$outfile"
|
rm "$outfile"
|
||||||
elif [[ $contentType == application/java-archive ]]; then
|
elif [[ $fileType == .jar ]]; then
|
||||||
log "Moving resource ${resource} into plugins"
|
log "Moving resource ${resource} into plugins"
|
||||||
mv "$outfile" /data/plugins
|
mv "$outfile" /data/plugins
|
||||||
else
|
else
|
||||||
log "ERROR: file for resource ${resource} is not a valid content type: ${contentType}"
|
log "ERROR: file for resource ${resource} has an unexpected file type: ${fileType}"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -234,7 +234,7 @@ function extract() {
|
|||||||
type=$(file -b --mime-type "${src}")
|
type=$(file -b --mime-type "${src}")
|
||||||
case "${type}" in
|
case "${type}" in
|
||||||
application/zip)
|
application/zip)
|
||||||
unzip -q -d "${destDir}" "${src}"
|
unzip -o -q -d "${destDir}" "${src}"
|
||||||
;;
|
;;
|
||||||
application/x-tar|application/gzip|application/x-gzip|application/x-bzip2|application/zstd|application/x-zstd)
|
application/x-tar|application/gzip|application/x-gzip|application/x-bzip2|application/zstd|application/x-zstd)
|
||||||
tar -C "${destDir}" -xf "${src}"
|
tar -C "${destDir}" -xf "${src}"
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ services:
|
|||||||
EULA: "TRUE"
|
EULA: "TRUE"
|
||||||
SETUP_ONLY: "TRUE"
|
SETUP_ONLY: "TRUE"
|
||||||
TYPE: PAPER
|
TYPE: PAPER
|
||||||
SPIGET_RESOURCES: "34315,3836"
|
SPIGET_RESOURCES: "34315,3836,6245"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
mc-image-helper assert fileExists plugins/3836.jar
|
mc-image-helper assert fileExists plugins/3836.jar
|
||||||
mc-image-helper assert fileExists plugins/34315.jar
|
mc-image-helper assert fileExists plugins/34315.jar
|
||||||
|
mc-image-helper assert fileExists plugins/6245.jar
|
||||||
Reference in new issue
Block a user