From 5dce02ebbdf05ccae9a8eb2b59497c180fd5ece1 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 16 Mar 2022 19:09:53 +0100 Subject: [PATCH] Docker: Use absolute command names to avoid path problems #2146 #2149 --- Dockerfile | 2 +- Makefile | 1 + docker/develop/armv7/Dockerfile | 2 +- docker/develop/bullseye-slim/Dockerfile | 2 +- docker/develop/bullseye/Dockerfile | 2 +- docker/develop/buster/Dockerfile | 2 +- docker/develop/impish/Dockerfile | 2 +- docker/examples/arm64/docker-compose.yml | 1 + docker/examples/armv7/docker-compose.yml | 1 + docker/examples/cloud/docker-compose.yml | 1 + docker/examples/docker-compose.yml | 1 + docker/examples/macos/docker-compose.yml | 1 + docker/examples/scheduler/docker-compose.yml | 1 + docker/examples/sqlite/docker-compose.yml | 1 + docker/examples/windows/docker-compose.yml | 1 + docker/photoprism/armv7/Dockerfile | 2 +- docker/photoprism/bullseye/Dockerfile | 2 +- docker/photoprism/buster/Dockerfile | 2 +- docker/photoprism/impish/Dockerfile | 2 +- scripts/build.sh | 8 +++--- scripts/dist/Makefile | 14 ++++----- scripts/dist/arch.sh | 2 +- scripts/dist/audit.sh | 4 +-- scripts/dist/cleanup.sh | 24 ++++++++-------- scripts/dist/dist-upgrade.sh | 8 +++--- scripts/dist/entrypoint-init.sh | 26 +++++++++-------- scripts/dist/entrypoint.sh | 26 +++++++++-------- scripts/dist/heif-convert.sh | 2 +- scripts/dist/install-chrome.sh | 10 +++---- scripts/dist/install-darktable.sh | 30 ++++++++++---------- scripts/dist/install-davfs.sh | 4 +-- scripts/dist/install-go.sh | 16 +++++------ scripts/dist/install-gpu.sh | 14 ++++----- scripts/dist/install-mariadb.sh | 6 ++-- scripts/dist/install-nodejs.sh | 4 +-- scripts/dist/install-tensorflow.sh | 16 +++++------ scripts/dist/tensorflow-driver.sh | 6 ++-- scripts/docker/build.sh | 2 +- scripts/docker/buildx-multi.sh | 2 +- scripts/docker/buildx.sh | 2 +- scripts/download-facenet.sh | 20 ++++++------- scripts/download-nasnet.sh | 20 ++++++------- scripts/download-nsfw.sh | 18 ++++++------ 43 files changed, 163 insertions(+), 150 deletions(-) diff --git a/Dockerfile b/Dockerfile index 179f99bfe..f0357d4df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM photoprism/develop:220311-bullseye +FROM photoprism/develop:220316-bullseye ## alternative base images # FROM photoprism/develop:buster # Debian 10, Codename "Buster" diff --git a/Makefile b/Makefile index 3661f08ae..9deb2ff3e 100644 --- a/Makefile +++ b/Makefile @@ -121,6 +121,7 @@ stop: go run cmd/photoprism/photoprism.go stop terminal: docker-compose exec -u $(UID) photoprism bash +rootshell: root-terminal root-terminal: docker-compose exec -u root photoprism bash migrate: diff --git a/docker/develop/armv7/Dockerfile b/docker/develop/armv7/Dockerfile index 65d284892..bb39ed902 100644 --- a/docker/develop/armv7/Dockerfile +++ b/docker/develop/armv7/Dockerfile @@ -17,7 +17,7 @@ ENV PHOTOPRISM_ARCH=$TARGETARCH \ TF_CPP_MIN_LOG_LEVEL="0" \ GOPATH="/go" \ GOBIN="/go/bin" \ - PATH="/scripts:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/usr/local/go/bin:/go/bin:/usr/local/bin:/usr/bin" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" diff --git a/docker/develop/bullseye-slim/Dockerfile b/docker/develop/bullseye-slim/Dockerfile index ad0e00a01..bf66b3e13 100644 --- a/docker/develop/bullseye-slim/Dockerfile +++ b/docker/develop/bullseye-slim/Dockerfile @@ -10,7 +10,7 @@ ARG BUILD_TAG ENV PHOTOPRISM_ARCH=$TARGETARCH \ DOCKER_TAG=$BUILD_TAG \ DOCKER_ENV="develop" \ - PATH="/scripts:/opt/photoprism/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin" \ TMPDIR="/tmp" \ DEBIAN_FRONTEND="noninteractive" \ TF_CPP_MIN_LOG_LEVEL="2" diff --git a/docker/develop/bullseye/Dockerfile b/docker/develop/bullseye/Dockerfile index 410d342b2..227789b89 100644 --- a/docker/develop/bullseye/Dockerfile +++ b/docker/develop/bullseye/Dockerfile @@ -17,7 +17,7 @@ ENV PHOTOPRISM_ARCH=$TARGETARCH \ TF_CPP_MIN_LOG_LEVEL="0" \ GOPATH="/go" \ GOBIN="/go/bin" \ - PATH="/scripts:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/usr/local/go/bin:/go/bin:/usr/local/bin:/usr/bin" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" diff --git a/docker/develop/buster/Dockerfile b/docker/develop/buster/Dockerfile index dad2f5e0c..480d604aa 100644 --- a/docker/develop/buster/Dockerfile +++ b/docker/develop/buster/Dockerfile @@ -17,7 +17,7 @@ ENV PHOTOPRISM_ARCH=$TARGETARCH \ TF_CPP_MIN_LOG_LEVEL="0" \ GOPATH="/go" \ GOBIN="/go/bin" \ - PATH="/scripts:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/usr/local/go/bin:/go/bin:/usr/local/bin:/usr/bin" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" diff --git a/docker/develop/impish/Dockerfile b/docker/develop/impish/Dockerfile index 867f2f259..b8ad0746d 100644 --- a/docker/develop/impish/Dockerfile +++ b/docker/develop/impish/Dockerfile @@ -17,7 +17,7 @@ ENV PHOTOPRISM_ARCH=$TARGETARCH \ TF_CPP_MIN_LOG_LEVEL="0" \ GOPATH="/go" \ GOBIN="/go/bin" \ - PATH="/scripts:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/usr/local/go/bin:/go/bin:/usr/local/bin:/usr/bin" \ GO111MODULE="on" \ CGO_CFLAGS="-g -O2 -Wno-return-local-addr" diff --git a/docker/examples/arm64/docker-compose.yml b/docker/examples/arm64/docker-compose.yml index 2395c1054..a34e99705 100644 --- a/docker/examples/arm64/docker-compose.yml +++ b/docker/examples/arm64/docker-compose.yml @@ -96,6 +96,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + HOME: "/photoprism" ## Start as a non-root user (see https://docs.docker.com/engine/reference/run/#user) # user: "1000:1000" ## Share hardware devices with FFmpeg and TensorFlow (optional): diff --git a/docker/examples/armv7/docker-compose.yml b/docker/examples/armv7/docker-compose.yml index 72122a95d..faa54cf2c 100644 --- a/docker/examples/armv7/docker-compose.yml +++ b/docker/examples/armv7/docker-compose.yml @@ -90,6 +90,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + HOME: "/photoprism" ## Start as a non-root user (see https://docs.docker.com/engine/reference/run/#user) # user: "1000:1000" ## Share hardware devices with FFmpeg and TensorFlow (optional): diff --git a/docker/examples/cloud/docker-compose.yml b/docker/examples/cloud/docker-compose.yml index fa449ee1f..ef0e6607b 100644 --- a/docker/examples/cloud/docker-compose.yml +++ b/docker/examples/cloud/docker-compose.yml @@ -156,6 +156,7 @@ services: PHOTOPRISM_DATABASE_PASSWORD: "_admin_password_" # MariaDB or MySQL database user password ## Run/install on first startup (options: update, gpu, tensorflow, davfs, clean): PHOTOPRISM_INIT: "update tensorflow clean" + HOME: "/photoprism" working_dir: "/photoprism" ## Storage Folders: "~" is a shortcut for your home directory, "." for the current directory volumes: diff --git a/docker/examples/docker-compose.yml b/docker/examples/docker-compose.yml index 3aaa9dedc..006c48a61 100644 --- a/docker/examples/docker-compose.yml +++ b/docker/examples/docker-compose.yml @@ -90,6 +90,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + HOME: "/photoprism" ## Start as a non-root user (see https://docs.docker.com/engine/reference/run/#user) # user: "1000:1000" ## Share hardware devices with FFmpeg and TensorFlow (optional): diff --git a/docker/examples/macos/docker-compose.yml b/docker/examples/macos/docker-compose.yml index b3970da0d..702c6c8ef 100644 --- a/docker/examples/macos/docker-compose.yml +++ b/docker/examples/macos/docker-compose.yml @@ -77,6 +77,7 @@ services: PHOTOPRISM_SITE_AUTHOR: "" ## Run/install on first startup (options: update, gpu, tensorflow, davfs, nano, clean): # PHOTOPRISM_INIT: "gpu tensorflow" + HOME: "/photoprism" ## Storage Folders: "~" is a shortcut for your home directory, "." for the current directory volumes: # "/host/folder:/photoprism/folder" # example diff --git a/docker/examples/scheduler/docker-compose.yml b/docker/examples/scheduler/docker-compose.yml index 27f28013c..c074ffcef 100644 --- a/docker/examples/scheduler/docker-compose.yml +++ b/docker/examples/scheduler/docker-compose.yml @@ -87,6 +87,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + HOME: "/photoprism" ## Start as a non-root user (see https://docs.docker.com/engine/reference/run/#user) # user: "1000:1000" working_dir: "/photoprism" diff --git a/docker/examples/sqlite/docker-compose.yml b/docker/examples/sqlite/docker-compose.yml index 73b2c80ba..8b37bde57 100644 --- a/docker/examples/sqlite/docker-compose.yml +++ b/docker/examples/sqlite/docker-compose.yml @@ -80,6 +80,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + HOME: "/photoprism" ## Start as a non-root user (see https://docs.docker.com/engine/reference/run/#user) # user: "1000:1000" working_dir: "/photoprism" diff --git a/docker/examples/windows/docker-compose.yml b/docker/examples/windows/docker-compose.yml index 3ff5bd622..fb00e0847 100644 --- a/docker/examples/windows/docker-compose.yml +++ b/docker/examples/windows/docker-compose.yml @@ -80,6 +80,7 @@ services: PHOTOPRISM_SITE_CAPTION: "AI-Powered Photos App" PHOTOPRISM_SITE_DESCRIPTION: "" PHOTOPRISM_SITE_AUTHOR: "" + HOME: "/photoprism" working_dir: "/photoprism" ## Storage Folders: use "/" not "\" as separator, "~" is a shortcut for C:/user/{username}, "." for the current directory volumes: diff --git a/docker/photoprism/armv7/Dockerfile b/docker/photoprism/armv7/Dockerfile index ffa5b342b..9f4b7704b 100644 --- a/docker/photoprism/armv7/Dockerfile +++ b/docker/photoprism/armv7/Dockerfile @@ -24,7 +24,7 @@ ARG BUILD_TAG ENV PHOTOPRISM_ARCH=$TARGETARCH \ DOCKER_TAG=$BUILD_TAG \ DOCKER_ENV="prod" \ - PATH="/scripts:/opt/photoprism/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin" \ TMPDIR="/tmp" \ DEBIAN_FRONTEND="noninteractive" \ TF_CPP_MIN_LOG_LEVEL="2" \ diff --git a/docker/photoprism/bullseye/Dockerfile b/docker/photoprism/bullseye/Dockerfile index e7b5a0b46..49f1b6f0f 100644 --- a/docker/photoprism/bullseye/Dockerfile +++ b/docker/photoprism/bullseye/Dockerfile @@ -24,7 +24,7 @@ ARG BUILD_TAG ENV PHOTOPRISM_ARCH=$TARGETARCH \ DOCKER_TAG=$BUILD_TAG \ DOCKER_ENV="prod" \ - PATH="/scripts:/opt/photoprism/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin" \ TMPDIR="/tmp" \ DEBIAN_FRONTEND="noninteractive" \ TF_CPP_MIN_LOG_LEVEL="2" \ diff --git a/docker/photoprism/buster/Dockerfile b/docker/photoprism/buster/Dockerfile index 61682a0fc..e58f546bb 100644 --- a/docker/photoprism/buster/Dockerfile +++ b/docker/photoprism/buster/Dockerfile @@ -24,7 +24,7 @@ ARG BUILD_TAG ENV PHOTOPRISM_ARCH=$TARGETARCH \ DOCKER_TAG=$BUILD_TAG \ DOCKER_ENV="prod" \ - PATH="/scripts:/opt/photoprism/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin" \ TMPDIR="/tmp" \ DEBIAN_FRONTEND="noninteractive" \ TF_CPP_MIN_LOG_LEVEL="2" \ diff --git a/docker/photoprism/impish/Dockerfile b/docker/photoprism/impish/Dockerfile index f06fbebce..fed17f53f 100644 --- a/docker/photoprism/impish/Dockerfile +++ b/docker/photoprism/impish/Dockerfile @@ -24,7 +24,7 @@ ARG BUILD_TAG ENV PHOTOPRISM_ARCH=$TARGETARCH \ DOCKER_TAG=$BUILD_TAG \ DOCKER_ENV="prod" \ - PATH="/scripts:/opt/photoprism/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin" \ + PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin" \ TMPDIR="/tmp" \ DEBIAN_FRONTEND="noninteractive" \ TF_CPP_MIN_LOG_LEVEL="2" \ diff --git a/scripts/build.sh b/scripts/build.sh index be3fa052e..3957b74de 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -7,9 +7,9 @@ fi set -e -BUILD_OS=$(uname -s) -BUILD_ARCH=$("$(dirname "$0")/dist/arch.sh") -BUILD_DATE=$(date -u +%y%m%d) +BUILD_OS=$(/bin/uname -s) +BUILD_ARCH=$("$(/usr/bin/dirname "$0")/dist/arch.sh") +BUILD_DATE=$(/bin/date -u +%y%m%d) BUILD_VERSION=$(git describe --always) BUILD_TAG=${BUILD_DATE}-${BUILD_VERSION} BUILD_ID=${BUILD_TAG}-${BUILD_OS}-${BUILD_ARCH^^} @@ -35,6 +35,6 @@ echo "=> ${BUILD_CMD[*]}" "${BUILD_CMD[@]}" # show size -du -h "${BUILD_NAME}" +/usr/bin/du -h "${BUILD_NAME}" echo "Done." \ No newline at end of file diff --git a/scripts/dist/Makefile b/scripts/dist/Makefile index a8a0f173f..9354dcceb 100755 --- a/scripts/dist/Makefile +++ b/scripts/dist/Makefile @@ -10,12 +10,12 @@ tensorflow-amd64-avx2: tensorflow apt-cleanup: clean apt-upgrade: update update: - apt-get update - apt-get -qq dist-upgrade + /usr/bin/apt-get update + /usr/bin/apt-get -qq dist-upgrade clean: - apt-get -y autoremove - apt-get -y autoclean - rm -rf /var/lib/apt/lists/* + /usr/bin/apt-get -y autoremove + /usr/bin/apt-get -y autoclean + /bin/rm -rf /var/lib/apt/lists/* gpu: /scripts/install-gpu.sh tensorflow: @@ -23,8 +23,8 @@ tensorflow: davfs: /scripts/install-davfs.sh nano: - apt-get update - apt-get -qq install nano + /usr/bin/apt-get update + /usr/bin/apt-get -qq install nano .PHONY: update apt-upgrade clean apt-cleanup gpu tensorflow davfs nano \ tensorflow-amd64-cpu tensorflow-amd64-avx tensorflow-amd64-avx2 \ diff --git a/scripts/dist/arch.sh b/scripts/dist/arch.sh index 88d41417d..7e2c5a7f2 100755 --- a/scripts/dist/arch.sh +++ b/scripts/dist/arch.sh @@ -13,7 +13,7 @@ elif [[ $OS == "Windows_NT" ]]; then exit 1 fi else - SYSTEM_ARCH=$(uname -m) + SYSTEM_ARCH=$(/bin/uname -m) fi BUILD_ARCH=${BUILD_ARCH:-$SYSTEM_ARCH} diff --git a/scripts/dist/audit.sh b/scripts/dist/audit.sh index 0ed0a8496..c3f1d13b3 100755 --- a/scripts/dist/audit.sh +++ b/scripts/dist/audit.sh @@ -9,12 +9,12 @@ DOC_URL="https://docs.photoprism.app/getting-started/troubleshooting/docker/#fil set -e # create directory if not exists -mkdir -p "${STORAGE_PATH}" || (echo "Failed creating storage folder \"$STORAGE_PATH\", see $DOC_URL" 1>&2; exit 1) +/bin/mkdir -p "${STORAGE_PATH}" || (echo "Failed creating storage folder \"$STORAGE_PATH\", see $DOC_URL" 1>&2; exit 1) # check directory permissions [[ -w "${STORAGE_PATH}" ]] || \ (echo "Storage folder \"$STORAGE_PATH\" is not writable, see $DOC_URL" 1>&2; exit 1) # create and delete test file -(touch "${STORAGE_PATH}/is-writable" 2>/dev/null && rm "${STORAGE_PATH}/is-writable") || \ +(/usr/bin/touch "${STORAGE_PATH}/is-writable" 2>/dev/null && rm "${STORAGE_PATH}/is-writable") || \ (echo "Failed creating test file in storage folder, see $DOC_URL" 1>&2; exit 1) diff --git a/scripts/dist/cleanup.sh b/scripts/dist/cleanup.sh index 63f7727f0..83e6d06e0 100755 --- a/scripts/dist/cleanup.sh +++ b/scripts/dist/cleanup.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # abort if not executed as root -if [[ $(id -u) != "0" ]]; then +if [[ $(/usr/bin/id -u) != "0" ]]; then echo "Usage: run ${0##*/} as root" 1>&2 exit 1 fi @@ -9,21 +9,21 @@ fi set -o errexit if [[ ! -d /tmp ]]; then - mkdir /tmp + /bin/mkdir /tmp fi -chmod 1777 /tmp +/bin/chmod 1777 /tmp -apt-get -y autoremove -apt-get -y autoclean -rm -rf /var/lib/apt/lists/* -rm -rf /tmp/* /var/tmp/* +/usr/bin/apt-get -y autoremove +/usr/bin/apt-get -y autoclean +/bin/rm -rf /var/lib/apt/lists/* +/bin/rm -rf /tmp/* /var/tmp/* history -c -cat /dev/null > /root/.bash_history +/bin/cat /dev/null > /root/.bash_history unset HISTFILE -find /var/log -mtime -1 -type f -exec truncate -s 0 {} \; -rm -rf /var/log/*.gz /var/log/*.log /var/log/*.[0-9] /var/log/*-???????? -rm -rf /var/lib/cloud/instances/* -rm -f /root/.ssh/* /etc/ssh/*key* +/usr/bin/find /var/log -mtime -1 -type f -exec truncate -s 0 {} \; +/bin/rm -rf /var/log/*.gz /var/log/*.log /var/log/*.[0-9] /var/log/*-???????? +/bin/rm -rf /var/lib/cloud/instances/* +/bin/rm -f /root/.ssh/* /etc/ssh/*key* echo "Done." diff --git a/scripts/dist/dist-upgrade.sh b/scripts/dist/dist-upgrade.sh index 4099f9ecf..17dfafcc8 100755 --- a/scripts/dist/dist-upgrade.sh +++ b/scripts/dist/dist-upgrade.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # abort if not executed as root -if [[ $(id -u) != "0" ]]; then +if [[ $(/usr/bin/id -u) != "0" ]]; then echo "Usage: run ${0##*/} as root" 1>&2 exit 1 fi @@ -13,8 +13,8 @@ set -eu export DEBIAN_FRONTEND="noninteractive" export TMPDIR="/tmp" -apt-get -y update -apt-get -y dist-upgrade -apt-get -y autoremove +/usr/bin/apt-get -y update +/usr/bin/apt-get -y dist-upgrade +/usr/bin/apt-get -y autoremove echo "Done." \ No newline at end of file diff --git a/scripts/dist/entrypoint-init.sh b/scripts/dist/entrypoint-init.sh index 7d10a69db..d2a1880fa 100755 --- a/scripts/dist/entrypoint-init.sh +++ b/scripts/dist/entrypoint-init.sh @@ -3,7 +3,7 @@ # INITIALIZES CONTAINER PACKAGES AND PERMISSIONS # abort if not executed as root -if [[ $(id -u) != "0" ]]; then +if [[ $(/usr/bin/id -u) != "0" ]]; then echo "Usage: run ${0##*/} as root" 1>&2 exit 1 fi @@ -14,12 +14,14 @@ re='^[0-9]+$' # detect environment case $DOCKER_ENV in prod) + export PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin"; INIT_SCRIPTS="/scripts" CHOWN_DIRS=("/photoprism" "/opt/photoprism") CHMOD_DIRS=("/opt/photoprism") ;; develop) + export PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/usr/local/go/bin:/go/bin:/usr/local/bin:/usr/bin"; INIT_SCRIPTS="/go/src/github.com/photoprism/photoprism/scripts/dist" CHOWN_DIRS=("/go /photoprism" "/opt/photoprism" "/tmp/photoprism") CHMOD_DIRS=("/photoprism" "/opt/photoprism" "/tmp/photoprism") @@ -33,25 +35,25 @@ esac if [[ ${PHOTOPRISM_UID} =~ $re ]] && [[ ${PHOTOPRISM_UID} != "0" ]]; then if [[ ${PHOTOPRISM_GID} =~ $re ]] && [[ ${PHOTOPRISM_GID} != "0" ]]; then - groupadd -g "${PHOTOPRISM_GID}" "group_${PHOTOPRISM_GID}" 2>/dev/null - useradd -o -u "${PHOTOPRISM_UID}" -g "${PHOTOPRISM_GID}" -d "/photoprism" "user_${PHOTOPRISM_UID}" 2>/dev/null - usermod -g "${PHOTOPRISM_GID}" "user_${PHOTOPRISM_UID}" 2>/dev/null + /usr/sbin/groupadd -g "${PHOTOPRISM_GID}" "group_${PHOTOPRISM_GID}" 2>/dev/null + /usr/sbin/useradd -o -u "${PHOTOPRISM_UID}" -g "${PHOTOPRISM_GID}" -d "/photoprism" "user_${PHOTOPRISM_UID}" 2>/dev/null + /usr/sbin/usermod -g "${PHOTOPRISM_GID}" "user_${PHOTOPRISM_UID}" 2>/dev/null if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]]; then echo "updating filesystem permissions..." echo "PHOTOPRISM_DISABLE_CHOWN: \"true\" disables filesystem permission updates" - chown --preserve-root -Rcf "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" "${CHOWN_DIRS[@]}" - chmod --preserve-root -Rcf u+rwX "${CHMOD_DIRS[@]}" + /bin/chown --preserve-root -Rcf "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" "${CHOWN_DIRS[@]}" + /bin/chmod --preserve-root -Rcf u+rwX "${CHMOD_DIRS[@]}" fi else - useradd -o -u "${PHOTOPRISM_UID}" -g 1000 -d "/photoprism" "user_${PHOTOPRISM_UID}" 2>/dev/null - usermod -g 1000 "user_${PHOTOPRISM_UID}" 2>/dev/null + /usr/sbin/useradd -o -u "${PHOTOPRISM_UID}" -g 1000 -d "/photoprism" "user_${PHOTOPRISM_UID}" 2>/dev/null + /usr/sbin/usermod -g 1000 "user_${PHOTOPRISM_UID}" 2>/dev/null if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]]; then echo "updating filesystem permissions..." echo "PHOTOPRISM_DISABLE_CHOWN: \"true\" disables filesystem permission updates" - chown --preserve-root -Rcf "${PHOTOPRISM_UID}" "${CHOWN_DIRS[@]}" - chmod --preserve-root -Rcf u+rwX "${CHMOD_DIRS[@]}" + /bin/chown --preserve-root -Rcf "${PHOTOPRISM_UID}" "${CHOWN_DIRS[@]}" + /bin/chmod --preserve-root -Rcf u+rwX "${CHMOD_DIRS[@]}" fi fi fi @@ -63,11 +65,11 @@ fi INIT_LOCK="/scripts/.init-lock" -# execute targets via make +# execute targets via /usr/bin/make if [[ ! -e ${INIT_LOCK} ]]; then for INIT_TARGET in $PHOTOPRISM_INIT; do echo "init $INIT_TARGET..." - make -C "$INIT_SCRIPTS" "$INIT_TARGET" + /usr/bin/make -C "$INIT_SCRIPTS" "$INIT_TARGET" done echo 1 >${INIT_LOCK} diff --git a/scripts/dist/entrypoint.sh b/scripts/dist/entrypoint.sh index 140cd28bc..ffa7400c2 100755 --- a/scripts/dist/entrypoint.sh +++ b/scripts/dist/entrypoint.sh @@ -11,16 +11,18 @@ export DOCKER_TAG=${DOCKER_TAG:-unknown} # detect environment case $DOCKER_ENV in prod) + export PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/opt/photoprism/bin:/usr/local/bin:/usr/bin"; INIT_SCRIPT="/scripts/entrypoint-init.sh" ;; develop) + export PATH="/usr/local/sbin:/usr/sbin:/sbin:/bin:/scripts:/usr/local/go/bin:/go/bin:/usr/local/bin:/usr/bin"; INIT_SCRIPT="/go/src/github.com/photoprism/photoprism/scripts/dist/entrypoint-init.sh" ;; *) - INIT_SCRIPT="" echo "unknown environment \"$DOCKER_ENV\""; + INIT_SCRIPT="" ;; esac @@ -44,16 +46,16 @@ fi DOCKER_IMAGE="$PHOTOPRISM_ARCH-$DOCKER_ENV/$DOCKER_TAG" # initialize container packages and permissions -if [[ -f "${INIT_SCRIPT}" ]]; then - if [[ $(id -u) == "0" ]]; then +if [[ ${INIT_SCRIPT} ]] && [[ -f "${INIT_SCRIPT}" ]]; then + if [[ $(/usr/bin/id -u) == "0" ]]; then echo "init $DOCKER_IMAGE as root" - bash -c "${INIT_SCRIPT}" + /bin/bash -c "${INIT_SCRIPT}" else - echo "init $DOCKER_IMAGE as uid $(id -u)" - sudo -E "${INIT_SCRIPT}" + echo "init $DOCKER_IMAGE as uid $(/usr/bin/id -u)" + /usr/bin/sudo -E "${INIT_SCRIPT}" fi else - echo "started $DOCKER_IMAGE as uid $(id -u)" + echo "started $DOCKER_IMAGE as uid $(/usr/bin/id -u)" fi # set explicit home directory @@ -80,22 +82,22 @@ echo "import-path: ${PHOTOPRISM_IMPORT_PATH}" echo "assets-path: ${PHOTOPRISM_ASSETS_PATH}" # change to another user and group on request -if [[ $(id -u) == "0" ]] && [[ ${PHOTOPRISM_UID} =~ $re ]] && [[ ${PHOTOPRISM_UID} != "0" ]]; then +if [[ ${INIT_SCRIPT} ]] && [[ $(/usr/bin/id -u) == "0" ]] && [[ ${PHOTOPRISM_UID} =~ $re ]] && [[ ${PHOTOPRISM_UID} != "0" ]]; then # check uid and gid env variables if [[ ${PHOTOPRISM_GID} =~ $re ]] && [[ ${PHOTOPRISM_GID} != "0" ]]; then echo "switching to uid ${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" echo "${@}" # run command as uid:gid - ([[ ${DOCKER_ENV} != "prod" ]] || gosu "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" "/scripts/audit.sh") \ - && gosu "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" "$@" & + ([[ ${DOCKER_ENV} != "prod" ]] || /bin/gosu "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" "/scripts/audit.sh") \ + && /bin/gosu "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" "$@" & else echo "switching to uid ${PHOTOPRISM_UID}" echo "${@}" # run command as uid - ([[ ${DOCKER_ENV} != "prod" ]] || gosu "${PHOTOPRISM_UID}" "/scripts/audit.sh") \ - && gosu "${PHOTOPRISM_UID}" "$@" & + ([[ ${DOCKER_ENV} != "prod" ]] || /bin/gosu "${PHOTOPRISM_UID}" "/scripts/audit.sh") \ + && /bin/gosu "${PHOTOPRISM_UID}" "$@" & fi else echo "running as uid $(id -u)" diff --git a/scripts/dist/heif-convert.sh b/scripts/dist/heif-convert.sh index bf2db0a76..ccb35a9a0 100755 --- a/scripts/dist/heif-convert.sh +++ b/scripts/dist/heif-convert.sh @@ -11,7 +11,7 @@ fi # Reset Exif orientation flag if output image was rotated based on "QuickTime:Rotation" -if [[ $(exiftool -n -QuickTime:Rotation "$1") ]]; then +if [[ $(/usr/bin/exiftool -n -QuickTime:Rotation "$1") ]]; then /usr/bin/exiftool -overwrite_original -P -n '-ModifyDate> /etc/apt/sources.list.d/google-chrome.list' -apt-get update -apt-get -qq install google-chrome-stable +/usr/bin/wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | /usr/bin/apt-key add - +/bin/sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' +/usr/bin/apt-get update +/usr/bin/apt-get -qq install google-chrome-stable echo "Done." \ No newline at end of file diff --git a/scripts/dist/install-darktable.sh b/scripts/dist/install-darktable.sh index ded94b241..1809ef23f 100755 --- a/scripts/dist/install-darktable.sh +++ b/scripts/dist/install-darktable.sh @@ -8,7 +8,7 @@ fi set -e -SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +SYSTEM_ARCH=$("$(/usr/bin/dirname "$0")/arch.sh") DESTARCH=${2:-$SYSTEM_ARCH} . /etc/os-release @@ -17,30 +17,30 @@ echo "Installing Darktable for ${DESTARCH^^}..." if [[ $DESTARCH == "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 - apt-get update - apt-get -qq install darktable + echo 'deb http://download.opensuse.org/repositories/graphics:/darktable/Debian_11/ /' | /usr/bin/tee /etc/apt/sources.list.d/graphics:darktable.list + /usr/bin/curl -fsSL https://download.opensuse.org/repositories/graphics:darktable/Debian_11/Release.key | gpg --dearmor | /usr/bin/tee /etc/apt/trusted.gpg.d/graphics_darktable.gpg > /dev/null + /usr/bin/apt-get update + /usr/bin/apt-get -qq install darktable elif [[ $VERSION_CODENAME == "buster" ]]; then - echo 'deb http://download.opensuse.org/repositories/graphics:/darktable/Debian_10/ /' | tee /etc/apt/sources.list.d/graphics:darktable.list - curl -fsSL https://download.opensuse.org/repositories/graphics:darktable/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/graphics_darktable.gpg > /dev/null - apt-get update - apt-get -qq install darktable + echo 'deb http://download.opensuse.org/repositories/graphics:/darktable/Debian_10/ /' | /usr/bin/tee /etc/apt/sources.list.d/graphics:darktable.list + /usr/bin/curl -fsSL https://download.opensuse.org/repositories/graphics:darktable/Debian_10/Release.key | gpg --dearmor | /usr/bin/tee /etc/apt/trusted.gpg.d/graphics_darktable.gpg > /dev/null + /usr/bin/apt-get update + /usr/bin/apt-get -qq install darktable else echo "install-darktable: installing standard amd64 (Intel 64-bit) package" - apt-get -qq install darktable + /usr/bin/apt-get -qq install darktable fi echo "Done." elif [[ $DESTARCH == "arm64" ]]; then if [[ $VERSION_CODENAME == "bullseye" ]]; then - apt-get update - apt-get -qq install -t bullseye-backports darktable + /usr/bin/apt-get update + /usr/bin/apt-get -qq install -t bullseye-backports darktable elif [[ $VERSION_CODENAME == "buster" ]]; then - apt-get update - apt-get -qq install -t buster-backports darktable + /usr/bin/apt-get update + /usr/bin/apt-get -qq install -t buster-backports darktable else echo "install-darktable: installing standard amd64 (ARM 64-bit) package" - apt-get -qq install darktable + /usr/bin/apt-get -qq install darktable fi echo "Done." else diff --git a/scripts/dist/install-davfs.sh b/scripts/dist/install-davfs.sh index 9b5bd2474..97011f2d8 100755 --- a/scripts/dist/install-davfs.sh +++ b/scripts/dist/install-davfs.sh @@ -8,7 +8,7 @@ fi echo "Installing WebDAV filesystem driver..." -apt-get update -apt-get -qq install davfs2 +/usr/bin/apt-get update +/usr/bin/apt-get -qq install davfs2 echo "Done." \ No newline at end of file diff --git a/scripts/dist/install-go.sh b/scripts/dist/install-go.sh index c5f9662d6..56bb792dd 100755 --- a/scripts/dist/install-go.sh +++ b/scripts/dist/install-go.sh @@ -2,7 +2,7 @@ GOLANG_VERSION=1.18 -DESTDIR=$(realpath "${1:-/usr/local}") +DESTDIR=$(/usr/bin/realpath "${1:-/usr/local}") # abort if not executed as root if [[ $(id -u) != "0" ]]; then @@ -14,9 +14,9 @@ echo "Installing Go in \"$DESTDIR\"..." set -e -mkdir -p "$DESTDIR" +/bin/mkdir -p "$DESTDIR" -SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +SYSTEM_ARCH=$("$(/usr/bin/dirname "$0")/arch.sh") DESTARCH=${2:-$SYSTEM_ARCH} set -eux; @@ -37,11 +37,11 @@ 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/bin/wget -O go.tgz $URL +echo $CHECKSUM | /usr/bin/sha256sum -c - +/bin/rm -rf /usr/local/go +/bin/tar -C /usr/local -xzf go.tgz +/bin/rm go.tgz /usr/local/go/bin/go version diff --git a/scripts/dist/install-gpu.sh b/scripts/dist/install-gpu.sh index e37a99f11..793247112 100755 --- a/scripts/dist/install-gpu.sh +++ b/scripts/dist/install-gpu.sh @@ -8,7 +8,7 @@ fi set -e -SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +SYSTEM_ARCH=$("$(/usr/bin/dirname "$0")/arch.sh") DESTARCH=${DESTARCH:-$SYSTEM_ARCH} TMPDIR=${TMPDIR:-/tmp} . /etc/os-release @@ -18,22 +18,22 @@ if [[ $DESTARCH != "amd64" ]]; then exit fi -apt-get update -apt-get -qq upgrade -apt-get -qq install lshw jq +/usr/bin/apt-get update +/usr/bin/apt-get -qq upgrade +/usr/bin/apt-get -qq install lshw jq # shellcheck disable=SC2207 -GPU_DETECTED=($(lshw -c display -json 2>/dev/null | jq -r '.[].configuration.driver')) +GPU_DETECTED=($(/usr/bin/lshw -c display -json 2>/dev/null | /usr/bin/jq -r '.[].configuration.driver')) # shellcheck disable=SC2068 for t in ${GPU_DETECTED[@]}; do case $t in i915) - apt-get -qq install intel-opencl-icd intel-media-va-driver-non-free i965-va-driver-shaders libmfx1 libva2 vainfo libva-wayland2 + /usr/bin/apt-get -qq install intel-opencl-icd intel-media-va-driver-non-free i965-va-driver-shaders libmfx1 libva2 vainfo libva-wayland2 ;; nvidia) - apt-get -qq install nvidia-opencl-icd nvidia-vdpau-driver nvidia-driver-libs nvidia-kernel-dkms libva2 vainfo libva-wayland2 + /usr/bin/apt-get -qq install nvidia-opencl-icd nvidia-vdpau-driver nvidia-driver-libs nvidia-kernel-dkms libva2 vainfo libva-wayland2 ;; *) diff --git a/scripts/dist/install-mariadb.sh b/scripts/dist/install-mariadb.sh index 5409e49dc..56fcedccd 100755 --- a/scripts/dist/install-mariadb.sh +++ b/scripts/dist/install-mariadb.sh @@ -17,12 +17,12 @@ SETUP_URL="https://downloads.mariadb.com/MariaDB/mariadb_repo_setup" if [ ! -f "/etc/apt/sources.list.d/mariadb.list" ]; then echo "Adding MariaDB packages sources from \"$SETUP_URL\"..." - curl -Ls $SETUP_URL | bash -s -- --mariadb-server-version="mariadb-10.6" + /usr/bin/curl -Ls $SETUP_URL | /bin/bash -s -- --mariadb-server-version="mariadb-10.6" fi echo "Installing \"$1\"..." -apt-get update -apt-get -qq install $1 +/usr/bin/apt-get update +/usr/bin/apt-get -qq install $1 echo "Done." \ No newline at end of file diff --git a/scripts/dist/install-nodejs.sh b/scripts/dist/install-nodejs.sh index 2d9060ba0..91162c6ac 100755 --- a/scripts/dist/install-nodejs.sh +++ b/scripts/dist/install-nodejs.sh @@ -12,8 +12,8 @@ SETUP_URL="https://deb.nodesource.com/setup_16.x" echo "Installing NodeJS and NPM from \"$SETUP_URL\"..." -curl -sL $SETUP_URL | bash - -apt-get update && apt-get -qq install nodejs +/usr/bin/curl -sL $SETUP_URL | /bin/bash - +/usr/bin/apt-get update && /usr/bin/apt-get -qq install nodejs npm install --unsafe-perm=true --allow-root -g npm testcafe npm config set cache ~/.cache/npm diff --git a/scripts/dist/install-tensorflow.sh b/scripts/dist/install-tensorflow.sh index 66319cbab..a0c820471 100755 --- a/scripts/dist/install-tensorflow.sh +++ b/scripts/dist/install-tensorflow.sh @@ -4,14 +4,14 @@ set -e TF_VERSION=${TF_VERSION:-1.15.2} -SYSTEM_ARCH=$("$(dirname "$0")/arch.sh") +SYSTEM_ARCH=$("$(/usr/bin/dirname "$0")/arch.sh") DESTARCH=${DESTARCH:-$SYSTEM_ARCH} if [[ $1 == "auto" ]]; then TF_DRIVER="auto"; DESTDIR="/usr"; else - DESTDIR=$(realpath "${1:-/usr}") + DESTDIR=$(/usr/bin/realpath "${1:-/usr}") fi TMPDIR=${TMPDIR:-/tmp} @@ -22,11 +22,11 @@ if [[ $(id -u) != "0" ]] && [[ $DESTDIR == "/usr" || $DESTDIR == "/usr/local" ]] exit 1 fi -mkdir -p "$DESTDIR" +/bin/mkdir -p "$DESTDIR" if [[ $TF_DRIVER == "auto" ]]; then echo "Detecting driver..." - TF_DRIVER=$("$(dirname "$0")/tensorflow-driver.sh") + TF_DRIVER=$("$(/usr/bin/dirname "$0")/tensorflow-driver.sh") fi if [[ -z $TF_DRIVER ]]; then @@ -40,13 +40,13 @@ fi if [ ! -f "$TMPDIR/$INSTALL_FILE" ]; then URL="https://dl.photoprism.app/tensorflow/${INSTALL_FILE}" echo "Downloading ${DESTARCH} libs from \"$URL\". Please wait." - curl --create-dirs -fsSL -o "$TMPDIR/$INSTALL_FILE" "$URL" + /usr/bin/curl --create-dirs -fsSL -o "$TMPDIR/$INSTALL_FILE" "$URL" fi echo "Extracting \"$TMPDIR/$INSTALL_FILE\" to \"$DESTDIR\"." if [ -f "$TMPDIR/$INSTALL_FILE" ]; then - tar --overwrite --mode=755 -C "$DESTDIR" -xzf "$TMPDIR/$INSTALL_FILE" + /bin/tar --overwrite --mode=755 -C "$DESTDIR" -xzf "$TMPDIR/$INSTALL_FILE" else echo "Fatal: \"$TMPDIR/$INSTALL_FILE\" not found" exit 1 @@ -54,10 +54,10 @@ fi if [[ $DESTDIR == "/usr" || $DESTDIR == "/usr/local" ]]; then echo "Running \"ldconfig\"." - ldconfig + /sbin/ldconfig else echo "Running \"ldconfig -n $DESTDIR/lib\"." - ldconfig -n "$DESTDIR/lib" + /sbin/ldconfig -n "$DESTDIR/lib" fi echo "Done." diff --git a/scripts/dist/tensorflow-driver.sh b/scripts/dist/tensorflow-driver.sh index 02dcf93b8..ce89a94f5 100755 --- a/scripts/dist/tensorflow-driver.sh +++ b/scripts/dist/tensorflow-driver.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -CPU_DETECTED=$(lshw -c processor -json 2>/dev/null) +CPU_DETECTED=$(/usr/bin/lshw -c processor -json 2>/dev/null) -if [[ $(echo "${CPU_DETECTED}" | jq -r '.[].capabilities.avx2') == "true" ]]; then +if [[ $(echo "${CPU_DETECTED}" | /usr/bin/jq -r '.[].capabilities.avx2') == "true" ]]; then echo "avx2" -elif [[ $(echo "${CPU_DETECTED}" | jq -r '.[].capabilities.avx') == "true" ]]; then +elif [[ $(echo "${CPU_DETECTED}" | /usr/bin/jq -r '.[].capabilities.avx') == "true" ]]; then echo "avx" fi \ No newline at end of file diff --git a/scripts/docker/build.sh b/scripts/docker/build.sh index 1f73c6822..00b8ddb8c 100755 --- a/scripts/docker/build.sh +++ b/scripts/docker/build.sh @@ -11,7 +11,7 @@ if [[ -z $1 ]] || [[ -z $2 ]]; then fi NUMERIC='^[0-9]+$' -BUILD_DATE=$(date -u +%y%m%d) +BUILD_DATE=$(/bin/date -u +%y%m%d) echo "Building image 'photoprism/$1' from docker/${1/-//}$3/Dockerfile..."; diff --git a/scripts/docker/buildx-multi.sh b/scripts/docker/buildx-multi.sh index 93e40ba26..c1c47ed10 100755 --- a/scripts/docker/buildx-multi.sh +++ b/scripts/docker/buildx-multi.sh @@ -9,7 +9,7 @@ if [[ -z $1 ]] || [[ -z $2 ]]; then fi NUMERIC='^[0-9]+$' -BUILD_DATE=$(date -u +%y%m%d) +BUILD_DATE=$(/bin/date -u +%y%m%d) # kill old multi builder if still alive. echo "Removing existing multibuilder..." diff --git a/scripts/docker/buildx.sh b/scripts/docker/buildx.sh index 5eab8950d..bc10173ad 100755 --- a/scripts/docker/buildx.sh +++ b/scripts/docker/buildx.sh @@ -9,7 +9,7 @@ if [[ -z $1 ]] || [[ -z $2 ]]; then fi NUMERIC='^[0-9]+$' -BUILD_DATE=$(date -u +%y%m%d) +BUILD_DATE=$(/bin/date -u +%y%m%d) echo "Starting 'photoprism/$1' build from docker/${1/-//}$4/Dockerfile..." echo "Build Arch: $2" diff --git a/scripts/download-facenet.sh b/scripts/download-facenet.sh index 6e00dae50..b2a9887ed 100755 --- a/scripts/download-facenet.sh +++ b/scripts/download-facenet.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -TODAY=`date -u +%Y%m%d` +TODAY=$(/bin/date -u +%Y%m%d) MODEL_NAME="Facenet" MODEL_URL="https://dl.photoprism.app/tensorflow/facenet.zip?$TODAY" @@ -13,11 +13,11 @@ MODEL_BACKUP="storage/backup/facenet-$TODAY" echo "Installing $MODEL_NAME model for TensorFlow..." # Create directories -mkdir -p /tmp/photoprism -mkdir -p storage/backup +/bin/mkdir -p /tmp/photoprism +/bin/mkdir -p storage/backup # Check for update -if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then +if [[ -f ${MODEL_ZIP} ]] && [[ $(/usr/bin/sha1sum ${MODEL_ZIP}) == ${MODEL_HASH} ]]; then if [[ -f ${MODEL_VERSION} ]]; then echo "Already up to date." exit @@ -25,22 +25,22 @@ if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then else # Download model echo "Downloading latest model from $MODEL_URL..." - wget ${MODEL_URL} -O ${MODEL_ZIP} + /usr/bin/wget ${MODEL_URL} -O ${MODEL_ZIP} - TMP_HASH=`sha1sum ${MODEL_ZIP}` + TMP_HASH=$(/usr/bin/sha1sum ${MODEL_ZIP}) - echo ${TMP_HASH} + echo "${TMP_HASH}" fi # Create backup if [[ -e ${MODEL_PATH} ]]; then echo "Creating backup of existing directory: $MODEL_BACKUP" - rm -rf ${MODEL_BACKUP} - mv ${MODEL_PATH} ${MODEL_BACKUP} + /bin/rm -rf "${MODEL_BACKUP}" + /bin/mv ${MODEL_PATH} "${MODEL_BACKUP}" fi # Unzip model -unzip ${MODEL_ZIP} -d assets +/usr/bin/unzip ${MODEL_ZIP} -d assets echo "$MODEL_NAME $TODAY $MODEL_HASH" > ${MODEL_VERSION} echo "Latest $MODEL_NAME installed." diff --git a/scripts/download-nasnet.sh b/scripts/download-nasnet.sh index 2fea8fbac..9e0dcc7e2 100755 --- a/scripts/download-nasnet.sh +++ b/scripts/download-nasnet.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -TODAY=`date -u +%Y%m%d` +TODAY=$(/bin/date -u +%Y%m%d) MODEL_NAME="NASNet Mobile" MODEL_URL="https://dl.photoprism.app/tensorflow/nasnet.zip?$TODAY" @@ -13,11 +13,11 @@ MODEL_BACKUP="storage/backup/nasnet-$TODAY" echo "Installing $MODEL_NAME model for TensorFlow..." # Create directories -mkdir -p /tmp/photoprism -mkdir -p storage/backup +/bin/mkdir -p /tmp/photoprism +/bin/mkdir -p storage/backup # Check for update -if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then +if [[ -f ${MODEL_ZIP} ]] && [[ $(/usr/bin/sha1sum ${MODEL_ZIP}) == "${MODEL_HASH}" ]]; then if [[ -f ${MODEL_VERSION} ]]; then echo "Already up to date." exit @@ -25,22 +25,22 @@ if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then else # Download model echo "Downloading latest model from $MODEL_URL..." - wget ${MODEL_URL} -O ${MODEL_ZIP} + /usr/bin/wget "${MODEL_URL}" -O ${MODEL_ZIP} - TMP_HASH=`sha1sum ${MODEL_ZIP}` + TMP_HASH=$(/usr/bin/sha1sum ${MODEL_ZIP}) - echo ${TMP_HASH} + echo "${TMP_HASH}" fi # Create backup if [[ -e ${MODEL_PATH} ]]; then echo "Creating backup of existing directory: $MODEL_BACKUP" - rm -rf ${MODEL_BACKUP} - mv ${MODEL_PATH} ${MODEL_BACKUP} + /bin/rm -rf "${MODEL_BACKUP}" + /bin/mv ${MODEL_PATH} "${MODEL_BACKUP}" fi # Unzip model -unzip ${MODEL_ZIP} -d assets +/usr/bin/unzip ${MODEL_ZIP} -d assets echo "$MODEL_NAME $TODAY $MODEL_HASH" > ${MODEL_VERSION} echo "Latest $MODEL_NAME installed." diff --git a/scripts/download-nsfw.sh b/scripts/download-nsfw.sh index 02d114b64..52ee09327 100755 --- a/scripts/download-nsfw.sh +++ b/scripts/download-nsfw.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -TODAY=`date -u +%Y%m%d` +TODAY=$(/bin/date -u +%Y%m%d) MODEL_NAME="NSFW" MODEL_URL="https://dl.photoprism.app/tensorflow/nsfw.zip?$TODAY" @@ -13,11 +13,11 @@ MODEL_BACKUP="storage/backup/nsfw-$TODAY" echo "Installing $MODEL_NAME model for TensorFlow..." # Create directories -mkdir -p /tmp/photoprism -mkdir -p storage/backup +/bin/mkdir -p /tmp/photoprism +/bin/mkdir -p storage/backup # Check for update -if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then +if [[ -f ${MODEL_ZIP} ]] && [[ $(/usr/bin/sha1sum ${MODEL_ZIP}) == "${MODEL_HASH}" ]]; then if [[ -f ${MODEL_VERSION} ]]; then echo "Already up to date." exit @@ -25,9 +25,9 @@ if [[ -f ${MODEL_ZIP} ]] && [[ `sha1sum ${MODEL_ZIP}` == ${MODEL_HASH} ]]; then else # Download model echo "Downloading latest model from $MODEL_URL..." - wget ${MODEL_URL} -O ${MODEL_ZIP} + /usr/bin/wget "${MODEL_URL}" -O ${MODEL_ZIP} - TMP_HASH=`sha1sum ${MODEL_ZIP}` + TMP_HASH=$(/usr/bin/sha1sum ${MODEL_ZIP}) echo ${TMP_HASH} fi @@ -35,12 +35,12 @@ fi # Create backup if [[ -e ${MODEL_PATH} ]]; then echo "Creating backup of existing directory: $MODEL_BACKUP" - rm -rf ${MODEL_BACKUP} - mv ${MODEL_PATH} ${MODEL_BACKUP} + /bin/rm -rf "${MODEL_BACKUP}" + /bin/mv ${MODEL_PATH} "${MODEL_BACKUP}" fi # Unzip model -unzip ${MODEL_ZIP} -d assets +/usr/bin/unzip ${MODEL_ZIP} -d assets echo "$MODEL_NAME $TODAY $MODEL_HASH" > ${MODEL_VERSION} echo "Latest $MODEL_NAME installed."