install.fairie/home/dot_config/rclone/merge_rclone.conf

45 lines
1.4 KiB
Text
Raw Normal View History

2022-11-29 22:26:34 -08:00
{{- if and (ne .user.CLOUDFLARE_ACCESS_KEY_ID "") (ne .user.CLOUDFLARE_SECRET_ACCESS_KEY "") (ne .user.CLOUDFLARE_R2_ACCOUNT_ID "") }}
#!/usr/bin/env bash
CONFIG_FILE="$HOME/.config/rclone/rclone.conf"
if cat "$CONFIG_FILE" | grep '# MEGABYTE LABS MANAGED S3'; then
2022-11-29 22:26:34 -08:00
# TODO: Remove old block
START_LINE="$(echo `grep -n -m 1 "# MEGABYTE LABS MANAGED S3" .zshrc | cut -f1 -d ":"`)"
END_LINE="$(echo `grep -n -m 1 "# MEGABYTE LABS MANAGED S3" .zshrc | cut -f1 -d ":"`)"
2022-11-29 22:26:34 -08:00
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]
2022-11-29 22:26:34 -08:00
type = s3
provider = Cloudflare
access_key_id = {{ .user.CLOUDFLARE_ACCESS_KEY_ID }}
secret_access_key = {{ .user.CLOUDFLARE_SECRET_ACCESS_KEY }}
region = auto
endpoint = https://{{ .user.CLOUDFLARE_R2_ACCOUNT_ID }}.r2.cloudflarestorage.com
acl = private
[do-private]
type = s3
provider = DigitalOcean
env_auth = false
access_key_id = your_spaces_access_key
secret_access_key = your_spaces_secret_key
endpoint = private.nyc3.digitaloceanspaces.com
acl = private
[do-open]
type = s3
provider = DigitalOcean
env_auth = false
access_key_id = your_spaces_access_key
secret_access_key = your_spaces_secret_key
endpoint = open.nyc3.digitaloceanspaces.com
acl = public-read
# MEGABYTE LABS MANAGED S3
2022-11-29 22:26:34 -08:00
EOT
{{- end }}