diff --git a/Dockerfile b/Dockerfile index f155f7e65..40198a5f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN npm install -g npm # copy scripts to test changes COPY --chown=root:root /docker/develop/entrypoint.sh /entrypoint.sh -COPY --chown=root:root /docker/scripts/Makefile /root/Makefile +COPY --chown=root:root /scripts/init/Makefile /root/Makefile # set up project directory WORKDIR "/go/src/github.com/photoprism/photoprism" diff --git a/assets/.buildignore b/assets/.buildignore new file mode 100644 index 000000000..7de951127 --- /dev/null +++ b/assets/.buildignore @@ -0,0 +1,3 @@ +examples +README.md +.* \ No newline at end of file diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/cmd/photoprism/photoprism.go b/cmd/photoprism/photoprism.go index 5633c620e..487b44434 100644 --- a/cmd/photoprism/photoprism.go +++ b/cmd/photoprism/photoprism.go @@ -42,8 +42,8 @@ import ( var version = "development" var log = event.Log -const appDescription = "The documentation can be found at https://docs.photoprism.app/. This is free software. " + - "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." +const appDescription = "For installation instructions, visit https://docs.photoprism.app/" +const appCopyright = "(c) 2018-2022 Michael Mayer " func main() { app := cli.NewApp() @@ -52,7 +52,7 @@ func main() { app.Usage = "Browse Your Life in Pictures" app.Description = appDescription app.Version = version - app.Copyright = "(c) 2018-2022 Michael Mayer " + app.Copyright = appCopyright app.EnableBashCompletion = true app.Flags = config.GlobalFlags diff --git a/docker/develop/armv7/Dockerfile b/docker/develop/armv7/Dockerfile index ac1fde961..39eff60f9 100644 --- a/docker/develop/armv7/Dockerfile +++ b/docker/develop/armv7/Dockerfile @@ -19,15 +19,15 @@ ENV DEBIAN_FRONTEND="noninteractive" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # update image and install build dependencies RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-install-recommends \ @@ -75,7 +75,7 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta sudo && \ /root/.local/bin/install-nodejs.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* && \ - /root/.local/bin/install-tensorflow.sh ${TARGETARCH} && \ + /root/.local/bin/install-tensorflow.sh && \ mkdir -p "/go/src" "/go/bin" && \ chmod -R 777 "/go" diff --git a/docker/develop/bullseye/Dockerfile b/docker/develop/bullseye/Dockerfile index a9237fd09..e594841a4 100644 --- a/docker/develop/bullseye/Dockerfile +++ b/docker/develop/bullseye/Dockerfile @@ -21,15 +21,15 @@ ENV DEBIAN_FRONTEND="noninteractive" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # copy backport packages source list COPY --chown=root:root --chmod=644 /docker/develop/bullseye/backports.list /etc/apt/sources.list.d/backports.list @@ -87,8 +87,8 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta apache2-utils && \ /root/.local/bin/install-nodejs.sh && \ /root/.local/bin/install-mariadb-client.sh && \ - /root/.local/bin/install-darktable.sh ${TARGETARCH} && \ - /root/.local/bin/install-tensorflow.sh ${TARGETARCH} && \ + /root/.local/bin/install-tensorflow.sh && \ + /root/.local/bin/install-darktable.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* && \ mkdir -p "/go/src" "/go/bin" && \ chmod -R 777 "/go" diff --git a/docker/develop/buster/Dockerfile b/docker/develop/buster/Dockerfile index 074a42cdd..9bff3e645 100644 --- a/docker/develop/buster/Dockerfile +++ b/docker/develop/buster/Dockerfile @@ -21,15 +21,15 @@ ENV DEBIAN_FRONTEND="noninteractive" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # copy backport packages source list COPY --chown=root:root --chmod=644 /docker/develop/buster/backports.list /etc/apt/sources.list.d/backports.list @@ -86,8 +86,8 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta lsof \ apache2-utils && \ /root/.local/bin/install-nodejs.sh && \ - /root/.local/bin/install-darktable.sh ${TARGETARCH} && \ - /root/.local/bin/install-tensorflow.sh ${TARGETARCH} && \ + /root/.local/bin/install-tensorflow.sh && \ + /root/.local/bin/install-darktable.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* && \ mkdir -p "/go/src" "/go/bin" && \ chmod -R 777 "/go" diff --git a/docker/develop/impish/Dockerfile b/docker/develop/impish/Dockerfile index 608eacca2..0bf1a9a08 100644 --- a/docker/develop/impish/Dockerfile +++ b/docker/develop/impish/Dockerfile @@ -21,15 +21,15 @@ ENV DEBIAN_FRONTEND="noninteractive" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts to /root/.local/bin -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts to /root/.local/bin +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # update image and install build dependencies RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-install-recommends \ @@ -84,10 +84,10 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta fonts-roboto \ sudo && \ /root/.local/bin/install-nodejs.sh && \ - /root/.local/bin/install-darktable.sh ${TARGETARCH} && \ - /root/.local/bin/install-tensorflow.sh ${TARGETARCH} && \ - /root/.local/bin/install-devtools.sh ${TARGETARCH} && \ - /root/.local/bin/install-go.sh ${TARGETARCH} && \ + /root/.local/bin/install-tensorflow.sh && \ + /root/.local/bin/install-darktable.sh && \ + /root/.local/bin/install-devtools.sh && \ + /root/.local/bin/install-go.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* && \ mkdir -p "/go/src" "/go/bin" && \ chmod -R 777 "/go" diff --git a/docker/photoprism/armv7/Dockerfile b/docker/photoprism/armv7/Dockerfile index 9b205b378..6402757d5 100644 --- a/docker/photoprism/armv7/Dockerfile +++ b/docker/photoprism/armv7/Dockerfile @@ -27,15 +27,15 @@ ARG TARGETPLATFORM ENV DEBIAN_FRONTEND="noninteractive" \ TMPDIR="/tmp" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # install additional distribution packages RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-install-recommends \ diff --git a/docker/photoprism/bullseye/Dockerfile b/docker/photoprism/bullseye/Dockerfile index e9e7385e1..70ce9c908 100644 --- a/docker/photoprism/bullseye/Dockerfile +++ b/docker/photoprism/bullseye/Dockerfile @@ -27,15 +27,15 @@ ARG TARGETPLATFORM ENV DEBIAN_FRONTEND="noninteractive" \ TMPDIR="/tmp" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # copy debian backports source COPY --chown=root:root --chmod=644 /docker/develop/bullseye/backports.list /etc/apt/sources.list.d/backports.list @@ -59,7 +59,7 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta ffmpegthumbnailer \ libavcodec-extra && \ /root/.local/bin/install-mariadb-client.sh && \ - /root/.local/bin/install-darktable.sh ${TARGETARCH} && \ + /root/.local/bin/install-darktable.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* # set environment variables, see https://docs.photoprism.app/getting-started/config-options/ diff --git a/docker/photoprism/buster/Dockerfile b/docker/photoprism/buster/Dockerfile index 6784491b2..47f27f3f7 100644 --- a/docker/photoprism/buster/Dockerfile +++ b/docker/photoprism/buster/Dockerfile @@ -27,15 +27,15 @@ ARG TARGETPLATFORM ENV DEBIAN_FRONTEND="noninteractive" \ TMPDIR="/tmp" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # copy backports sources COPY --chown=root:root --chmod=644 /docker/develop/buster/backports.list /etc/apt/sources.list.d/backports.list @@ -60,7 +60,7 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta ffmpeg \ ffmpegthumbnailer \ libavcodec-extra && \ - /root/.local/bin/install-darktable.sh ${TARGETARCH} && \ + /root/.local/bin/install-darktable.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* # set environment variables, see https://docs.photoprism.app/getting-started/config-options/ diff --git a/docker/photoprism/impish/Dockerfile b/docker/photoprism/impish/Dockerfile index 49501beb2..4f5768487 100644 --- a/docker/photoprism/impish/Dockerfile +++ b/docker/photoprism/impish/Dockerfile @@ -27,15 +27,15 @@ ARG TARGETPLATFORM ENV DEBIAN_FRONTEND="noninteractive" \ TMPDIR="/tmp" -# configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing -# copy scripts -COPY --chown=root:root --chmod=755 /docker/scripts/* /root/.local/bin/ +# copy init scripts +COPY --chown=root:root --chmod=755 /scripts/init/* /root/.local/bin/ # install additional distribution packages RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-install-recommends \ @@ -56,7 +56,7 @@ RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-insta ffmpeg \ ffmpegthumbnailer \ libavcodec-extra && \ - /root/.local/bin/install-darktable.sh ${TARGETARCH} && \ + /root/.local/bin/install-darktable.sh && \ apt-get -y autoremove && apt-get -y autoclean && apt-get -y clean && rm -rf /var/lib/apt/lists/* # set environment variables, see https://docs.photoprism.app/getting-started/config-options/ diff --git a/docker/scripts/install-devtools.sh b/docker/scripts/install-devtools.sh deleted file mode 100755 index 349449a86..000000000 --- a/docker/scripts/install-devtools.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -# abort if the user is not root -if [[ $(id -u) != "0" ]]; then - echo "Usage: run install-devtools.sh as root" 1>&2 - exit 1 -fi - -set -e - -if [[ -z $1 ]]; then - echo "Usage: install-devtools.sh [amd64|arm64|arm]" 1>&2 - exit 1 -else - set -eux; - umask 0000 - - # Install Chrome or Chromium - if [[ $1 == "amd64" ]]; then - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - - sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' - apt-get update - apt-get -qq install google-chrome-stable - elif [[ $1 == "arm64" ]]; then -cat < /etc/apt/preferences.d/chromium -Package: * -Pin: release o=LP-PPA-saiarcot895-chromium-dev -Pin-Priority: 1002 -EOF - add-apt-repository -y ppa:saiarcot895/chromium-dev - apt-get update - apt-get -qq install chromium-browser chromium-codecs-ffmpeg-extra - fi - - # Remove package files - apt-get -y autoremove - apt-get -y autoclean - apt-get -y clean - rm -rf /var/lib/apt/lists/* - - # Install Puppeteer, TestCafe & ChromeDriver - if [[ $1 == "amd64" ]]; then - npm install --unsafe-perm=true --allow-root -g puppeteer testcafe testcafe-browser-provider-puppeteer chromedriver - elif [[ $1 == "arm64" ]]; then - npm install --unsafe-perm=true --allow-root -g testcafe chromedriver - fi -fi - diff --git a/docker/scripts/install-go.sh b/docker/scripts/install-go.sh deleted file mode 100755 index e7f360d46..000000000 --- a/docker/scripts/install-go.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -# abort if the user is not root -if [[ $(id -u) != "0" ]]; then - echo "Usage: run install-go.sh as root" 1>&2 - exit 1 -fi - -set -e - -GOLANG_VERSION=1.17.7 - -if [[ -z $1 ]]; then - echo "Usage: install-go.sh [amd64|arm64|arm]" 1>&2 - exit 1 -else - set -eux; - if [[ $1 == "amd64" ]]; then - URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" - CHECKSUM="02b111284bedbfa35a7e5b74a06082d18632eff824fd144312f6063943d49259 *go.tgz" - elif [[ $1 == "arm64" ]]; then - URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz" - CHECKSUM="a5aa1ed17d45ee1d58b4a4099b12f8942acbd1dd09b2e9a6abb1c4898043c5f5 *go.tgz" - elif [[ $1 == "arm" ]]; then - URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz" - CHECKSUM="874774f078b182fa21ffcb3878467eb5cb7e78bbffa6343ea5f0fbe47983433b *go.tgz" - else - echo "install-go: unsupported architecture" 1>&2 - exit 1 - fi - wget -O go.tgz $URL - echo $CHECKSUM | sha256sum -c - - rm -rf /usr/local/go - tar -C /usr/local -xzf go.tgz - rm go.tgz - /usr/local/go/bin/go version -fi diff --git a/docker/scripts/install-tensorflow.sh b/docker/scripts/install-tensorflow.sh deleted file mode 100755 index e15d826e1..000000000 --- a/docker/scripts/install-tensorflow.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash - -# abort if the user is not root -if [[ $(id -u) != "0" ]]; then - echo "Usage: run install-tensorflow.sh as root" 1>&2 - exit 1 -fi - -if [[ -z $1 ]] && [[ -z $2 ]]; then - echo "Usage: install-tensorflow.sh [amd64|arm64|arm] [cpu|avx|avx2]" 1>&2 - exit 1 -else - echo "install-tensorflow: downloading library..." - if [[ $1 == "amd64" ]]; then - TARGETARCH="linux" - TARGETVARIANT="-${2:-"cpu"}" - URL="https://dl.photoprism.app/tensorflow/$TARGETARCH/libtensorflow-${TARGETARCH}${TARGETVARIANT}-1.15.2.tar.gz" - elif [[ $1 == "arm64" ]]; then - URL="https://dl.photoprism.app/tensorflow/$1/libtensorflow-$1-1.15.2.tar.gz" - elif [[ $1 == "arm" ]]; then - URL="https://dl.photoprism.app/tensorflow/$1/libtensorflow-$1-1.15.2.tar.gz" - else - echo "install-tensorflow: unsupported architecture" 1>&2 - exit 1 - fi - echo "$URL" - curl -fsSL "$URL" | \ - tar --overwrite -C "/usr" -xz && \ - ldconfig - echo "install-tensorflow: done" -fi diff --git a/docker/tensorflow/Dockerfile b/docker/tensorflow/Dockerfile index 1d23a546a..b9f0234b7 100644 --- a/docker/tensorflow/Dockerfile +++ b/docker/tensorflow/Dockerfile @@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND noninteractive ENV TMP /tmp ENV EXTRA_BAZEL_ARGS "--host_javabase=@local_jdk//:jdk" -# Configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ diff --git a/docker/tensorflow/arm64/Dockerfile b/docker/tensorflow/arm64/Dockerfile index 2fd6501ce..3d395cf01 100644 --- a/docker/tensorflow/arm64/Dockerfile +++ b/docker/tensorflow/arm64/Dockerfile @@ -6,7 +6,7 @@ ENV DEBIAN_FRONTEND noninteractive ENV TMP /tmp ENV EXTRA_BAZEL_ARGS "--host_javabase=@local_jdk//:jdk" -# Configure apt +# apt default settings RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends && \ echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests && \ diff --git a/scripts/init/.buildignore b/scripts/init/.buildignore new file mode 100644 index 000000000..c1925418e --- /dev/null +++ b/scripts/init/.buildignore @@ -0,0 +1,2 @@ +.* +install-devtools.sh \ No newline at end of file diff --git a/docker/scripts/Makefile b/scripts/init/Makefile similarity index 100% rename from docker/scripts/Makefile rename to scripts/init/Makefile diff --git a/scripts/init/arch.sh b/scripts/init/arch.sh new file mode 100755 index 000000000..cab625601 --- /dev/null +++ b/scripts/init/arch.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# This script returns the normalized machine architecture (amd64, arm64, or arm). +# An error is returned if the architecture is currently not supported by PhotoPrism. + +if [[ $TARGETARCH ]]; then + SYSTEM_ARCH=$TARGETARCH +elif [[ $OS == "Windows_NT" ]]; then + if [[ $PROCESSOR_ARCHITEW6432 == "AMD64" || $PROCESSOR_ARCHITECTURE == "AMD64" ]]; then + SYSTEM_ARCH=amd64 + else + echo "Unsupported Windows Architecture" 1>&2 + exit 1 + fi +else + SYSTEM_ARCH=$(arch) +fi + +BUILD_ARCH=${BUILD_ARCH:-$SYSTEM_ARCH} + +case $BUILD_ARCH in + amd64 | AMD64 | x86_64) + BUILD_ARCH=amd64 + ;; + + arm64 | ARM64 | aarch64) + BUILD_ARCH=arm64 + ;; + + arm | ARM | aarch | armv7l | armhf | arm6l) + BUILD_ARCH=arm + ;; + + *) + echo "Unsupported Machine Architecture: \"$BUILD_ARCH\"" 1>&2 + exit 1 + ;; +esac + +export BUILD_ARCH=$BUILD_ARCH + +echo $BUILD_ARCH \ No newline at end of file diff --git a/docker/scripts/cleanup.sh b/scripts/init/cleanup.sh similarity index 100% rename from docker/scripts/cleanup.sh rename to scripts/init/cleanup.sh diff --git a/docker/scripts/dist-upgrade.sh b/scripts/init/dist-upgrade.sh similarity index 92% rename from docker/scripts/dist-upgrade.sh rename to scripts/init/dist-upgrade.sh index fcbe56fe9..d18d43cdb 100755 --- a/docker/scripts/dist-upgrade.sh +++ b/scripts/init/dist-upgrade.sh @@ -16,3 +16,5 @@ export TMPDIR="/tmp" apt-get -y update apt-get -y dist-upgrade apt-get -y autoremove + +echo "Packages updated." \ No newline at end of file diff --git a/docker/scripts/heif-convert.sh b/scripts/init/heif-convert.sh similarity index 100% rename from docker/scripts/heif-convert.sh rename to scripts/init/heif-convert.sh diff --git a/docker/scripts/install-darktable.sh b/scripts/init/install-darktable.sh similarity index 83% rename from docker/scripts/install-darktable.sh rename to scripts/init/install-darktable.sh index bed385b1f..a0661a56e 100755 --- a/docker/scripts/install-darktable.sh +++ b/scripts/init/install-darktable.sh @@ -8,12 +8,14 @@ fi set -e +SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +INSTALL_ARCH=${2:-$SYSTEM_ARCH} + . /etc/os-release -if [[ -z $1 ]]; then - echo "Usage: install-darktable.sh [amd64|arm64|arm]" 1>&2 - exit 1 -elif [[ $1 == "amd64" ]]; then +echo "Installing Darktable for ${INSTALL_ARCH^^}..." + +if [[ $INSTALL_ARCH == "amd64" ]]; then if [[ $VERSION_CODENAME == "bullseye" ]]; then echo 'deb http://download.opensuse.org/repositories/graphics:/darktable/Debian_11/ /' | tee /etc/apt/sources.list.d/graphics:darktable.list curl -fsSL https://download.opensuse.org/repositories/graphics:darktable/Debian_11/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/graphics_darktable.gpg > /dev/null @@ -28,8 +30,8 @@ elif [[ $1 == "amd64" ]]; then echo "install-darktable: installing standard amd64 (Intel 64-bit) package" apt-get -qq install darktable fi - echo "install-darktable: done" -elif [[ $1 == "arm64" ]]; then + echo "Installed." +elif [[ $INSTALL_ARCH == "arm64" ]]; then if [[ $VERSION_CODENAME == "bullseye" ]]; then apt-get update apt-get -qq install -t bullseye-backports darktable @@ -40,7 +42,7 @@ elif [[ $1 == "arm64" ]]; then echo "install-darktable: installing standard amd64 (ARM 64-bit) package" apt-get -qq install darktable fi - echo "install-darktable: done" + echo "Installed." else - echo "install-darktable: unsupported architecture $1" + echo "Unsupported Machine Architecture: $INSTALL_ARCH" fi diff --git a/scripts/init/install-devtools.sh b/scripts/init/install-devtools.sh new file mode 100755 index 000000000..ea994b52d --- /dev/null +++ b/scripts/init/install-devtools.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +# abort if the user is not root +if [[ $(id -u) != "0" ]]; then + echo "Usage: run install-devtools.sh as root" 1>&2 + exit 1 +fi + +. /etc/os-release + +if [[ $ID != "ubuntu" ]]; then + echo "Dev-Tools only need to be installed on Ubuntu Linux." + exit +fi + +set -e + +SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +INSTALL_ARCH=${2:-$SYSTEM_ARCH} + +echo "Installing Dev-Tools for ${INSTALL_ARCH^^}..." + +set -eux; +umask 0000 + +# Install Chrome or Chromium +if [[ $INSTALL_ARCH == "amd64" ]]; then + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - + sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' + apt-get update + apt-get -qq install google-chrome-stable +elif [[ $INSTALL_ARCH == "arm64" ]]; then +cat < /etc/apt/preferences.d/chromium +Package: * +Pin: release o=LP-PPA-saiarcot895-chromium-dev +Pin-Priority: 1002 +EOF + add-apt-repository -y ppa:saiarcot895/chromium-dev + apt-get update + apt-get -qq install chromium-browser chromium-codecs-ffmpeg-extra +fi + +# Remove package files +apt-get -y autoremove +apt-get -y autoclean +apt-get -y clean +rm -rf /var/lib/apt/lists/* + +# Install Puppeteer, TestCafe & ChromeDriver +if [[ $INSTALL_ARCH == "amd64" ]]; then + npm install --unsafe-perm=true --allow-root -g puppeteer testcafe testcafe-browser-provider-puppeteer chromedriver +elif [[ $INSTALL_ARCH == "arm64" ]]; then + npm install --unsafe-perm=true --allow-root -g testcafe chromedriver +fi + +echo "Installed." \ No newline at end of file diff --git a/scripts/init/install-go.sh b/scripts/init/install-go.sh new file mode 100755 index 000000000..5b08834b1 --- /dev/null +++ b/scripts/init/install-go.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +GOLANG_VERSION=1.17.7 + +DESTDIR=$(realpath "${1:-/usr/local}") + +echo "Installing Go in \"$DESTDIR\"..." + +# abort if the user is not root +if [[ $(id -u) != "0" ]]; then + echo "Usage: run install-go.sh as root" 1>&2 + exit 1 +fi + +set -e + +mkdir -p "$DESTDIR" + +SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +INSTALL_ARCH=${2:-$SYSTEM_ARCH} + +set -eux; + +if [[ $INSTALL_ARCH == "amd64" ]]; then + URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" + CHECKSUM="02b111284bedbfa35a7e5b74a06082d18632eff824fd144312f6063943d49259 *go.tgz" +elif [[ $INSTALL_ARCH == "arm64" ]]; then + URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz" + CHECKSUM="a5aa1ed17d45ee1d58b4a4099b12f8942acbd1dd09b2e9a6abb1c4898043c5f5 *go.tgz" +elif [[ $INSTALL_ARCH == "arm" ]]; then + URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz" + CHECKSUM="874774f078b182fa21ffcb3878467eb5cb7e78bbffa6343ea5f0fbe47983433b *go.tgz" +else + echo "Unsupported Machine Architecture: $INSTALL_ARCH" 1>&2 + exit 1 +fi + +echo "Downloading Go from \"$URL\". Please wait." + +wget -O go.tgz $URL +echo $CHECKSUM | sha256sum -c - +rm -rf /usr/local/go +tar -C /usr/local -xzf go.tgz +rm go.tgz + +/usr/local/go/bin/go version + +echo "Installed." \ No newline at end of file diff --git a/docker/scripts/install-mariadb-client.sh b/scripts/init/install-mariadb-client.sh similarity index 84% rename from docker/scripts/install-mariadb-client.sh rename to scripts/init/install-mariadb-client.sh index bf4245e16..ada9c8b2f 100755 --- a/docker/scripts/install-mariadb-client.sh +++ b/scripts/init/install-mariadb-client.sh @@ -8,4 +8,5 @@ fi curl -Ls https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version="mariadb-10.6" apt-get update -apt-get -qq install mariadb-client \ No newline at end of file +apt-get -qq install mariadb-client +echo "Installed." \ No newline at end of file diff --git a/docker/scripts/install-nodejs.sh b/scripts/init/install-nodejs.sh similarity index 95% rename from docker/scripts/install-nodejs.sh rename to scripts/init/install-nodejs.sh index 90d768074..e47c47884 100755 --- a/docker/scripts/install-nodejs.sh +++ b/scripts/init/install-nodejs.sh @@ -11,3 +11,4 @@ curl -sL https://deb.nodesource.com/setup_16.x | bash - apt-get update && apt-get -qq install nodejs npm install --unsafe-perm=true --allow-root -g npm npm config set cache ~/.cache/npm +echo "Installed." \ No newline at end of file diff --git a/scripts/init/install-tensorflow.sh b/scripts/init/install-tensorflow.sh new file mode 100755 index 000000000..889002e65 --- /dev/null +++ b/scripts/init/install-tensorflow.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -e + +TF_VERSION="1.15.2" + +DESTDIR=$(realpath "${1:-/usr}") + +echo "Installing TensorFlow in \"$DESTDIR\"..." + +# abort if the user is not root +if [[ $(id -u) != "0" ]] && [[ $DESTDIR == "/usr" || $DESTDIR == "/usr/local" ]]; then + echo "Error: Run install-tensorflow.sh as root to install in a system directory!" 1>&2 + exit 1 +fi + +mkdir -p "$DESTDIR" + +SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +INSTALL_ARCH=${2:-$SYSTEM_ARCH} + +if [[ -z $3 ]]; then + URL="https://dl.photoprism.app/tensorflow/${INSTALL_ARCH}/libtensorflow-${INSTALL_ARCH}-${TF_VERSION}.tar.gz" +else + URL="https://dl.photoprism.app/tensorflow/${INSTALL_ARCH}/libtensorflow-${INSTALL_ARCH}-${2}-${TF_VERSION}.tar.gz" +fi + +echo "Downloading $INSTALL_ARCH libs from \"$URL\". Please wait." + +curl -fsSL "$URL" | tar --overwrite --mode=755 -C "$DESTDIR" -xz + +if [[ $DESTDIR == "/usr" || $DESTDIR == "/usr/local" ]]; then + echo "Running ldconfig..." + ldconfig +else + echo "Running \"ldconfig -n $DESTDIR/lib\"." + ldconfig -n "$DESTDIR/lib" +fi + +echo "Installed."