From 11dc16df6b99f9bdad450248fd9ae7c2bc69b8ab Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 28 Nov 2021 19:33:50 -0600 Subject: [PATCH] improved photoprism auto indexing --- PhotoPrismAutoIndex | 24 ++++-------------------- photoprism-index | 4 ++++ 2 files changed, 8 insertions(+), 20 deletions(-) create mode 100755 photoprism-index diff --git a/PhotoPrismAutoIndex b/PhotoPrismAutoIndex index df6dd10..43bf935 100755 --- a/PhotoPrismAutoIndex +++ b/PhotoPrismAutoIndex @@ -1,23 +1,7 @@ #!/bin/bash -# If started as root, then re-start as user "gavenkoa": -if [ "$(id -u)" -eq 0 ]; then - exec sudo -H -u $0 "$@" -fi +# To be used as a cron job -function notify-send2() { - #Detect the name of the display in use - local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)" - - #Detect the user using such display - local user=$(who | grep '('$display')' | awk '{print $1}' | head -n 1) - - #Detect the id of the user - local uid=$(id -u $user) - - sudo -u $user DISPLAY=$display DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$uid/bus notify-send -a rclone -h string:desktop-entry:alacritty "$@" -} - -notify-send2 "PhotoPrism autoindex" "Indexing started..." -sudo /usr/bin/docker exec -it photoprism_photoprism_1 /photoprism/bin/photoprism index -notify-send2 "PhotoPrism autoindex" "Indexing finished..." +echo `date` "| Updating index..." | tee -a logfile + +echo `date` "| Done!" | tee -a logfile \ No newline at end of file diff --git a/photoprism-index b/photoprism-index new file mode 100755 index 0000000..b3e68f6 --- /dev/null +++ b/photoprism-index @@ -0,0 +1,4 @@ +#!/bin/bash + +cd +docker-compose exec -T photoprism photoprism index