From ec89e1bef21943ece6ebab3fb5c7160172853cc6 Mon Sep 17 00:00:00 2001 From: illuminatus Date: Wed, 15 Nov 2023 13:56:39 -0800 Subject: [PATCH] Mithril mkdir in scripts for existing deployments (#1702) Both mithril-signer and mithril-client will check for directory existence before generating the mithril environment file. If the directory does not exist it will `mkdir -p` and `chown -R`. --- scripts/cnode-helper-scripts/mithril-client.sh | 11 +++++++++++ scripts/cnode-helper-scripts/mithril-relay.sh | 4 ++++ scripts/cnode-helper-scripts/mithril-signer.sh | 7 +++++++ 3 files changed, 22 insertions(+) diff --git a/scripts/cnode-helper-scripts/mithril-client.sh b/scripts/cnode-helper-scripts/mithril-client.sh index 728261746..49c3bc124 100755 --- a/scripts/cnode-helper-scripts/mithril-client.sh +++ b/scripts/cnode-helper-scripts/mithril-client.sh @@ -15,6 +15,9 @@ # Do NOT modify code below # ###################################### +U_ID=$(id -u) +G_ID=$(id -g) + ##################### # Functions # ##################### @@ -34,6 +37,10 @@ usage() { generate_environment_file() { + if [[ ! -d "${CNODE_HOME}/mithril/data-stores" ]]; then + sudo mkdir -p "${CNODE_HOME}"/mithril/data-stores + sudo chown -R "$U_ID":"$G_ID" "${CNODE_HOME}"/mithril 2>/dev/null + fi if [[ -n "${POOL_NAME}" ]] && [[ "${POOL_NAME}" != "CHANGE_ME" ]]; then export ERA_READER_ADDRESS=https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/${RELEASE}-${NETWORK_NAME,,}/era.addr export ERA_READER_VKEY=https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/${RELEASE}-${NETWORK_NAME,,}/era.vkey @@ -169,6 +176,10 @@ while getopts :duh opt; do usage exit 1 ;; + *) + usage + exit 1 + ;; esac done diff --git a/scripts/cnode-helper-scripts/mithril-relay.sh b/scripts/cnode-helper-scripts/mithril-relay.sh index c395c232d..6c104fddf 100755 --- a/scripts/cnode-helper-scripts/mithril-relay.sh +++ b/scripts/cnode-helper-scripts/mithril-relay.sh @@ -208,6 +208,10 @@ while getopts :dlh opt; do usage exit 1 ;; + *) + usage + exit 1 + ;; esac done diff --git a/scripts/cnode-helper-scripts/mithril-signer.sh b/scripts/cnode-helper-scripts/mithril-signer.sh index cd5090743..dd93187de 100755 --- a/scripts/cnode-helper-scripts/mithril-signer.sh +++ b/scripts/cnode-helper-scripts/mithril-signer.sh @@ -16,6 +16,9 @@ # Do NOT modify code below # ###################################### +U_ID=$(id -u) +G_ID=$(id -g) + ##################### # Functions # ##################### @@ -71,6 +74,10 @@ get_relay_endpoint() { } generate_environment_file() { + if [[ ! -d "${CNODE_HOME}/mithril/data-stores" ]]; then + sudo mkdir -p "${CNODE_HOME}"/mithril/data-stores + sudo chown -R "$U_ID":"$G_ID" "${CNODE_HOME}"/mithril 2>/dev/null + fi # Inquire about the relay endpoint read -r -p "Are you using a relay endpoint? (y/n, press Enter to use default y): " ENABLE_RELAY_ENDPOINT ENABLE_RELAY_ENDPOINT=${ENABLE_RELAY_ENDPOINT:-y}