Last active
August 4, 2023 15:58
-
-
Save cloudnull/8d03e581f5f2947dd168a8f9375844c4 to your computer and use it in GitHub Desktop.
compose omnibus protocol shell
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
function fig-up () { | |
function get_latest_release() { | |
curl $(curl --silent "https://api.github.com/repos/ovrclk/cosmos-omnibus/releases/latest" | jq ".url" -r) | jq -r .tag_name | |
} | |
function get_rpc_endpoint() { | |
curl --silent "https://cdn.jsdelivr.net/gh/cosmos/chain-registry@master/$1/chain.json" | jq ".apis.rpc[0].address" -r | |
} | |
if ! command -v jq &> /dev/null; then | |
echo 'install "jq" to go forward.' | |
fi | |
if ! command -v curl &> /dev/null; then | |
echo 'install "curl" to go forward.' | |
fi | |
if ! command -v git &> /dev/null; then | |
echo 'install "git" to go forward.' | |
fi | |
if ! command -v docker &> /dev/null; then | |
echo 'install "docker" to go forward.' | |
fi | |
PROTOCOL="$1" | |
RPC_URL="$(get_rpc_endpoint ${PROTOCOL})" | |
if [[ -d /tmp/cosmos-omnibus ]]; then | |
pushd /tmp/cosmos-omnibus | |
git checkout $(get_latest_release) | |
popd | |
else | |
git clone --branch $(get_latest_release) https://github.com/ovrclk/cosmos-omnibus /tmp/cosmos-omnibus | |
fi | |
pushd "/tmp/cosmos-omnibus/${PROTOCOL}" | |
docker compose up -d | |
docker compose exec -it -e NODE=$RPC_URL node_1 /bin/bash | |
COMPOSE_RC=$? | |
docker compose kill node_1 || true | |
docker compose rm --force node_1 || true | |
popd | |
if [[ ${COMPOSE_RC} == 0 ]]; then | |
rm -rf /tmp/cosmos-omnibus | |
fi | |
unset COMPOSE_RC | |
unset RPC_URL | |
unset PROTOCOL | |
unset -f get_rpc_endpoint | |
unset -f get_latest_release | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Integration example
Add the function to your terminal RC file.
Once added restart the terminal emulator application.
Execution example
With the function installed, you can run it normally. The first positional argument is always assumed to be the protocol supported by cosmos-omnibus.