From 41b92be7c9725e1c8c4a751753b9d97f738a5395 Mon Sep 17 00:00:00 2001 From: Laurent Constantin Date: Tue, 26 Nov 2024 14:07:43 +0100 Subject: [PATCH] Kepubify support multiple arch --- Dockerfile | 12 +++-------- docker/get_kepubify_url.sh | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 docker/get_kepubify_url.sh diff --git a/Dockerfile b/Dockerfile index 8e1b8d1..f39d30f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,15 +47,9 @@ RUN install-php-extensions \ @composer # Install kepubify (from https://github.com/linuxserver/docker-calibre-web/blob/master/Dockerfile) -RUN \ - if [ -z ${KEPUBIFY_RELEASE+x} ]; then \ - KEPUBIFY_RELEASE=$(curl -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" \ - | awk '/tag_name/{print $4;exit}' FS='[""]'); \ - fi && \ - curl -o \ - /usr/bin/kepubify -L \ - https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/kepubify-linux-64bit && \ - chmod +x /usr/bin/kepubify +COPY docker/get_kepubify_url.sh /usr/bin/get_kepubify_url.sh +RUN chmod +x /usr/bin/get_kepubify_url.sh ; \ + URL=$(/usr/bin/get_kepubify_url.sh) && curl -f -vvv -o /usr/bin/kepubify -L "$URL" && chmod +x /usr/bin/kepubify RUN a2enmod rewrite diff --git a/docker/get_kepubify_url.sh b/docker/get_kepubify_url.sh new file mode 100644 index 0000000..74ab038 --- /dev/null +++ b/docker/get_kepubify_url.sh @@ -0,0 +1,43 @@ +#!/bin/sh +set -e + +KEPUBIFY_RELEASE="${1}" + +# Get OS and architecture +OS=$(uname -s) +ARCH=$(uname -m) +case "$OS" in + Linux) + case "$ARCH" in + x86_64) BINARY="kepubify-linux-64bit" ;; + i686 | i386) BINARY="kepubify-linux-32bit" ;; + armv7l | armv6l) BINARY="kepubify-linux-arm" ;; + aarch64) BINARY="kepubify-linux-arm64" ;; + *) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; + esac + ;; + Darwin) + case "$ARCH" in + x86_64) BINARY="kepubify-darwin-64bit" ;; + arm64) BINARY="kepubify-darwin-arm64" ;; + *) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; + esac + ;; + Windows_NT) + case "$ARCH" in + x86_64) BINARY="kepubify-windows-64bit.exe" ;; + i686 | i386) BINARY="kepubify-windows-32bit.exe" ;; + arm64) BINARY="kepubify-windows-arm64.exe" ;; + *) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; + esac + ;; + *) + echo "Unsupported OS: $OS" >&2 + exit 1 + ;; +esac +if [ "${KEPUBIFY_RELEASE}x" = "x" ]; then + KEPUBIFY_RELEASE=$(curl -f -sX GET "https://api.github.com/repos/pgaskin/kepubify/releases/latest" | awk '/tag_name/{print $4;exit}' FS='[""]'); +fi + +echo "https://github.com/pgaskin/kepubify/releases/download/${KEPUBIFY_RELEASE}/${BINARY}"