From b694217d91fe84458d0f1babd96e7ad9496c4d6c Mon Sep 17 00:00:00 2001 From: illuminatus Date: Wed, 15 Nov 2023 08:14:04 -0800 Subject: [PATCH 1/2] mkdir in generate for existing guild environments --- scripts/cnode-helper-scripts/mithril-client.sh | 7 +++++++ scripts/cnode-helper-scripts/mithril-signer.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/scripts/cnode-helper-scripts/mithril-client.sh b/scripts/cnode-helper-scripts/mithril-client.sh index 728261746..d74ba9c5d 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 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} From 7e2dbf8f7e75e1d36909525c5e3eb31e65a34a71 Mon Sep 17 00:00:00 2001 From: illuminatus Date: Wed, 15 Nov 2023 08:14:25 -0800 Subject: [PATCH 2/2] lint, handle unknown flags in case --- scripts/cnode-helper-scripts/mithril-client.sh | 4 ++++ scripts/cnode-helper-scripts/mithril-relay.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/scripts/cnode-helper-scripts/mithril-client.sh b/scripts/cnode-helper-scripts/mithril-client.sh index d74ba9c5d..49c3bc124 100755 --- a/scripts/cnode-helper-scripts/mithril-client.sh +++ b/scripts/cnode-helper-scripts/mithril-client.sh @@ -176,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