Skip to content

Commit

Permalink
guild-deploy option to download mithril binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
TrevorBenson committed Oct 21, 2023
1 parent 8402049 commit 09d4510
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion scripts/cnode-helper-scripts/guild-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ versionCheck() { printf '%s\n%s' "${1//v/}" "${2//v/}" | sort -C -V; } #$1=avail
usage() {
cat <<-EOF >&2
Usage: $(basename "$0") [-n <mainnet|preprod|guild|preview>] [-p path] [-t <name>] [-b <branch>] [-u] [-s [p][b][l][f][d][c][o][w][x]]
Usage: $(basename "$0") [-n <mainnet|preprod|guild|preview>] [-p path] [-t <name>] [-b <branch>] [-u] [-s [p][b][l][m][f][d][c][o][w][x]]
Set up dependencies for building/using common tools across cardano ecosystem.
The script will always update dynamic content from existing scripts retaining existing user variables
Expand All @@ -74,6 +74,7 @@ usage() {
p Install common pre-requisite OS-level Dependencies for most tools on this repo (Default: skip)
b Install OS level dependencies for tools required while building cardano-node/cardano-db-sync components (Default: skip)
l Build and Install libsodium fork from IO repositories (Default: skip)
m Build and install mithril from IO repositories (Default: skip)
f Force overwrite entire content of scripts and config files (backups of existing ones will be created) (Default: skip)
d Download latest (released) binaries for bech32, cardano-address, cardano-node, cardano-cli, cardano-db-sync and cardano-submit-api (Default: skip)
c Install/Upgrade CNCLI binary (Default: skip)
Expand All @@ -92,6 +93,7 @@ set_defaults() {
[[ -z ${WANT_BUILD_DEPS} ]] && WANT_BUILD_DEPS='N'
[[ -z ${FORCE_OVERWRITE} ]] && FORCE_OVERWRITE='N'
[[ -z ${LIBSODIUM_FORK} ]] && LIBSODIUM_FORK='N'
[[ -z ${INSTALL_MITHRIL} ]] && INSTALL_MITHRIL='N'
[[ -z ${INSTALL_CNCLI} ]] && INSTALL_CNCLI='N'
[[ -z ${INSTALL_CWHCLI} ]] && INSTALL_CWHCLI='N'
[[ -z ${INSTALL_OGMIOS} ]] && INSTALL_OGMIOS='N'
Expand Down Expand Up @@ -322,6 +324,25 @@ build_libsodium() {
echo -e "\nIOG fork of libsodium installed to /usr/local/lib/"
}

# Build mithril
download_mithril() {
echo -e "\nDownloading mithril binaries..."
pushd "${HOME}"/tmp >/dev/null || err_exit
# hardcoded latest release requiring a bump
# latest_release="2337.0"
# dynamic latest release updated automatically
latest_release=$(curl --silent "https://api.github.com/repos/input-output-hk/mithril/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo -e "\n Downloading mithril ${latest_release}..."
rm -f mithril-signer mithril-client
curl -m 200 -sfL https://github.com/input-output-hk/mithril/releases/download/${latest_release}/mithril-${latest_release}-linux-x64.tar.gz -o mithril.tar.gz || err_exit " Could not download mithril's latest release archive from IO github!"
tar zxf mithril.tar.gz mithril-signer mithril-client &>/dev/null
rm -f mithril.tar.gz
[[ -f mithril-signer ]] || err_exit " mithril archive downloaded but binary (mithril-signer) not found after extracting package!"
[[ -f mithril-client ]] || err_exit " mithril archive downloaded but binary (mithril-client) not found after extracting package!"
mv -t "${HOME}"/.local/bin mithril-signer mithril-client
chmod +x "${HOME}"/.local/bin/*
}

# Download cardano-node, cardano-cli, cardano-db-sync, bech32 and cardano-submit-api
# TODO: Replace these with self-hosted ones (potentially consider IPFS as upload destination for CI)
download_cnodebins() {
Expand Down Expand Up @@ -591,6 +612,7 @@ parse_args() {
[[ "${S_ARGS}" =~ "p" ]] && INSTALL_OS_DEPS="Y"
[[ "${S_ARGS}" =~ "b" ]] && INSTALL_OS_DEPS="Y" && WANT_BUILD_DEPS="Y"
[[ "${S_ARGS}" =~ "l" ]] && INSTALL_OS_DEPS="Y" && WANT_BUILD_DEPS="Y" && INSTALL_LIBSODIUM_FORK="Y"
[[ "${S_ARGS}" =~ "m" ]] && INSTALL_MITHRIL="Y" && WANT_BUILD_DEPS="Y"
[[ "${S_ARGS}" =~ "f" ]] && FORCE_OVERWRITE="Y" && POPULATE_CNODE="F"
[[ "${S_ARGS}" =~ "d" ]] && INSTALL_CNODEBINS="Y"
[[ "${S_ARGS}" =~ "c" ]] && INSTALL_CNCLI="Y"
Expand All @@ -613,6 +635,7 @@ main_flow() {
[[ "${INSTALL_OS_DEPS}" == "Y" ]] && os_dependencies
[[ "${WANT_BUILD_DEPS}" == "Y" ]] && build_dependencies
[[ "${INSTALL_LIBSODIUM_FORK}" == "Y" ]] && build_libsodium
[[ "${INSTALL_MITHRIL}" == "Y" ]] && download_mithril
[[ "${FORCE_OVERWRITE}" == "Y" ]] && POPULATE_CNODE="F" && populate_cnode
[[ "${POPULATE_CNODE}" == "Y" ]] && populate_cnode
[[ "${INSTALL_CNODEBINS}" == "Y" ]] && download_cnodebins
Expand Down

0 comments on commit 09d4510

Please sign in to comment.