From 3b26e6ed999e3ebf913391d566cbf9459243c8df Mon Sep 17 00:00:00 2001 From: pdp8 Date: Wed, 24 Jul 2024 11:36:07 +0200 Subject: sync pictures from borg mount --- update-pictures.nu | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 update-pictures.nu (limited to 'update-pictures.nu') diff --git a/update-pictures.nu b/update-pictures.nu new file mode 100755 index 0000000..8d888f8 --- /dev/null +++ b/update-pictures.nu @@ -0,0 +1,33 @@ +#!/usr/bin/env nu + +$env.BORG_PASSPHRASE = (cat ~/.borg-sub2) +/etc/profiles/per-user/ch/bin/borg mount --last 1 ssh://u242757-sub2@u242757.your-storagebox.de:23/./borg ~/borg /home/ch/img + +do -i { # ensure that borg is unmounted to enable backups + let img_dir = ls ~/borg/*/home/ch/img | first | get name + let pub_dir = '/srv/media/pictures' + + cd $pub_dir + let published = (ls | get name) + cd $img_dir + # TODO overwrite modified images + # TODO add description + let all = (open motivs.json | where rating == 3 | get stack | each {|s| $s.0}) + let new = ($all | filter {|id| not ($id in $published) }) + print $new + cd backup + $new | each {|img| + let public = $'($pub_dir)/($img)' + echo $public + cp -uv $img $public + chmod u+w $public + # TODO add description + /etc/profiles/per-user/ch/bin/exiv2 rm $public + /etc/profiles/per-user/ch/bin/exiv2 -M "set Xmp.dc.creator pdp8@pdp8.info" -M "set Xmp.dc.rights © pdp8@pdp8.info" -M "set Xmp.dc.license http://creativecommons.org/licenses/by-sa/4.0/" -M "set Xmp.xmpRights.UsageTerms Creative Commons Attribution-ShareAlike 4.0 International License" -M "set Xmp.xmpRights.Marked True" -M "set Xmp.dc.description Original artwork available from pdp8@pdp8.info" $public + } + + cd /home/ch/src/publish/ + /home/ch/.nix-profile/bin/make www-pictures +} + +/run/wrappers/bin/umount ~/borg -- cgit v1.2.3