From a2491aa355c2c9fca4a782e2c516df3280487552 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Mon, 22 Jan 2024 14:39:14 +0100 Subject: [PATCH] install.sh: improve error checking. --- install.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index a7126e1..fe4a358 100755 --- a/install.sh +++ b/install.sh @@ -7,10 +7,28 @@ fi INSTALL_DIR=$1 -echo "Installing application in: $INSTALL_DIR" +echo -e "\033[34m-\033[0m Installing application in: $INSTALL_DIR" + +PROGRAMS=(make go) + +missing_prog=0 +for prog in ${PROGRAMS[@]}; do + CMD=$(which $prog) + if [ -z "$CMD" ]; then + echo -e "\033[31m!!\033[0m Failed to locate $prog, please install this program" + missing_prog=1 + fi +done + +if [ $missing_prog -ne 0 ]; then + exit 1 +fi mkdir -p "$INSTALL_DIR"/{bin,logs} - make -e DESTDIR=$INSTALL_DIR PREFIX= CFGDIR= install install-scripts +if [ $? -ne 0 ]; then + echo -e "\033[31m!!\033[0m Installation failed" + exit 1 +fi -echo "Done" +echo -e "\033[32m*\033[0m Done"