From 044fa4de08a75aea440320835fb000ff43d5d33f Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 3 Jan 2025 07:33:05 +0100 Subject: [PATCH] Develop: Update Go install script and related Dockerfiles Signed-off-by: Michael Mayer --- Makefile | 2 +- docker/develop/armv7/Dockerfile | 4 +- docker/develop/bookworm/Dockerfile | 4 +- docker/develop/jammy/Dockerfile | 4 +- docker/develop/noble/Dockerfile | 6 +- docker/develop/oracular/Dockerfile | 4 +- scripts/dist/install-admin-tools.sh | 2 +- scripts/dist/install-caddy.sh | 2 +- scripts/dist/install-chrome.sh | 2 +- scripts/dist/install-darktable.sh | 2 +- scripts/dist/install-davfs.sh | 2 +- scripts/dist/install-docker.sh | 2 +- scripts/dist/install-ffmpeg.sh | 2 +- scripts/dist/install-firewall.sh | 2 +- scripts/dist/install-go-tools.sh | 2 +- scripts/dist/install-go.sh | 85 ++++++++++++++++++++--------- scripts/dist/install-gpu.sh | 2 +- scripts/dist/install-jxl.sh | 2 +- scripts/dist/install-libheif.sh | 2 +- scripts/dist/install-mariadb.sh | 2 +- scripts/dist/install-nodejs.sh | 2 +- scripts/dist/install-nuclei.sh | 2 +- scripts/dist/install-tensorflow.sh | 2 +- 23 files changed, 88 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 1ecd3aa78..71a4a9bc3 100644 --- a/Makefile +++ b/Makefile @@ -172,7 +172,7 @@ install: chmod -R $(INSTALL_MODE_BIN) $(DESTDIR)/bin $(DESTDIR)/lib @echo "PhotoPrism $(BUILD_TAG) has been successfully installed in \"$(DESTDIR)\".\nEnjoy!" install-go: - sudo scripts/dist/install-go.sh + sudo scripts/dist/install-go.sh latest go build -v ./... install-tensorflow: sudo scripts/dist/install-tensorflow.sh diff --git a/docker/develop/armv7/Dockerfile b/docker/develop/armv7/Dockerfile index 1fb703144..7ef019f76 100644 --- a/docker/develop/armv7/Dockerfile +++ b/docker/develop/armv7/Dockerfile @@ -63,8 +63,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \ /scripts/install-libheif.sh && \ /scripts/install-tensorflow.sh && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ - mkdir -p /etc/skel/.config/go && \ - echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ + mkdir -p /etc/skel/.config/go/telemetry && \ + echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \ cp -r /etc/skel/.config /root/.config && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ /scripts/install-go-tools.sh && \ diff --git a/docker/develop/bookworm/Dockerfile b/docker/develop/bookworm/Dockerfile index 409f7ceb2..7c11034b8 100644 --- a/docker/develop/bookworm/Dockerfile +++ b/docker/develop/bookworm/Dockerfile @@ -72,8 +72,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \ /scripts/install-tensorflow.sh && \ /scripts/install-darktable.sh && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ - mkdir -p /etc/skel/.config/go && \ - echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ + mkdir -p /etc/skel/.config/go/telemetry && \ + echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \ cp -r /etc/skel/.config /root/.config && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ /scripts/install-go-tools.sh && \ diff --git a/docker/develop/jammy/Dockerfile b/docker/develop/jammy/Dockerfile index 047ea0bfc..8a19fb669 100644 --- a/docker/develop/jammy/Dockerfile +++ b/docker/develop/jammy/Dockerfile @@ -73,8 +73,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \ /scripts/install-libheif.sh && \ /scripts/install-chrome.sh && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ - mkdir -p /etc/skel/.config/go && \ - echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ + mkdir -p /etc/skel/.config/go/telemetry && \ + echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \ cp -r /etc/skel/.config /root/.config && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ /scripts/install-go-tools.sh && \ diff --git a/docker/develop/noble/Dockerfile b/docker/develop/noble/Dockerfile index 9338e8ce5..e05e578dc 100644 --- a/docker/develop/noble/Dockerfile +++ b/docker/develop/noble/Dockerfile @@ -74,10 +74,10 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \ /scripts/install-libheif.sh && \ /scripts/install-chrome.sh && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ - mkdir -p /etc/skel/.config/go && \ - echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ + mkdir -p /etc/skel/.config/go/telemetry && \ + echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \ cp -r /etc/skel/.config /root/.config && \ - GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ + /scripts/install-go.sh && \ /scripts/install-go-tools.sh && \ echo 'alias go=richgo ll="ls -alh"' >> /etc/skel/.bashrc && \ echo 'export PS1="\u@$DOCKER_TAG:\w\$ "' >> /etc/skel/.bashrc && \ diff --git a/docker/develop/oracular/Dockerfile b/docker/develop/oracular/Dockerfile index c01e40d12..b6fd18c14 100644 --- a/docker/develop/oracular/Dockerfile +++ b/docker/develop/oracular/Dockerfile @@ -74,8 +74,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \ /scripts/install-libheif.sh && \ /scripts/install-chrome.sh && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ - mkdir -p /etc/skel/.config/go && \ - echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ + mkdir -p /etc/skel/.config/go/telemetry && \ + echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \ cp -r /etc/skel/.config /root/.config && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ /scripts/install-go-tools.sh && \ diff --git a/scripts/dist/install-admin-tools.sh b/scripts/dist/install-admin-tools.sh index 425ef0166..e28c5de4c 100755 --- a/scripts/dist/install-admin-tools.sh +++ b/scripts/dist/install-admin-tools.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the "duf" and "muffet" admin tools on Linux. +# Installs the "duf" and "muffet" admin tools on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-admin-tools.sh) # Abort if not executed as root.. diff --git a/scripts/dist/install-caddy.sh b/scripts/dist/install-caddy.sh index c4e87afae..5d5c27d69 100755 --- a/scripts/dist/install-caddy.sh +++ b/scripts/dist/install-caddy.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the Caddy web server on Linux. +# Installs the Caddy web server on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-caddy.sh) set -e diff --git a/scripts/dist/install-chrome.sh b/scripts/dist/install-chrome.sh index 5ab9ce53e..d8af85b20 100755 --- a/scripts/dist/install-chrome.sh +++ b/scripts/dist/install-chrome.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs Google Chrome on Linux. +# Installs Google Chrome on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-chrome.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-darktable.sh b/scripts/dist/install-darktable.sh index b764d189c..714219172 100755 --- a/scripts/dist/install-darktable.sh +++ b/scripts/dist/install-darktable.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs Darktable on Linux. +# Installs Darktable on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-darktable.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-davfs.sh b/scripts/dist/install-davfs.sh index 4c9d3e38a..3959e907d 100755 --- a/scripts/dist/install-davfs.sh +++ b/scripts/dist/install-davfs.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the DavFS filesystem driver on Linux. +# Installs the DavFS filesystem driver on Linux. PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-docker.sh b/scripts/dist/install-docker.sh index 1c8fc809e..0296dde01 100755 --- a/scripts/dist/install-docker.sh +++ b/scripts/dist/install-docker.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs Docker on Ubuntu Linux +# Installs Docker on Ubuntu Linux # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-docker.sh) echo "Installing Docker..." diff --git a/scripts/dist/install-ffmpeg.sh b/scripts/dist/install-ffmpeg.sh index a106f80dd..a97d6e45e 100755 --- a/scripts/dist/install-ffmpeg.sh +++ b/scripts/dist/install-ffmpeg.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the static FFmpeg build available at https://johnvansickle.com/ffmpeg/. +# Installs the static FFmpeg build available at https://johnvansickle.com/ffmpeg/. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-ffmpeg.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-firewall.sh b/scripts/dist/install-firewall.sh index 0ee02e2c3..30baab9f8 100755 --- a/scripts/dist/install-firewall.sh +++ b/scripts/dist/install-firewall.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs a simple firewall on Ubuntu Linux that only allows incoming http, https and ssh connections. +# Installs a simple firewall on Ubuntu Linux that only allows incoming http, https and ssh connections. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-firewall.sh) # Install ufw package if needed: diff --git a/scripts/dist/install-go-tools.sh b/scripts/dist/install-go-tools.sh index 0546f46ab..23825fb33 100755 --- a/scripts/dist/install-go-tools.sh +++ b/scripts/dist/install-go-tools.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs Go tools on Linux. +# Installs development tools for Go on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go-tools.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:/usr/local/go/bin:/go/bin:$PATH" diff --git a/scripts/dist/install-go.sh b/scripts/dist/install-go.sh index 75cae74b8..eec586917 100755 --- a/scripts/dist/install-go.sh +++ b/scripts/dist/install-go.sh @@ -1,24 +1,44 @@ #!/usr/bin/env bash -# This installs latest Go on Linux. +# Downloads and installs the Go compiler on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" -DESTDIR=$(realpath "${1:-/usr/local}") +# Show usage information? +if [[ ${1} == "--help" ]]; then + echo "${0##*/} [version] [destdir] downloads and installs the Go compiler on Linux, for example:" 1>&2 + echo "${0##*/}" 1>&2 + echo "${0##*/} latest" 1>&2 + echo "${0##*/} 1.23.4 /usr/local" 1>&2 + exit 0 +fi -# Query version. -if [[ -z $GOLANG_VERSION ]]; then - GOLANG_VERSION="go1.22.10" -elif [[ $GOLANG_VERSION == "latest" ]]; then +set -e +set +x + +# Check version to be installed: +GOLANG_VERSION=${1:-$GOLANG_VERSION} + +if [[ -z $GOLANG_VERSION ]] || [[ $GOLANG_VERSION == "latest" ]]; then GOLANG_VERSION=$(curl -fsSL https://go.dev/VERSION?m=text | head -n 1) fi -echo "Installing ${GOLANG_VERSION} in \"${DESTDIR}\"..." +GOLANG_VERSION=${GOLANG_VERSION#"go"} -set -e +if [[ -z $GOLANG_VERSION ]]; then + echo "Go compiler version must be passed as first argument, e.g. 1.23.4" 1>&2 + exit 1 +fi -# Determine the system architecture. +# Check destination directory: +DESTDIR=$(realpath "${2:-/usr/local}") + +if [[ -z $DESTDIR ]] || [[ $DESTDIR == "default" ]]; then + DESTDIR="/usr/local" +fi + +# Determine the system architecture: if [[ $PHOTOPRISM_ARCH ]]; then SYSTEM_ARCH=$PHOTOPRISM_ARCH else @@ -27,21 +47,22 @@ fi DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} -sudo mkdir -p "$DESTDIR" +# Start installation: +echo "Installing Go ${GOLANG_VERSION} for ${DESTARCH^^} in \"${DESTDIR}\". Please wait." -set -eux; +sudo mkdir -p "$DESTDIR" case $DESTARCH in amd64 | AMD64 | x86_64 | x86-64) - URL="https://go.dev/dl/${GOLANG_VERSION}.linux-amd64.tar.gz" + URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" ;; arm64 | ARM64 | aarch64) - URL="https://go.dev/dl/${GOLANG_VERSION}.linux-arm64.tar.gz" + URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz" ;; arm | ARM | aarch | armv7l | armhf) - URL="https://go.dev/dl/${GOLANG_VERSION}.linux-armv6l.tar.gz" + URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz" ;; *) @@ -50,18 +71,32 @@ case $DESTARCH in ;; esac -# Replace current installation in "/usr/local/go". -echo "Installing Go for ${DESTARCH^^} from \"$URL\". Please wait." -sudo rm -rf /usr/local/go -wget --inet4-only -c "$URL" -O - | sudo tar -xz -C /usr/local +# Replace current installation in "$DESTDIR/go": +echo "Extracting \"${URL}\" to \"${DESTDIR}/go\"..." +set -eux; +sudo rm -rf "${DESTDIR}/go" +wget --inet4-only -c "${URL}" -O - | sudo tar -xz -C "${DESTDIR}" +set +x +echo "Done." -# Add symlink to go binary. -echo "Adding symbolic links for go and gofmt." -sudo ln -sf /usr/local/go/bin/go /usr/local/bin/go -sudo ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt +# Add symlink to go binary: +echo "Adding symbolic links for \"${DESTDIR}/go/bin/go\" and \"${DESTDIR}/go/bin/gofmt\"..." +set -eux; +sudo ln -sf "${DESTDIR}/go/bin/go" /usr/local/bin/go +sudo ln -sf "${DESTDIR}/go/bin/gofmt" /usr/local/bin/gofmt +set +x +echo "Done." -# Test go command by showing installed Go version. Telemetry in Go >= 1.23 should be set to "off" in -# ~/.config/go/telemetry, see https://go.dev/doc/telemetry. You can otherwise run "go telemetry off". +# Telemetry in Go >= 1.23 should be set to "off" in ~/.config/go/telemetry, see https://go.dev/doc/telemetry. +# You can do this by running "go telemetry off": +echo "Disabling Go telemetry..." +set +e -x; +mkdir -p ~/.config/go +go telemetry off +set +x + +# Test go command by showing installed Go version: +echo "Installed Go version:" go version -echo "Done." \ No newline at end of file +echo "Enjoy!" \ No newline at end of file diff --git a/scripts/dist/install-gpu.sh b/scripts/dist/install-gpu.sh index f0f077a56..2f7d892fe 100755 --- a/scripts/dist/install-gpu.sh +++ b/scripts/dist/install-gpu.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs GPU drivers on Linux. +# Installs GPU drivers on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-gpu.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-jxl.sh b/scripts/dist/install-jxl.sh index 63a7cca85..8eee53b28 100755 --- a/scripts/dist/install-jxl.sh +++ b/scripts/dist/install-jxl.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs JPEG XL on Linux. +# Installs JPEG XL on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-jxl.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-libheif.sh b/scripts/dist/install-libheif.sh index 5445d3b01..6fe2e84fc 100755 --- a/scripts/dist/install-libheif.sh +++ b/scripts/dist/install-libheif.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the heif-convert, heif-enc, heif-info, and heif-thumbnailer binaries on Linux. +# Installs the heif-convert, heif-enc, heif-info, and heif-thumbnailer binaries on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-libheif.sh) set -e diff --git a/scripts/dist/install-mariadb.sh b/scripts/dist/install-mariadb.sh index 31447fac7..69510027d 100755 --- a/scripts/dist/install-mariadb.sh +++ b/scripts/dist/install-mariadb.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs MariaDB on Linux. +# Installs MariaDB on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-mariadb.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-nodejs.sh b/scripts/dist/install-nodejs.sh index 9390d97a4..202aff25a 100755 --- a/scripts/dist/install-nodejs.sh +++ b/scripts/dist/install-nodejs.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs NodeJS, NPM and TestCafe on Linux. +# Installs NodeJS, NPM and TestCafe on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nodejs.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" diff --git a/scripts/dist/install-nuclei.sh b/scripts/dist/install-nuclei.sh index dfb0d82de..69e9c3c80 100755 --- a/scripts/dist/install-nuclei.sh +++ b/scripts/dist/install-nuclei.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the Nuclei Vulnerability Scanner on Linux. +# Installs the Nuclei Vulnerability Scanner on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nuclei.sh) # Abort if not executed as root.. diff --git a/scripts/dist/install-tensorflow.sh b/scripts/dist/install-tensorflow.sh index c8b6aab12..04edb19ce 100755 --- a/scripts/dist/install-tensorflow.sh +++ b/scripts/dist/install-tensorflow.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# This installs the TensorFlow libraries on Linux. +# Installs the TensorFlow libraries on Linux. # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-tensorflow.sh) PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"