From 65e0be5a18a00c8852b214271534b131d6f740bf Mon Sep 17 00:00:00 2001 From: intuxicated Date: Thu, 18 Jul 2013 16:48:08 +0430 Subject: [PATCH] add requirments check functionality --- install.sh | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index eb9aa95..748997c 100755 --- a/install.sh +++ b/install.sh @@ -12,9 +12,11 @@ remoteexecutable="http://raw.github.com/Karajlug/KusoIDE/1.0/bin/kuso" conffile=conf/dotkuso +REQUIRMENTS=(emacs git) + # Coloring Functions function info() { - echo -e "[\033[01;32mINFO\033[00m]: $1" + echo -ne "[\033[01;32mINFO\033[00m]: $1" } function error(){ @@ -25,8 +27,34 @@ function warn(){ echo -e "[\033[01;33mWARN\033[00m]: $1" } +function requirments_check(){ + for app in "${REQUIRMENTS[@]}" + do + echo -ne "[\033[01;32mINFO\033[00m]: $app \033[01;34m[CHEKING]\033[00m \r" + if hash $1 2>/dev/null; then + echo -ne "[\033[01;32mINFO\033[00m]: $app \033[01;34m[OK]\033[00m \n" + else + REQUIRMENT_CHECK=false + echo -ne "[\033[01;32mINFO\033[00m]: $app \033[01;31m[ERR]\033[00m \n" + fi + done +} + # Gathering informations echo -e "\n\033[01;32mKuso IDE\033[00m $VERSION copyright 2010-2013 \033[01;34mSameer Rahmani \033[00m\n\n" + +# Requirments check to make sure everything is ok +echo -e "Requirment Check" +# if this variable changed to fasle , means we have something to install +REQUIRMENT_CHECK=true +requirments_check $REQUIRMENTS +# exit if our requirement check +if [ $REQUIRMENT_CHECK == false ]; then + error "Please install requirments first"; + exit; +fi +echo -e "\n\n" + echo "Enter requested informations. You can change it later in top" echo -e "your init file.\n\n"