diff --git a/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl b/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl index d69ffab1..afd04a2f 100644 --- a/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl +++ b/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl @@ -13,9 +13,11 @@ {{- $githubUsername := "ProfessorManhattan" -}} {{- $githubReadToken := "" -}} {{- $gitlabReadToken := "" -}} +{{- $locale := (output ("echo" "$LANG")) }} {{- $ngrokAuthToken := "" -}} {{- $slackApiToken := "" -}} {{- $tabbySyncToken := "" -}} +{{- $timezone := "" -}} {{- $toolchains := list "docker" "iac" "java" "kubernetes" "node" "python" "rust" "extra" -}} {{- $data := . }} @@ -96,6 +98,8 @@ {{- end }} {{- $domain = promptStringOnce $data.user "domain" "Domain" $domain -}} +{{- $locale = promptStringOnce $data.user "locale" "locale" "Locale" $locale -}} +{{- $timezone = promptStringOnce $data.user "timezone" "Timezone" $timezone -}} {{- $cloudflareUsername = promptStringOnce $data.user "cloudflareUsername" "CloudFlare E-Mail" $email -}} {{- $cloudflareToken = promptStringOnce $data.user "cloudflareToken" "CloudFlare API Token" $cloudflareToken -}} {{- $gitlabReadToken = promptStringOnce $data.user "gitlabReadToken" "GitLab read-only token (See: https://github.com/gabrie30/ghorg#scm-provider-setup)" $gitlabReadToken }} @@ -127,6 +131,7 @@ data: family: "{{ .chezmoi.os }}" id: "{{ get .chezmoi.osRelease "id" | default .chezmoi.os }}" home: "{{ .chezmoi.homeDir }}" + homeParentFolder: "{{ if eq .chezmoi.os "linux" }}/home{{ else if eq .chezmoi.os "darwin" }}/Users{{ else }}C:\Users{{ end }}" type: "{{ $chassisType }}" work: {{ $work }} restricted: {{ $restricted }} @@ -138,14 +143,17 @@ data: user: email: "{{ $email }}" name: "{{ $name }}" - username: 'Betelgeuse' + username: "{{ output ("echo" "$USER") }} domain: "{{ $domain }}" gmailAddress: "{{ $gmailAddress }}" gmailAddressAppPassword: "{{ $gmailAddressAppPassword }}" githubUsername: "{{ $githubUsername }}" - locale: "en_US" - timezone: "America/New_York" + locale: "{{ $locale }}" + timezone: "{{ $timezone }}" CLOUDFLARE_USERNAME: "{{ $cloudflareUsername }}" + CLOUDFLARE_ACCESS_KEY_ID: "{{ $cloudflareAccessKeyId }}" + CLOUDFLARE_SECRET_ACCESS_KEY: "{{ $cloudflareSecretAccessKey }}" + CLOUDFLARE_R2_ACCOUNT_ID: "{{ $cloudflareR2AccountId }}" GITHUB_READ_TOKEN: "{{ $githubReadToken }}" GITLAB_READ_TOKEN: "{{ $gitlabReadToken }}" NGROK_AUTH_TOKEN: "{{ $ngrokAuthToken }}" @@ -158,9 +166,6 @@ git: autoCommit: true autoPush: true scriptEnv: - CLOUDFLARE_ACCESS_KEY_ID: "{{ $cloudflareAccessKeyId }}" - CLOUDFLARE_SECRET_ACCESS_KEY: "{{ $cloudflareSecretAccessKey }}" - CLOUDFLARE_R2_ACCOUNT_ID: "{{ $cloudflareR2AccountId }}" LEXICON_CLOUDFLARE_USERNAME: "{{ $cloudflareUsername }}" LEXICON_CLOUDFLARE_TOKEN: "{{ $cloudflareToken }}" textconv: diff --git a/dotfiles/.local/share/chezmoi/home/dot_cache/readonly_rclone/.gitkeep b/dotfiles/.local/share/chezmoi/home/dot_cache/readonly_rclone/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dotfiles/.local/share/chezmoi/home/dot_local/log/remove_dot_gitkeep b/dotfiles/.local/share/chezmoi/home/dot_local/log/remove_dot_gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dotfiles/.local/share/chezmoi/home/dot_ssh/create_encrypted_private_readonly_private_id_rsa.tmpl b/dotfiles/.local/share/chezmoi/home/dot_ssh/create_encrypted_private_readonly_private_id_rsa.tmpl new file mode 100644 index 00000000..46e895af --- /dev/null +++ b/dotfiles/.local/share/chezmoi/home/dot_ssh/create_encrypted_private_readonly_private_id_rsa.tmpl @@ -0,0 +1,10 @@ +{{- if ( bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private" ).notes -}} +{{- ( bitwarden "item" "dev.betelgeuse.ssh.personal.id_rsa.private" ).notes -}} +{{- 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 }} diff --git a/dotfiles/.local/share/chezmoi/home/dot_ssh/private_id_rsa.tmpl b/dotfiles/.local/share/chezmoi/home/dot_ssh/private_id_rsa.tmpl deleted file mode 100644 index d5d9af98..00000000 --- a/dotfiles/.local/share/chezmoi/home/dot_ssh/private_id_rsa.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ ( bitwarden "item" "dev.muniftanjim.ssh.personal.id_rsa.private" ).notes }} diff --git a/dotfiles/.local/share/chezmoi/home/dot_ssh/run_onchanges_after_generate-public-keys b/dotfiles/.local/share/chezmoi/home/dot_ssh/run_onchanges_after_generate-public-keys new file mode 100644 index 00000000..c6f0df22 --- /dev/null +++ b/dotfiles/.local/share/chezmoi/home/dot_ssh/run_onchanges_after_generate-public-keys @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +{{ $sshFiles = (output "find" "$HOME/.ssh" "-type" "f") }} +{{ range $sshFile := $sshFiles }} +# .ssh hash: {{ include ".ssh" | sha256sum }} +# {{ $sshFile }} hash: {{ include $sshFile | sha256sum }} +{{ end }} + +logg 'Ensuring RSA public keys are present' +find "$HOME/.ssh" -type f | while read FILE; do + if [ ! -f "${FILE}" ] && cat "$FILE" | grep 'BEGIN RSA PRIVATE KEY'; then + logg 'Generating missing public key for `'"$FILE"'`' + ssh-keygen -f "$FILE" -y > "${FILE}.pub" + fi +done diff --git a/dotfiles/.local/share/chezmoi/home/private_dot_config/rclone/merge_rclone.conf b/dotfiles/.local/share/chezmoi/home/private_dot_config/rclone/merge_rclone.conf index b7e61984..3ee32905 100644 --- a/dotfiles/.local/share/chezmoi/home/private_dot_config/rclone/merge_rclone.conf +++ b/dotfiles/.local/share/chezmoi/home/private_dot_config/rclone/merge_rclone.conf @@ -1,22 +1,29 @@ -{{- if and (ne .scriptEnv.CLOUDFLARE_ACCESS_KEY_ID "") (ne .scriptEnv.CLOUDFLARE_SECRET_ACCESS_KEY "") (ne .scriptEnv.CLOUDFLARE_R2_ACCOUNT_ID "") }} +{{- if and (ne .user.CLOUDFLARE_ACCESS_KEY_ID "") (ne .user.CLOUDFLARE_SECRET_ACCESS_KEY "") (ne .user.CLOUDFLARE_R2_ACCOUNT_ID "") }} #!/usr/bin/env bash -R2_CONFIG=$(cat < /dev/null; then + gsed -i "$START_LINE,$END_LINEd" "$CONFIG_FILE" + else + sed -i "$START_LINE,$END_LINEd" "$CONFIG_FILE" + fi +fi + +tee -a "$CONFIG_FILE" > /dev/null <