install.fairie/dotfiles/.config/age/run_once_before_decrypt-private-key.sh.tmpl

13 lines
406 B
Bash

#!/bin/sh
if [ ! -f "$HOME/.config/age/headless.txt" ]; then
logg 'Generating age public key under `~/.config/age/key.txt`'
age-keygen > "$HOME/.config/age/headless.txt"
fi
if [ -f "{{ .chezmoi.sourceDir }}/key.txt.age" ]; then
# TODO
logg 'Decrypting age key'
age --decrypt --output "$HOME/.config/age/key.txt" "{{ .chezmoi.sourceDir }}/key.txt.age"
chmod 600 "$HOME/.config/age/key.txt"
fi