1
0
Fork 0
mirror of https://github.com/SinTan1729/random.git synced 2024-12-27 05:28:37 -06:00

improved photoprism auto indexing

This commit is contained in:
Sayantan Santra 2021-11-28 19:33:50 -06:00
parent 68899bb73c
commit 11dc16df6b
2 changed files with 8 additions and 20 deletions

View file

@ -1,23 +1,7 @@
#!/bin/bash #!/bin/bash
# If started as root, then re-start as user "gavenkoa": # To be used as a cron job
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u <user> $0 "$@"
fi
function notify-send2() { echo `date` "| Updating index..." | tee -a logfile
#Detect the name of the display in use <location-of-photoprism-index-script>
local display=":$(ls /tmp/.X11-unix/* | sed 's#/tmp/.X11-unix/X##' | head -n 1)" echo `date` "| Done!" | tee -a logfile
#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..."

4
photoprism-index Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
cd <photoprism-folder-location>
docker-compose exec -T photoprism photoprism index