Skip to content

Commit

Permalink
Merge pull request #767 from felddy/feature/file-check
Browse files Browse the repository at this point in the history
Feature:  Check installation file for correct type
  • Loading branch information
felddy authored Aug 29, 2023
2 parents 5ffd050 + f1b89ba commit 57ddc42
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ RUN addgroup --system --gid ${FOUNDRY_UID} foundry \
&& adduser --system --uid ${FOUNDRY_UID} --ingroup foundry foundry \
&& apk --update --no-cache add \
curl \
file \
jq \
sed \
su-exec \
Expand Down
27 changes: 25 additions & 2 deletions src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,31 @@ if [ $install_required = true ]; then

if [ -f "${release_filename}" ]; then
log "Installing Foundry Virtual Tabletop ${FOUNDRY_VERSION}"
unzip -q "${release_filename}" 'resources/*'
log_debug "Installation completed."

# Check the mime-type of the file
log_debug "Checking mime-type of release file."
mime_type=$(file --mime-type --brief "${release_filename}")
log_debug "Found mime-type: ${mime_type}"

# Check if the file is a zip archive
if [ "${mime_type}" = "application/zip" ]; then
log_debug "Extracting release file."
unzip -q "${release_filename}" 'resources/*'
log_debug "Installation completed."
elif [ "${mime_type}" = "application/vnd.microsoft.portable-executable" ]; then
log_error "The release file appears to be a Windows executable (.exe)."
log_error "Please provide the 'Linux/NodeJS' version of the release or URL."
exit 1
elif [ "${mime_type}" = "application/zlib" ]; then
log_error "The release file appears to be a Mac disk image (.dmg)."
log_error "Please provide the 'Linux/NodeJS' version of the release or URL."
exit 1
else
log_error "The release file does not contain the expected zip data."
log_error "Found: ${mime_type} instead of application/zip"
log_error "Make sure you provided the 'Linux/NodeJS' version of the release or URL."
exit 1
fi
else
log_error "Unable to install Foundry Virtual Tabletop!"
log_error "Either set FOUNDRY_RELEASE_URL."
Expand Down

0 comments on commit 57ddc42

Please sign in to comment.