install.fairie/home/dot_config/rclone/merge_private_rclone.conf.tmpl
Brian Zalewski 0932f983b8 Update 15 files
- /home/.chezmoitemplates/secrets/key-sendgrid-api-key
- /home/.chezmoidata.yaml
- /home/dot_config/postfix/private_sasl_passwd.tmpl
- /home/dot_config/postfix/main.cf
- /home/dot_config/slack-term/config.tmpl
- /home/dot_config/tabby/config.yaml.tmpl
- /home/dot_config/warp/private_mdm.xml.tmpl
- /home/dot_config/samba/config.tmpl
- /home/dot_config/npm/npmrc.tmpl
- /home/dot_config/ngrok/ngrok.yml.tmpl
- /home/dot_config/rclone/merge_private_rclone.conf.tmpl
- /home/.chezmoiscripts/universal/run_onchange_after_05-postfix.sh.tmpl
- /home/.chezmoitemplates/secrets/SENDGRID_API_KEY
- /docs/TODO.md
- /software.yml
2023-04-19 12:13:42 +00:00

28 lines
1.6 KiB
Cheetah

{{- if and (or (and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "CLOUDFLARE_R2_ID"))) (env "CLOUDFLARE_R2_ID")) (or (and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "CLOUDFLARE_R2_SECRET"))) (env "CLOUDFLARE_R2_SECRET")) (ne .user.cloudflare.r2 "") -}}
#!/usr/bin/env bash
CONFIG_FILE="$HOME/.config/rclone/rclone.conf"
if cat "$CONFIG_FILE" | grep '# MEGABYTE LABS MANAGED S3'; then
# TODO: Remove old block
START_LINE="$(echo `grep -n -m 1 "# MEGABYTE LABS MANAGED S3" "$CONFIG_FILE" | cut -f1 -d ":"`)"
END_LINE="$(echo `grep -n -m 1 "# MEGABYTE LABS MANAGED S3" "$CONFIG_FILE" | cut -f1 -d ":"`)"
if command -v gsed > /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 <<EOT
# MEGABYTE LABS MANAGED S3
[{{ .user.username}}-s3]
access_key_id = {{ if (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "CLOUDFLARE_R2_ID")) }}{{- includeTemplate "secrets/CLOUDFLARE_R2_ID" | decrypt -}}{{ else }}{{- env "CLOUDFLARE_R2_ID" -}}{{ end }}
acl = private
endpoint = {{ .user.cloudflare.r2 }}.r2.cloudflarestorage.com/user
provider = Cloudflare
region = auto
secret_access_key = {{ if (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "CLOUDFLARE_R2_SECRET")) }}{{- includeTemplate "secrets/CLOUDFLARE_R2_SECRET" | decrypt -}}{{ else }}{{- env "CLOUDFLARE_R2_SECRET" -}}{{ end }}
type = s3
# MEGABYTE LABS MANAGED S3
EOT
{{- end -}}