Docker: Use absolute command names to avoid path problems #2146 #2149

This commit is contained in:
Michael Mayer 2022-03-16 19:09:53 +01:00
parent de6e0390a7
commit 5dce02ebbd
43 changed files with 163 additions and 150 deletions

View file

@ -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"

View file

@ -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:

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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):

View file

@ -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):

View file

@ -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:

View file

@ -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):

View file

@ -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

View file

@ -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"

View file

@ -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"

View file

@ -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:

View file

@ -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" \

View file

@ -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" \

View file

@ -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" \

View file

@ -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" \

View file

@ -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."

14
scripts/dist/Makefile vendored
View file

@ -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 \

View file

@ -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}

View file

@ -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)

View file

@ -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."

View file

@ -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."

View file

@ -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}

View file

@ -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)"

View file

@ -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<FileModifyDate' -Orientation=1 "$2"
else
/usr/bin/exiftool -overwrite_original -P -n '-ModifyDate<FileModifyDate' "$2"

View file

@ -6,7 +6,7 @@ if [[ $(id -u) != "0" ]]; then
exit 1
fi
SYSTEM_ARCH=$("$(dirname "$0")/arch.sh")
SYSTEM_ARCH=$("$(/usr/bin/dirname "$0")/arch.sh")
DESTARCH=${2:-$SYSTEM_ARCH}
. /etc/os-release
@ -19,9 +19,9 @@ echo "Installing Google Chrome (stable) on ${ID} for ${DESTARCH^^}..."
set -e
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
/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."

View file

@ -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

View file

@ -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."

View file

@ -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

View file

@ -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
;;
*)

View file

@ -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."

View file

@ -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

View file

@ -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."

View file

@ -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

View file

@ -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...";

View file

@ -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..."

View file

@ -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"

View file

@ -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."

View file

@ -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."

View file

@ -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."