From b79edf73ae7513bf4b4398299b07a9ae60377076 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 16 Feb 2025 09:42:29 +0100 Subject: [PATCH] Add custom library path --- immich/CHANGELOG.md | 2 +- immich/config.json | 3 +- immich/rootfs/etc/cont-init.d/20-folders.sh | 45 ++++++++++++++++----- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/immich/CHANGELOG.md b/immich/CHANGELOG.md index 82b5587bf..2db7f6dc4 100644 --- a/immich/CHANGELOG.md +++ b/immich/CHANGELOG.md @@ -1,10 +1,10 @@ -## 1.126.1-4 (15-02-2025) - RISK OF BREAKING CHANGE : backup both immich & postgres before starting - RISK OF BREAKING CHANGE : rewrite and improve database creation tool using addon options (overwritting manual database creation) - SECURITY FIX : avoid hardcoding the postgres root password and change it if was already applied - Ensure host is reachable before starting - Autocorrect homeassistant.local to local ip - Align configuration with /addon_configs +- NEW FUNCTION : allow to define a library path outside of the data location. For example, if you specify /mnt/NAS/MyPictures as "library_location", and /mnt/NAS/Immich as "data_location", it will then create the whole structure in /mnt/NAS/Immich including the /mnt/NAS/Immich/library. However, this will just be a symlink to /mnt/NAS/MyPictures ; allowing people to still manage their hard drives in a more linear manner ## 1.126.1 (15-02-2025) - Update to latest version from imagegenius/docker-immich (changelog : https://github.com/imagegenius/docker-immich/releases) diff --git a/immich/config.json b/immich/config.json index 5b6630361..5a062e3d4 100644 --- a/immich/config.json +++ b/immich/config.json @@ -132,6 +132,7 @@ "cifspassword": "str?", "cifsusername": "str?", "data_location": "str", + "library_location": "str?", "localdisks": "str?", "networkdisks": "str?" }, @@ -141,6 +142,6 @@ "slug": "immich", "udev": true, "url": "https://github.com/alexbelgium/hassio-addons", - "version": "1.126.1-4", + "version": "1.126.1-5", "webui": "http://[HOST]:[PORT:8080]" } diff --git a/immich/rootfs/etc/cont-init.d/20-folders.sh b/immich/rootfs/etc/cont-init.d/20-folders.sh index 16fc02cc8..7352d0c7f 100755 --- a/immich/rootfs/etc/cont-init.d/20-folders.sh +++ b/immich/rootfs/etc/cont-init.d/20-folders.sh @@ -2,6 +2,21 @@ # shellcheck shell=bash set -e +###################### +# GENERAL PARAMETERS # +###################### + +if bashio::config.has_value "PUID"; then + PUID="$(bashio::config 'PUID')" +else + PUID=0 +fi +if bashio::config.has_value "PGID"; then + PGID="$(bashio::config 'PGID')" +else + PGID=0 +fi + ########################## # MIGRATIONS AND UPDATES # ########################## @@ -15,17 +30,6 @@ fi # DATA_LOCATION # ################# -if bashio::config.has_value "PUID"; then - PUID="$(bashio::config 'PUID')" -else - PUID=0 -fi -if bashio::config.has_value "PGID"; then - PGID="$(bashio::config 'PGID')" -else - PGID=0 -fi - bashio::log.info "Setting data location" DATA_LOCATION="$(bashio::config 'data_location')" export IMMICH_MEDIA_LOCATION="$DATA_LOCATION" @@ -54,6 +58,25 @@ chown -R "$PUID":"$PGID" "$REVERSE_GEOCODING_DUMP_DIRECTORY" chown -R "$PUID":"$PGID" /data chmod 777 /data +#################### +# LIBRARY LOCATION # +#################### + +if bashio::config.has_value "library_location"; then + LIBRARY_LOCATION="$(bashio::config 'library_location')" + bashio::log.info "Setting library location to $LIBRARY_LOCATION. This will not move any of your files, you'll need to do this manually" + mkdir -p "$LIBRARY_LOCATION" + chown -R "$PUID":"$PGID" "$LIBRARY_LOCATION" + if [ -d "$DATA_LOCATION/library" ] && [ ! -L "$DATA_LOCATION/library" ] && [ "$(ls -A "$DATA_LOCATION/library")" ]; then + bashio::log.yellow "-------------------------------" + bashio::log.warning "Library folder in $DATA_LOCATION/library already exists, is a real folder, and is not empty. Moving to $DATA_LOCATION/library_old" + bashio::log.yellow "-------------------------------" + mv "$DATA_LOCATION/library" "$DATA_LOCATION/library_old" + sleep 5 + fi + ln -sf "$LIBRARY_LOCATION" "$DATA_LOCATION"/library +fi + ################## # REDIS LOCATION # ##################