From 2d44ee234aa8a10ca1f05d6f3e7ca46a25f6cf9d Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Fri, 9 Jan 2026 10:01:06 +0100 Subject: [PATCH] Update photoprism config migration --- photoprism/README.md | 1 - .../rootfs/etc/cont-init.d/00-folders.sh | 7 +++--- .../rootfs/etc/cont-init.d/01-migrate.sh | 23 +++++++++++++++---- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/photoprism/README.md b/photoprism/README.md index a47e89ccc..d28d3d1f1 100644 --- a/photoprism/README.md +++ b/photoprism/README.md @@ -76,7 +76,6 @@ Configurations can be done through the app webUI, except for the following optio | `IMPORT_PATH` | str | `/share/photoprism/import` | Import files path | | `BACKUP_PATH` | str | `/share/photoprism/backup` | Backup storage path | | `UPLOAD_NSFW` | bool | `true` | Allow uploads that may be offensive | -| `CONFIG_LOCATION` | str | | Location of additional config.yaml | | `graphic_drivers` | list | | Graphics driver (mesa) | | `ingress_disabled` | bool | | Disable ingress for direct IP:port access | | `localdisks` | str | | Local drives to mount (e.g., `sda1,sdb1,MYNAS`) | diff --git a/photoprism/rootfs/etc/cont-init.d/00-folders.sh b/photoprism/rootfs/etc/cont-init.d/00-folders.sh index e81c5d7fc..01a5374cc 100755 --- a/photoprism/rootfs/etc/cont-init.d/00-folders.sh +++ b/photoprism/rootfs/etc/cont-init.d/00-folders.sh @@ -12,8 +12,7 @@ fi bashio::log.info "Preparing scripts" echo "... creating structure" -CONFIG_DIR="$(dirname "$(bashio::config "CONFIG_LOCATION")")" -mkdir -p "$CONFIG_DIR" +mkdir -p /config/photoprism mkdir -p \ /data/photoprism/originals \ /data/photoprism/import \ @@ -25,8 +24,8 @@ echo "... setting permissions" chmod -R 777 /data/photoprism chown -Rf photoprism:photoprism /data/photoprism chmod -Rf a+rwx /data/photoprism -chmod -R 777 "$CONFIG_DIR" -chown -Rf photoprism:photoprism "$CONFIG_DIR" +chmod -R 777 /config/photoprism +chown -Rf photoprism:photoprism /config/photoprism for line in BACKUP_PATH IMPORT_PATH ORIGINALS_PATH STORAGE_PATH; do mkdir -p "$line" chmod -R 777 "$line" diff --git a/photoprism/rootfs/etc/cont-init.d/01-migrate.sh b/photoprism/rootfs/etc/cont-init.d/01-migrate.sh index 49e0d75f3..170ed4261 100644 --- a/photoprism/rootfs/etc/cont-init.d/01-migrate.sh +++ b/photoprism/rootfs/etc/cont-init.d/01-migrate.sh @@ -3,12 +3,27 @@ set -e slug=photoprism +new_config_location="/config/photoprism/config.yaml" +new_config_dir="$(dirname "$new_config_location")" +mkdir -p "$new_config_dir" -if [ -d "/homeassistant/addons_config/$slug" ]; then - echo "Migrating /homeassistant/addons_config/$slug to /addon_configs/xxx-$slug" - cp -rnf /homeassistant/addons_config/"$slug"/. /config/ || true +if bashio::config.has_value "CONFIG_LOCATION"; then + old_config_location="$(bashio::config "CONFIG_LOCATION")" +else + old_config_location="/config/addons_config/photoprism/config.yaml" +fi +old_config_dir="$(dirname "$old_config_location")" + +if [ "$old_config_dir" != "$new_config_dir" ] && [ -d "$old_config_dir" ]; then + echo "Migrating $old_config_dir to /addon_configs/xxx-$slug" + cp -rnf "$old_config_dir"/. "$new_config_dir"/ || true echo "Migrated to internal config folder accessible at /addon_configs/xxx-$slug" \ - > "/homeassistant/addons_config/$slug/.migrate" + > "$old_config_dir/.migrate" +fi + +if [ "$old_config_location" != "$new_config_location" ]; then + bashio::log.info "Updating CONFIG_LOCATION to $new_config_location" + bashio::addon.option "CONFIG_LOCATION" "$new_config_location" fi if [ -d /config/addons_config ]; then