Skip to content

Commit 379176f

Browse files
committed
feat(install-script): add requirement check + fix usage
Add a check that the required commands are installed (curl and jq). Fix the usage output which wrongly suggested to use a `-n` option instead of `-c` for the node choice.
1 parent d9517c6 commit 379176f

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

mithril-install.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,36 @@ set -e
55
# Function to display usage
66
usage() {
77
echo "Install or upgrade a Mithril node"
8-
echo "Usage: $0 [-n node] [-v version] [-d distribution] [-p path]"
8+
echo "Usage: $0 [-c node] [-v version] [-d distribution] [-p path]"
99
echo " -c node : Mithril node to install or upgrade (mithril-signer, mithril-aggregator, mithril-client)"
1010
echo " -d distribution : Distribution to upgrade to (latest, unstable or distribution version e.g '2445.0')"
1111
echo " -p path : Path to install the component"
1212
exit 1
1313
}
1414

15-
# Default values
16-
DISTRIBUTION="latest"
17-
GITHUB_ORGANIZATION="input-output-hk"
18-
GITHUB_REPOSITORY="mithril"
19-
2015
# Function to display an error message and exit
2116
error_exit() {
2217
echo "$1" 1>&2
2318
exit 1
2419
}
2520

21+
# Function to check that required tools are installed
22+
check_requirements() {
23+
which curl >/dev/null ||
24+
error_exit "It seems 'curl' is not installed or not in the path.";
25+
which jq >/dev/null ||
26+
error_exit "It seems 'jq' is not installed or not in the path.";
27+
}
28+
29+
# --- MAIN execution ---
30+
31+
# Default values
32+
DISTRIBUTION="latest"
33+
GITHUB_ORGANIZATION="input-output-hk"
34+
GITHUB_REPOSITORY="mithril"
35+
36+
check_requirements
37+
2638
# Parse command line arguments
2739
while getopts "c:v:d:p:" opt; do
2840
case ${opt} in

0 commit comments

Comments
 (0)