diff --git a/ct/immich.sh b/ct/immich.sh index d96bbd99d..f79cca3b8 100644 --- a/ct/immich.sh +++ b/ct/immich.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: vhsdream # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE @@ -52,9 +52,7 @@ Package: * Pin:release a=testing Pin-Priority: 450 EOF - if [[ -f /etc/apt/preferences.d/immich ]]; then - rm /etc/apt/preferences.d/immich - fi + [[ -f /etc/apt/preferences.d/immich ]] && rm /etc/apt/preferences.d/immich $STD apt update msg_ok "Added Debian Testing repo" fi @@ -69,8 +67,7 @@ EOF msg_info "Installing Mise" curl -fSs https://mise.jdx.dev/gpg-key.pub | tee /etc/apt/keyrings/mise-archive-keyring.pub 1>/dev/null echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.pub arch=amd64] https://mise.jdx.dev/deb stable main" >/etc/apt/sources.list.d/mise.list - $STD apt update - $STD apt install -y mise + ensure_dependencies mise msg_ok "Installed Mise" fi @@ -91,7 +88,7 @@ EOF curl -fsSLO "$url" done $STD apt-mark unhold libigdgmm12 - $STD apt install -y ./libigdgmm12*.deb + $STD apt install -y --allow-downgrades ./libigdgmm12*.deb rm ./libigdgmm12*.deb $STD apt install -y ./*.deb rm ./*.deb @@ -112,29 +109,31 @@ EOF msg_ok "Image-processing libraries up to date" fi - RELEASE="v2.5.2" - if check_for_gh_tag "immich" "immich-app/immich" "${RELEASE}"; then + RELEASE="2.5.2" + if check_for_gh_release "immich" "immich-app/immich" "${RELEASE}"; then + if [[ $(cat ~/.immich) > "2.5.1" ]]; then + msg_info "Enabling Maintenance Mode" + cd /opt/immich/app/bin + $STD ./immich-admin enable-maintenance-mode + export MAINT_MODE=1 + $STD cd - + msg_ok "Enabled Maintenance Mode" + fi msg_info "Stopping Services" systemctl stop immich-web systemctl stop immich-ml msg_ok "Stopped Services" VCHORD_RELEASE="0.5.3" - if [[ ! -f ~/.vchord_version ]] || [[ "$VCHORD_RELEASE" != "$(cat ~/.vchord_version)" ]]; then - msg_info "Upgrading VectorChord" - curl -fsSL "https://github.com/tensorchord/vectorchord/releases/download/${VCHORD_RELEASE}/postgresql-16-vchord_${VCHORD_RELEASE}-1_amd64.deb" -o vchord.deb - $STD apt install -y ./vchord.deb + [[ -f ~/.vchord_version ]] && mv ~/.vchord_version ~/.vectorchord + if check_for_gh_release "VectorChord" "tensorchord/VectorChord" "${VCHORD_RELEASE}"; then + fetch_and_deploy_gh_release "VectorChord" "tensorchord/VectorChord" "binary" "${VCHORD_RELEASE}" "/tmp" "postgresql-16-vchord_*_amd64.deb" systemctl restart postgresql $STD sudo -u postgres psql -d immich -c "ALTER EXTENSION vector UPDATE;" $STD sudo -u postgres psql -d immich -c "ALTER EXTENSION vchord UPDATE;" $STD sudo -u postgres psql -d immich -c "REINDEX INDEX face_index;" $STD sudo -u postgres psql -d immich -c "REINDEX INDEX clip_index;" - echo "$VCHORD_RELEASE" >~/.vchord_version - rm ./vchord.deb - msg_ok "Upgraded VectorChord to v${VCHORD_RELEASE}" - fi - if ! dpkg -l | grep -q ccache; then - $STD apt install -yqq ccache fi + ensure_dependencies ccache INSTALL_DIR="/opt/${APP}" UPLOAD_DIR="$(sed -n '/^IMMICH_MEDIA_LOCATION/s/[^=]*=//p' /opt/immich/.env)" @@ -144,7 +143,7 @@ EOF ML_DIR="${APP_DIR}/machine-learning" GEO_DIR="${INSTALL_DIR}/geodata" - cp "$ML_DIR"/ml_start.sh "$INSTALL_DIR" + [[ -f "$ML_DIR"/ml_start.sh ]] && cp "$ML_DIR"/ml_start.sh "$INSTALL_DIR" if grep -qs "set -a" "$APP_DIR"/bin/start.sh; then cp "$APP_DIR"/bin/start.sh "$INSTALL_DIR" else @@ -165,7 +164,7 @@ EOF rm -rf "${APP_DIR:?}"/* ) - CLEAN_INSTALL=1 fetch_and_deploy_gh_release "immich" "immich-app/immich" "tag" "${RELEASE}" "$SRC_DIR" + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "immich" "immich-app/immich" "tarball" "v${RELEASE}" "$SRC_DIR" msg_info "Updating Immich web and microservices" cd "$SRC_DIR"/server @@ -180,7 +179,7 @@ EOF export SHARP_FORCE_GLOBAL_LIBVIPS=true $STD pnpm --filter immich --frozen-lockfile --prod --no-optional deploy "$APP_DIR" cp "$APP_DIR"/package.json "$APP_DIR"/bin - sed -i 's|^start|./start|' "$APP_DIR"/bin/immich-admin + sed -i "s|^start|${APP_DIR}/bin/start|" "$APP_DIR"/bin/immich-admin # openapi & web build cd "$SRC_DIR" @@ -196,8 +195,7 @@ EOF $STD pnpm --filter @immich/sdk --filter @immich/cli --frozen-lockfile install $STD pnpm --filter @immich/sdk --filter @immich/cli build $STD pnpm --filter @immich/cli --prod --no-optional deploy "$APP_DIR"/cli - cd "$APP_DIR" - mv "$INSTALL_DIR"/start.sh "$APP_DIR"/bin + [[ -f "$INSTALL_DIR"/start.sh ]] && mv "$INSTALL_DIR"/start.sh "$APP_DIR"/bin # plugins cd "$SRC_DIR" @@ -217,16 +215,9 @@ EOF export VIRTUAL_ENV="${ML_DIR}"/ml-venv if [[ -f ~/.openvino ]]; then msg_info "Updating HW-accelerated machine-learning" - # Remove old venv if Python version changed (3.12 -> 3.13) - if [[ -d "${VIRTUAL_ENV}" ]] && ! "${VIRTUAL_ENV}/bin/python3" --version 2>/dev/null | grep -q "3.13"; then - rm -rf "${VIRTUAL_ENV}" - fi - $STD sudo --preserve-env=VIRTUAL_ENV -nu immich uv sync --extra openvino --no-dev --active --link-mode copy -n -p python3.13 --managed-python - patchelf --clear-execstack "${VIRTUAL_ENV}/lib/python3.13/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-313-x86_64-linux-gnu.so" - # Add workaround for onnxruntime-openvino 1.23.x crash if not present - if ! grep -q "MACHINE_LEARNING_OPENVINO_NUM_THREADS" "$INSTALL_DIR/.env" 2>/dev/null; then - sed -i '/MACHINE_LEARNING_CACHE_FOLDER/a ## - For OpenVINO only - workaround for onnxruntime-openvino 1.23.x crash\n## - See: https://github.com/immich-app/immich/pull/11240\nMACHINE_LEARNING_OPENVINO_NUM_THREADS=$(nproc)' "$INSTALL_DIR/.env" - fi + $STD uv add --no-sync --optional openvino onnxruntime-openvino==1.20.0 --active -n -p python3.12 --managed-python + $STD sudo --preserve-env=VIRTUAL_ENV -nu immich uv sync --extra openvino --no-dev --active --link-mode copy -n -p python3.12 --managed-python + patchelf --clear-execstack "${VIRTUAL_ENV}/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-312-x86_64-linux-gnu.so" msg_ok "Updated HW-accelerated machine-learning" else msg_info "Updating machine-learning" @@ -235,10 +226,8 @@ EOF fi cd "$SRC_DIR" cp -a machine-learning/{ann,immich_ml} "$ML_DIR" - mv "$INSTALL_DIR"/ml_start.sh "$ML_DIR" - if [[ -f ~/.openvino ]]; then - sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py - fi + [[ -f "$INSTALL_DIR"/ml_start.sh ]] && mv "$INSTALL_DIR"/ml_start.sh "$ML_DIR" + [[ -f ~/.openvino ]] && sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py ln -sf "$APP_DIR"/resources "$INSTALL_DIR" cd "$APP_DIR" grep -rl /usr/src | xargs -n1 sed -i "s|\/usr/src|$INSTALL_DIR|g" @@ -247,8 +236,18 @@ EOF ln -s "${UPLOAD_DIR:-/opt/immich/upload}" "$APP_DIR"/upload ln -s "${UPLOAD_DIR:-/opt/immich/upload}" "$ML_DIR"/upload ln -s "$GEO_DIR" "$APP_DIR" + [[ ! -f /usr/bin/immich ]] && ln -sf "$APP_DIR"/cli/bin/immich /usr/bin/immich + [[ ! -f /usr/bin/immich-admin ]] && ln -sf "$APP_DIR"/bin/immich-admin /usr/bin/immich-admin chown -R immich:immich "$INSTALL_DIR" + if [[ "${MAINT_MODE:-0}" == 1 ]]; then + msg_info "Disabling Maintenance Mode" + cd /opt/immich/app/bin + $STD ./immich-admin disable-maintenance-mode + unset MAINT_MODE + $STD cd - + msg_ok "Disabled Maintenance Mode" + fi systemctl restart immich-ml immich-web msg_ok "Updated successfully!" fi @@ -262,7 +261,7 @@ function compile_libjxl() { : "${LIBJXL_REVISION:=$(jq -cr '.revision' "$BASE_DIR"/server/sources/libjxl.json)}" if [[ "$LIBJXL_REVISION" != "$(grep 'libjxl' ~/.immich_library_revisions | awk '{print $2}')" ]]; then msg_info "Recompiling libjxl" - if [[ -d "$SOURCE" ]]; then rm -rf "$SOURCE"; fi + [[ -d "$SOURCE" ]] && rm -rf "$SOURCE" $STD git clone https://github.com/libjxl/libjxl.git "$SOURCE" cd "$SOURCE" $STD git reset --hard "$LIBJXL_REVISION" @@ -302,14 +301,11 @@ function compile_libjxl() { function compile_libheif() { SOURCE=${SOURCE_DIR}/libheif - if ! dpkg -l | grep -q libaom; then - $STD apt install -y libaom-dev - local update="required" - fi + ensure_dependencies libaom-dev : "${LIBHEIF_REVISION:=$(jq -cr '.revision' "$BASE_DIR"/server/sources/libheif.json)}" if [[ "${update:-}" ]] || [[ "$LIBHEIF_REVISION" != "$(grep 'libheif' ~/.immich_library_revisions | awk '{print $2}')" ]]; then msg_info "Recompiling libheif" - if [[ -d "$SOURCE" ]]; then rm -rf "$SOURCE"; fi + [[ -d "$SOURCE" ]] && rm -rf "$SOURCE" $STD git clone https://github.com/strukturag/libheif.git "$SOURCE" cd "$SOURCE" $STD git reset --hard "$LIBHEIF_REVISION" @@ -325,7 +321,7 @@ function compile_libheif() { -DWITH_X265=OFF \ -DWITH_EXAMPLES=OFF \ .. - $STD make install -j "$(nproc)" + $STD make install -j"$(nproc)" ldconfig /usr/local/lib $STD make clean cd "$STAGING_DIR" @@ -340,7 +336,7 @@ function compile_libraw() { : "${LIBRAW_REVISION:=$(jq -cr '.revision' "$BASE_DIR"/server/sources/libraw.json)}" if [[ "$LIBRAW_REVISION" != "$(grep 'libraw' ~/.immich_library_revisions | awk '{print $2}')" ]]; then msg_info "Recompiling libraw" - if [[ -d "$SOURCE" ]]; then rm -rf "$SOURCE"; fi + [[ -d "$SOURCE" ]] && rm -rf "$SOURCE" $STD git clone https://github.com/libraw/libraw.git "$SOURCE" cd "$SOURCE" $STD git reset --hard "$LIBRAW_REVISION" @@ -362,7 +358,7 @@ function compile_imagemagick() { if [[ "$IMAGEMAGICK_REVISION" != "$(grep 'imagemagick' ~/.immich_library_revisions | awk '{print $2}')" ]] || ! grep -q 'DMAGICK_LIBRAW' /usr/local/lib/ImageMagick-7*/config-Q16HDRI/configure.xml; then msg_info "Recompiling ImageMagick" - if [[ -d "$SOURCE" ]]; then rm -rf "$SOURCE"; fi + [[ -d "$SOURCE" ]] && rm -rf "$SOURCE" $STD git clone https://github.com/ImageMagick/ImageMagick.git "$SOURCE" cd "$SOURCE" $STD git reset --hard "$IMAGEMAGICK_REVISION" @@ -382,7 +378,7 @@ function compile_libvips() { : "${LIBVIPS_REVISION:=$(jq -cr '.revision' "$BASE_DIR"/server/sources/libvips.json)}" if [[ "$LIBVIPS_REVISION" != "$(grep 'libvips' ~/.immich_library_revisions | awk '{print $2}')" ]]; then msg_info "Recompiling libvips" - if [[ -d "$SOURCE" ]]; then rm -rf "$SOURCE"; fi + [[ -d "$SOURCE" ]] && rm -rf "$SOURCE" $STD git clone https://github.com/libvips/libvips.git "$SOURCE" cd "$SOURCE" $STD git reset --hard "$LIBVIPS_REVISION" diff --git a/install/immich-install.sh b/install/immich-install.sh index d0625e4cf..b86058c12 100644 --- a/install/immich-install.sh +++ b/install/immich-install.sh @@ -149,12 +149,7 @@ NODE_VERSION="24" NODE_MODULE="pnpm@${PNPM_VERSION}" setup_nodejs PG_VERSION="16" PG_MODULES="pgvector" setup_postgresql VCHORD_RELEASE="0.5.3" -msg_info "Installing Vectorchord v${VCHORD_RELEASE}" -curl -fsSL "https://github.com/tensorchord/VectorChord/releases/download/${VCHORD_RELEASE}/postgresql-16-vchord_${VCHORD_RELEASE}-1_amd64.deb" -o vchord.deb -$STD apt install -y ./vchord.deb -rm vchord.deb -echo "$VCHORD_RELEASE" >~/.vchord_version -msg_ok "Installed Vectorchord v${VCHORD_RELEASE}" +fetch_and_deploy_gh_release "VectorChord" "tensorchord/VectorChord" "binary" "${VCHORD_RELEASE}" "/tmp" "postgresql-16-vchord_*_amd64.deb" sed -i -e "/^#shared_preload/s/^#//;/^shared_preload/s/''/'vchord.so'/" /etc/postgresql/16/main/postgresql.conf systemctl restart postgresql.service @@ -228,7 +223,7 @@ $STD cmake --preset=release-noplugins \ -DWITH_X265=OFF \ -DWITH_EXAMPLES=OFF \ .. -$STD make install -j "$(nproc)" +$STD make install -j"$(nproc)" ldconfig /usr/local/lib $STD make clean cd "$STAGING_DIR" @@ -293,10 +288,9 @@ APP_DIR="${INSTALL_DIR}/app" PLUGIN_DIR="${APP_DIR}/corePlugin" ML_DIR="${APP_DIR}/machine-learning" GEO_DIR="${INSTALL_DIR}/geodata" -mkdir -p "$INSTALL_DIR" mkdir -p {"${APP_DIR}","${UPLOAD_DIR}","${GEO_DIR}","${INSTALL_DIR}"/cache} -fetch_and_deploy_gh_release "immich" "immich-app/immich" "tag" "v2.5.2" "$SRC_DIR" +fetch_and_deploy_gh_release "immich" "immich-app/immich" "tarball" "v2.5.2" "$SRC_DIR" msg_info "Installing Immich (patience)" @@ -312,7 +306,7 @@ unset SHARP_IGNORE_GLOBAL_LIBVIPS export SHARP_FORCE_GLOBAL_LIBVIPS=true $STD pnpm --filter immich --frozen-lockfile --prod --no-optional deploy "$APP_DIR" cp "$APP_DIR"/package.json "$APP_DIR"/bin -sed -i 's|^start|./start|' "$APP_DIR"/bin/immich-admin +sed -i "s|^start|${APP_DIR}/bin/start|" "$APP_DIR"/bin/immich-admin # openapi & web build cd "$SRC_DIR" @@ -347,8 +341,9 @@ mkdir -p "$ML_DIR" && chown -R immich:immich "$INSTALL_DIR" export VIRTUAL_ENV="${ML_DIR}/ml-venv" if [[ -f ~/.openvino ]]; then msg_info "Installing HW-accelerated machine-learning" - $STD sudo --preserve-env=VIRTUAL_ENV -nu immich uv sync --extra openvino --no-dev --active --link-mode copy -n -p python3.13 --managed-python - patchelf --clear-execstack "${VIRTUAL_ENV}/lib/python3.13/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-313-x86_64-linux-gnu.so" + $STD uv add --no-sync --optional openvino onnxruntime-openvino==1.20.0 --active -n -p python3.12 --managed-python + $STD sudo --preserve-env=VIRTUAL_ENV -nu immich uv sync --extra openvino --no-dev --active --link-mode copy -n -p python3.12 --managed-python + patchelf --clear-execstack "${VIRTUAL_ENV}/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_pybind11_state.cpython-312-x86_64-linux-gnu.so" msg_ok "Installed HW-accelerated machine-learning" else msg_info "Installing machine-learning" @@ -357,9 +352,7 @@ else fi cd "$SRC_DIR" cp -a machine-learning/{ann,immich_ml} "$ML_DIR" -if [[ -f ~/.openvino ]]; then - sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py -fi +[[ -f ~/.openvino ]] && sed -i "/intra_op/s/int = 0/int = os.cpu_count() or 0/" "$ML_DIR"/immich_ml/config.py ln -sf "$APP_DIR"/resources "$INSTALL_DIR" cd "$APP_DIR" @@ -404,10 +397,9 @@ DB_VECTOR_EXTENSION=vectorchord REDIS_HOSTNAME=127.0.0.1 IMMICH_MACHINE_LEARNING_URL=http://127.0.0.1:3003 MACHINE_LEARNING_CACHE_FOLDER=${INSTALL_DIR}/cache -## - For OpenVINO only - workaround for onnxruntime-openvino 1.23.x crash -## - See: https://github.com/immich-app/immich/pull/11240 -MACHINE_LEARNING_OPENVINO_NUM_THREADS=$(nproc) -## - Uncomment below to increase inference speed while reducing accuracy +## - For OpenVINO only - uncomment below to increase +## - inference speed while reducing accuracy +## - Default is FP32 # MACHINE_LEARNING_OPENVINO_PRECISION=FP16 IMMICH_MEDIA_LOCATION=${UPLOAD_DIR} @@ -434,9 +426,11 @@ set +a /usr/bin/node ${APP_DIR}/dist/main.js "\$@" EOF chmod +x "$ML_DIR"/ml_start.sh "$APP_DIR"/bin/start.sh -cat </etc/systemd/system/"${APPLICATION}"-web.service +ln -sf "$APP_DIR"/cli/bin/immich /usr/bin/immich +ln -sf "$APP_DIR"/bin/immich-admin /usr/bin/immich-admin +cat </etc/systemd/system/immich-web.service [Unit] -Description=${APPLICATION} Web Service +Description=Immich Web Service After=network.target Requires=redis-server.service Requires=postgresql.service @@ -458,9 +452,9 @@ StandardError=append:/var/log/immich/web.log [Install] WantedBy=multi-user.target EOF -cat </etc/systemd/system/"${APPLICATION}"-ml.service +cat </etc/systemd/system/immich-ml.service [Unit] -Description=${APPLICATION} Machine-Learning +Description=Immich Machine-Learning After=network.target [Service] @@ -480,7 +474,7 @@ StandardError=append:/var/log/immich/ml.log WantedBy=multi-user.target EOF chown -R immich:immich "$INSTALL_DIR" /var/log/immich -systemctl enable -q --now "$APPLICATION"-ml.service "$APPLICATION"-web.service +systemctl enable -q --now immich-ml.service immich-web.service msg_ok "Modified user, created env file, scripts and services" motd_ssh