summaryrefslogtreecommitdiff
path: root/update-pictures.nu
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2024-07-24 11:36:07 +0200
committerpdp8 <pdp8@pdp8.info>2024-07-24 11:36:07 +0200
commit3b26e6ed999e3ebf913391d566cbf9459243c8df (patch)
tree436d3730d4d3cc4bd59dac94b6ea11fc58d4c2ce /update-pictures.nu
parent17da4aec12049d9dd4f599d71d7945fc7895472b (diff)
sync pictures from borg mount
Diffstat (limited to 'update-pictures.nu')
-rwxr-xr-xupdate-pictures.nu33
1 files changed, 33 insertions, 0 deletions
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