Created
August 31, 2020 12:05
-
-
Save josemarcosrf/a836b479c9cc4eb67e8cbcb5e43bd30c to your computer and use it in GitHub Desktop.
Script to initialize and configure DVC (Data Version Control) in a git repository with DigitalOcean Spaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| say() { | |
| echo "$@" | sed \ | |
| -e "s/\(\(@\(red\|green\|yellow\|blue\|magenta\|cyan\|white\|reset\|b\|u\)\)\+\)[[]\{2\}\(.*\)[]]\{2\}/\1\4@reset/g" \ | |
| -e "s/@red/$(tput setaf 1)/g" \ | |
| -e "s/@green/$(tput setaf 2)/g" \ | |
| -e "s/@yellow/$(tput setaf 3)/g" \ | |
| -e "s/@blue/$(tput setaf 4)/g" \ | |
| -e "s/@magenta/$(tput setaf 5)/g" \ | |
| -e "s/@cyan/$(tput setaf 6)/g" \ | |
| -e "s/@white/$(tput setaf 7)/g" \ | |
| -e "s/@reset/$(tput sgr0)/g" \ | |
| -e "s/@b/$(tput bold)/g" \ | |
| -e "s/@u/$(tput sgr 0 1)/g" | |
| } | |
| if [ -z "$AWS_ACCESS_KEY_ID" ] | |
| then | |
| say @red[["Please set the env. variable AWS_ACCESS_KEY_ID before running this script:"]] | |
| say @red[["export AWS_ACCESS_KEY_ID=<your-access-key-id>"]] | |
| exit 1; | |
| fi | |
| if [ -z "$AWS_SECRET_ACCESS_KEY" ] | |
| then | |
| say @red[["Please set the env. variable AWS_SECRET_ACCESS_KEY before running this script:"]] | |
| say @red[["export AWS_SECRET_ACCESS_KEY=<your-secret-access-key>"]] | |
| exit 1; | |
| fi | |
| if [ -z "$1" ] | |
| then | |
| say @red[["Please pass as 1st parameter the bucket URI: s3://bucket-name/dir-path"]] | |
| exit 1; | |
| else | |
| BUCKET_URI=$1 | |
| fi | |
| if [ -z "$2" ] | |
| then | |
| say @red[["Please pass as 2nd parameter the bucket ENDPOINT. Ex: ams3.digitaloceanspaces.com"]] | |
| exit 1; | |
| else | |
| ENDPOINT_URL=$2 | |
| fi | |
| dvc remote add -d do-dvc $BUCKET_URI | |
| dvc remote modify do-dvc endpointurl https://$ENDPOINT_URL | |
| dvc remote list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment