Skip to content

Commit

Permalink
added a function to check if the script's required programs exist or …
Browse files Browse the repository at this point in the history
…exit the program with an indicative message (#326)
  • Loading branch information
orelb authored and akshayrai committed Feb 5, 2018
1 parent 5500aad commit c182c98
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,26 @@ function play_command() {
fi
}

function require_programs() {
echo "Checking for required programs..."
missing_programs=""

for program in $@; do
if ! command -v "$program" > /dev/null; then
missing_programs=$(printf "%s\n\t- %s" "$missing_programs" "$program")
fi
done

if [ ! -z "$missing_programs" ]; then
echo "[ERROR] The following programs are required and are missing: $missing_programs"
exit 1
else
echo "[SUCCESS] Program requirement is fulfilled!"
fi
}

require_programs zip unzip

# Default configurations
HADOOP_VERSION="2.3.0"
SPARK_VERSION="1.4.0"
Expand Down

0 comments on commit c182c98

Please sign in to comment.