From 1ccc129bb6875230a40a6769b2638a2639e261de Mon Sep 17 00:00:00 2001 From: clerie Date: Fri, 14 Feb 2025 17:16:43 +0100 Subject: [PATCH] Add clerie-backup bundle --- bundles/uberspace-clerie-backup/items.py | 49 ++++++++++++++++++++++++ nodes.py | 1 + 2 files changed, 50 insertions(+) create mode 100644 bundles/uberspace-clerie-backup/items.py diff --git a/bundles/uberspace-clerie-backup/items.py b/bundles/uberspace-clerie-backup/items.py new file mode 100644 index 0000000..5a8166b --- /dev/null +++ b/bundles/uberspace-clerie-backup/items.py @@ -0,0 +1,49 @@ +uberspaceify = repo.libs.uberspace.Uberspaceify(node) + +files = uberspaceify.files({ + f'/home/{node.username}/.bwdownloads/clerie-backup.sh': { + "content_type": "download", + "source": "https://git.clerie.de/clerie/nixfiles/raw/commit/d17c2855ac0138c5009350d2539954c701df4eec/pkgs/clerie-backup/clerie-backup.sh", + "content_hash": "c0b68e6a4979c5ddcaaec10053bd8a1223c0b808", + }, + f'/home/{node.username}/.bwdownloads/restic.bz2': { + "content_type": "download", + "source": "https://github.com/restic/restic/releases/download/v0.17.3/restic_0.17.3_linux_amd64.bz2", + "content_hash": "cd4336cc86ec4e86decff5c995f08908844120c4", + "triggers": [ + "action:install_restic", + ], + }, +}) + +actions = { + "clerie_backup_exists": { + "command": 'true', + "unless": f'[[ -f "/home/{node.username}/bin/clerie-backup" && -x "/home/{node.username}/bin/clerie-backup" ]]', + "triggers": [ + "action:install_clerie_backup", + ], + }, + "install_clerie_backup": { + "command": ( + f'sed ' + f'-e "s#/etc/clerie-backup#/home/{node.username}/.config/clerie-backup#g" ' + f'-e "s#/var/cache/restic#/home/{node.username}/.cache/restic#g" ' + f'"/home/{node.username}/.bwdownloads/clerie-backup.sh" ' + f'> /home/{node.username}/bin/clerie-backup ' + f'&& chmod +x /home/{node.username}/bin/clerie-backup' + ), + "triggered": True, + }, + "restic_exists": { + "command": 'true', + "unless": f'[[ -f "/home/{node.username}/bin/restic" && -x "/home/{node.username}/bin/restic" ]]', + "triggers": [ + "action:install_restic", + ], + }, + "install_restic": { + "command": f'bzip2 -dkc /home/{node.username}/.bwdownloads/restic.bz2 > /home/{node.username}/bin/restic && chmod +x /home/{node.username}/bin/restic', + "triggered": True, + }, +} diff --git a/nodes.py b/nodes.py index bd2eab5..444e6cc 100644 --- a/nodes.py +++ b/nodes.py @@ -4,6 +4,7 @@ nodes = uberspaceify.nodes({ "clerie.uber.space": { "bundles": ( "uberspace-redirect-clerie", + "uberspace-clerie-backup", ), }, "cleriewi.uber.space": {