mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-12-05 01:49:16 +00:00
Determine SPIGET file type from API (#1427)
This commit is contained in:
parent
2042450f9b
commit
5ae5733741
4 changed files with 13 additions and 9 deletions
|
@ -89,24 +89,27 @@ downloadResourceFromSpiget() {
|
|||
|
||||
resourceUrl="https://api.spiget.org/v2/resources/${resource}"
|
||||
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
|
||||
log " Visit $externalUrl to pre-download the resource"
|
||||
log " instead of using SPIGET_RESOURCES"
|
||||
fi
|
||||
exit 2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
contentType=$(file -b --mime-type "$outfile")
|
||||
if [[ $contentType == application/zip ]]; then
|
||||
if ! fileType=$(get --json-path '.file.type' "${resourceUrl}"); 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"
|
||||
extract "$outfile" /data/plugins
|
||||
rm "$outfile"
|
||||
elif [[ $contentType == application/java-archive ]]; then
|
||||
elif [[ $fileType == .jar ]]; then
|
||||
log "Moving resource ${resource} into plugins"
|
||||
mv "$outfile" /data/plugins
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ function extract() {
|
|||
type=$(file -b --mime-type "${src}")
|
||||
case "${type}" in
|
||||
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)
|
||||
tar -C "${destDir}" -xf "${src}"
|
||||
|
|
|
@ -8,6 +8,6 @@ services:
|
|||
EULA: "TRUE"
|
||||
SETUP_ONLY: "TRUE"
|
||||
TYPE: PAPER
|
||||
SPIGET_RESOURCES: "34315,3836"
|
||||
SPIGET_RESOURCES: "34315,3836,6245"
|
||||
volumes:
|
||||
- ./data:/data
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
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
|
Loading…
Reference in a new issue