From 993f9d73b1275d59aef2fc9245b504e6196e6c14 Mon Sep 17 00:00:00 2001 From: Quentin Date: Fri, 20 Nov 2020 20:50:43 +0100 Subject: Quicker dev with more scripts --- README.md | 27 +++++++------------------ example/dev-cluster.sh | 54 ------------------------------------------------- script/dev-bucket.sh | 16 +++++++++++++++ script/dev-cluster.sh | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ script/dev-configure.sh | 15 ++++++++++++++ script/dev-env.sh | 18 +++++++++++++++++ 6 files changed, 110 insertions(+), 74 deletions(-) delete mode 100755 example/dev-cluster.sh create mode 100755 script/dev-bucket.sh create mode 100755 script/dev-cluster.sh create mode 100755 script/dev-configure.sh create mode 100755 script/dev-env.sh diff --git a/README.md b/README.md index f170f2ca..f9d33159 100644 --- a/README.md +++ b/README.md @@ -20,27 +20,14 @@ Our main use case is to provide a distributed storage layer for small-scale self We propose the following quickstart to setup a full dev. environment as quickly as possible: - 1. Setup a rust/cargo environment + 1. Setup a rust/cargo environment and install s3cmd. eg. `dnf install rust cargo s3cmd` 2. Run `cargo build` to build the project - 3. Run `./example/dev-cluster.sh` to launch a test cluster (feel free to read the script) - 4. Set a convenient alias `alias grg=./target/debug/garage` - 5. Get your node IDs with `grg status` - 6. Configure them, eg. `grg node configure -d dc1 -n 10 dd79867e0f5a9e08` - 7. Create a bucket, eg. `grg bucket create éprouvette` - 8. Create a key, eg. `grg key new --name opérateur` - 9. Bind the key with the bucket, eg. `grg bucket allow éprouvette --read --write --key GK108acc0d179b13826e54442b` - 10. Install s3cmd, eg. `dnf install s3cmd` - 11. s3cmd example command: - -```bash -s3cmd \ - --host 127.0.0.1:3900 \ - --access_key=GK108acc0d179b13826e54442b \ - --secret_key=f52aac5722c48f038ddf8612d1e91e8d0a9535048f1f1cd402cd0416f9f8807f \ - --region=garage \ - --no-ssl \ - ls s3://éprouvette -``` + 3. Run `./script/dev-cluster.sh` to launch a test cluster (feel free to read the script) + 4. Run `./script/dev-configure.sh` to configure your test cluster with default values (same datacenter, 100 tokens) + 5. Run `./script/dev-bucket.sh` to create a bucket named `éprouvette` and API key stored in `/tmp/garage.s3` + 6. Run `source ./script/dev-env.sh` to configure your environment: + - `garage` to manage the cluster. Try `garage --help`. + - `s3grg` to add, remove, and delete files. Try `s3grg --help`, `s3grg put /proc/cpuinfo s3://éprouvette/cpuinfo.txt`, `s3grg ls s3://éprouvette`. `s3grg` is a wrapper on `s3cmd` configured with previous API key (the one in `/tmp/garage.s3`). Now you should be ready to start hacking on garage! diff --git a/example/dev-cluster.sh b/example/dev-cluster.sh deleted file mode 100755 index e896b6ba..00000000 --- a/example/dev-cluster.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -set -e - -SCRIPT_FOLDER="`dirname \"$0\"`" -REPO_FOLDER="${SCRIPT_FOLDER}/../" -GARAGE_DEBUG="${REPO_FOLDER}/target/debug/" -GARAGE_RELEASE="${REPO_FOLDER}/target/release/" -PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH" -FANCYCOLORS=("41m" "42m" "44m" "45m" "100m" "104m") - -export RUST_BACKTRACE=1 -export RUST_LOG=garage=info -MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m" - -for count in $(seq 1 3); do -CONF_PATH="/tmp/config.$count.toml" -LABEL="\e[${FANCYCOLORS[$count]}[$count]\e[49m" - -cat > $CONF_PATH <&1|while read r; do echo -en "$LABEL $r\n"; done) & -done - -until garage status 2>&1|grep -q Healthy ; do - echo -en "${MAIN_LABEL} cluster starting...\n" - sleep 1 -done -echo -en "${MAIN_LABEL} cluster started\n" - -wait diff --git a/script/dev-bucket.sh b/script/dev-bucket.sh new file mode 100755 index 00000000..f07263f5 --- /dev/null +++ b/script/dev-bucket.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +SCRIPT_FOLDER="`dirname \"$0\"`" +REPO_FOLDER="${SCRIPT_FOLDER}/../" +GARAGE_DEBUG="${REPO_FOLDER}/target/debug/" +GARAGE_RELEASE="${REPO_FOLDER}/target/release/" +PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH" + +garage bucket create éprouvette +KEY_INFO=`garage key new --name opérateur` +ACCESS_KEY=`echo $KEY_INFO|grep -Po 'GK[a-f0-9]+'` +SECRET_KEY=`echo $KEY_INFO|grep -Po 'secret_key: "[a-f0-9]+'|grep -Po '[a-f0-9]+$'` +garage bucket allow éprouvette --read --write --key $ACCESS_KEY +echo "$ACCESS_KEY $SECRET_KEY" > /tmp/garage.s3 + +echo "Bucket s3://éprouvette created. Credentials stored in /tmp/garage.s3." diff --git a/script/dev-cluster.sh b/script/dev-cluster.sh new file mode 100755 index 00000000..756af234 --- /dev/null +++ b/script/dev-cluster.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -e + +SCRIPT_FOLDER="`dirname \"$0\"`" +REPO_FOLDER="${SCRIPT_FOLDER}/../" +GARAGE_DEBUG="${REPO_FOLDER}/target/debug/" +GARAGE_RELEASE="${REPO_FOLDER}/target/release/" +PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH" +FANCYCOLORS=("41m" "42m" "44m" "45m" "100m" "104m") + +export RUST_BACKTRACE=1 +export RUST_LOG=garage=info +MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m" + +for count in $(seq 1 3); do +CONF_PATH="/tmp/config.$count.toml" +LABEL="\e[${FANCYCOLORS[$count]}[$count]\e[49m" + +cat > $CONF_PATH <&1|while read r; do echo -en "$LABEL $r\n"; done) & +done + +until garage status 2>&1|grep -q Healthy ; do + echo -en "${MAIN_LABEL} cluster starting...\n" + sleep 1 +done +echo -en "${MAIN_LABEL} cluster started\n" + +wait diff --git a/script/dev-configure.sh b/script/dev-configure.sh new file mode 100755 index 00000000..8b7392c6 --- /dev/null +++ b/script/dev-configure.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +SCRIPT_FOLDER="`dirname \"$0\"`" +REPO_FOLDER="${SCRIPT_FOLDER}/../" +GARAGE_DEBUG="${REPO_FOLDER}/target/debug/" +GARAGE_RELEASE="${REPO_FOLDER}/target/release/" +PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH" + +garage status \ + | grep UNCONFIGURED \ + | grep -Po '^[0-9a-f]+' \ + | while read id; do + garage node configure -d dc1 -n 100 $id + done + diff --git a/script/dev-env.sh b/script/dev-env.sh new file mode 100755 index 00000000..15cb965a --- /dev/null +++ b/script/dev-env.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +SCRIPT_FOLDER="`dirname \"$0\"`" +REPO_FOLDER="${SCRIPT_FOLDER}/../" +GARAGE_DEBUG="${REPO_FOLDER}/target/debug/" +GARAGE_RELEASE="${REPO_FOLDER}/target/release/" +PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH" + +ACCESS_KEY=`cat /tmp/garage.s3 |cut -d' ' -f1` +SECRET_KEY=`cat /tmp/garage.s3 |cut -d' ' -f2` + +alias s3grg="s3cmd \ + --host 127.0.0.1:3900 \ + --access_key=$ACCESS_KEY \ + --secret_key=$SECRET_KEY \ + --region=garage \ + --no-ssl" + -- cgit v1.2.3