Use file content to detect spiget resource type (#1432)

For #1426
This commit is contained in:
Geoff Bourne 2022-03-17 22:07:34 -05:00 committed by GitHub
parent fda8981028
commit 4ff158266a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View file

@ -9,7 +9,7 @@ handleDebugMode
: "${SPIGET_RESOURCES:=}"
: "${SPIGET_DOWNLOAD_TOLERANCE:=5}" # in minutes
acceptArgs=(--accept application/zip --accept application/java-archive)
acceptArgs=(--accept application/zip --accept application/java-archive --accept application/octet-stream)
containsJars() {
file=${1?}
@ -20,7 +20,7 @@ containsJars() {
if [[ $line =~ $pat ]]; then
return 0
fi
done < <(unzip -l "$file")
done < <(unzip -l "$file" | tail -n +4)
return 1
}
@ -34,7 +34,7 @@ containsPlugin() {
if [[ $line =~ $pat ]]; then
return 0
fi
done < <(unzip -l "$file")
done < <(unzip -l "$file" | tail -n +4)
return 1
}
@ -101,11 +101,11 @@ downloadResourceFromSpiget() {
log "ERROR: failed to retrieve file type of resource $resource"
exit 1
fi
if [[ $fileType == .zip ]]; then
if containsJars "${outfile}"; then
log "Extracting contents of resource ${resource} into plugins"
extract "$outfile" /data/plugins
rm "$outfile"
elif [[ $fileType == .jar ]]; then
elif containsPlugin "${outfile}"; then
log "Moving resource ${resource} into plugins"
mv "$outfile" /data/plugins
else

View file

@ -8,6 +8,6 @@ services:
EULA: "TRUE"
SETUP_ONLY: "TRUE"
TYPE: PAPER
SPIGET_RESOURCES: "34315,3836,6245"
SPIGET_RESOURCES: "34315,3836,6245,2124"
volumes:
- ./data:/data

View file

@ -1,3 +1,4 @@
mc-image-helper assert fileExists plugins/3836.jar
mc-image-helper assert fileExists plugins/34315.jar
mc-image-helper assert fileExists plugins/6245.jar
mc-image-helper assert fileExists plugins/6245.jar
mc-image-helper assert fileExists plugins/SkinsRestorer.jar