2022-11-24 21:05:02 -08:00
{{- $ bwAuthenticated = eq (fromJson (output "bw" "status")).status "authenticated" }}
{{- if $ bwAuthenticated -}}
{{- writeToStdout "BitWarden is authenticated!" -}}
{{- (bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private").notes -}}
Update dotfiles/.local/share/chezmoi/home/dot_ssh/create_encrypted_private_readonly_private_id_rsa.tmpl, dotfiles/.local/share/chezmoi/home/dot_ssh/run_onchanges_after_generate-public-keys, dotfiles/.local/share/chezmoi/system-linux/etc/systemd/system/r2-{{ .user.username }}.service.tmpl, dotfiles/.local/share/chezmoi/system-linux/usr/local/bin/executable_rclone-mount, dotfiles/.local/share/chezmoi/home/dot_cache/readonly_rclone/.gitkeep, dotfiles/.local/share/chezmoi/system-linux/var/cache/readonly_rclone/remove_dot_gitkeep, dotfiles/.local/share/chezmoi/system-linux/etc/rcloneignore, dotfiles/.local/share/chezmoi/system-linux/etc/systemd/system/r2-docker.service, dotfiles/.local/share/chezmoi/system-linux/mnt/private_r2-docker/remove_dot_gitkeep, dotfiles/.local/share/chezmoi/system-linux/var/log/user/run_onchange_after-symlink-user-logs, dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl, dotfiles/.local/share/chezmoi/home/dot_local/log/remove_dot_gitkeep, dotfiles/.local/share/chezmoi/home/private_dot_config/rclone/merge_rclone.conf
Deleted dotfiles/.local/share/chezmoi/home/dot_ssh/id_rsa.pub
2022-11-24 19:04:16 -08:00
{{- else -}}
{{- $ sshLocation = (joinPath .chezmoi.homeDir ".ssh" "id_rsa") -}}
{{- if not (stat $ sshLocation ) -}}
{{- $ sshKeygen = (output "ssh-keygen" "-b" "4096" "-t" "rsa" "-f" $ sshLocation "-q" "-N" }}
{{- writeToStdout "Generated new SSH key since none were present and could not connect to BitWarden. It will be encrypted and included in your source." -}}
{{- end -}}
{{- include $ sshLocation }}
{{ end }}