add functions to easily encrypt & decrypt age encrypted dotfiles

This commit is contained in:
Philip Henning 2025-10-07 10:21:37 +02:00
parent d99efa3a28
commit 641b71513d
2 changed files with 58 additions and 17 deletions

View file

@ -3,7 +3,8 @@ config:
create: true
dotpath: dotfiles
variables:
ageidentity: ${{HOME}}/.age/phg-age-dotfiles
ageidentity: "{{@@ env['HOME'] @@}}/.age/phg-age-dotfiles"
ageidentity_pub: "{{@@ ageidentity@@}}.pub"
SHELL_ERR_MESSAGE: \033[41;30m
SHELL_RESET_COLOR: \033[0m
trans_install:
@ -11,7 +12,7 @@ trans_install:
[[ -f {{@@ ageidentity @@}} ]] && age --decrypt -i {{@@ ageidentity @@}} -o {1} {0} || ([[ ! -f {{@@ _dotfile_abs_dst @@}} ]] && (echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}, cannot decrypt {0}, creating empty file instead{{@@ SHELL_RESET_COLOR @@}}"; echo "" > {1}) || (echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}, cannot decrypt {0}{{@@ SHELL_RESET_COLOR @@}}"; cp {{@@ _dotfile_abs_dst @@}} {1}))
trans_update:
_encrypt: |
[[ -f {{@@ ageidentity @@}}.pub ]] && cat {0} | age -a -R {{@@ ageidentity @@}}.pub > {1} || echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity @@}}.pub, cannot encrypt {0}{{@@ SHELL_RESET_COLOR @@}}"
[[ -f {{@@ ageidentity_pub @@}} ]] && cat {0} | age -a -R {{@@ ageidentity_pub @@}} > {1} || echo "{{@@ SHELL_ERR_MESSAGE @@}}Missing age identity file {{@@ ageidentity_pub @@}}, cannot encrypt {0}{{@@ SHELL_RESET_COLOR @@}}"
actions:
oh-my-zsh: |
[[ ! -d ${{HOME}}/.oh-my-zsh ]] && sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended || echo "do nothing" >/dev/null