From 052459c3e681f03e696e849334aa055cb45a5869 Mon Sep 17 00:00:00 2001 From: Jockel Date: Fri, 17 Feb 2017 13:04:56 +0100 Subject: [PATCH] added basic error funcion --- install.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 3a64b31..6dbc23e 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,20 @@ #!/bin/bash + +function exitcodefunction { + errorcode=$1 + action=$2 + module=$3 + + if [ $errorcode -ne "0" ]; then + echo "Action: $action on $module failed." + echo "Exitcode: $errorcode" + exit 1 + else + echo "Action: $action on $module ok." + fi + } + + tput clear tput civis echo " ____ ____ ______ __ __ __ " @@ -63,14 +79,15 @@ echo "[ 2/10] [##--------]" tput cup 15 5 echo "-> download GIT and other stuff.........." apt-get -y install git cmake build-essential libusb-1.0 qt4-qmake qt4-default libpulse-dev libx11-dev sox >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? download stuff tput cup 13 15 echo "[ 3/10] [###-------]" tput cup 15 5 echo "-> download rtl_fm......................" cd $boswatchpath/install -#git clone git://git.osmocom.org/rtl-sdr.git >> $boswatchpath/install/setup_log.txt 2>&1 git clone https://github.com/Schrolli91/rtl-sdr.git >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? git-clone rtl-sdr cd rtl-sdr/ tput cup 13 15 @@ -79,17 +96,27 @@ tput cup 15 5 echo "-> compile rtl_fm......................" mkdir -p build && cd build cmake ../ -DINSTALL_UDEV_RULES=ON >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? cmake rtl-sdr + make >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? make rtl-sdr + make install >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? make-install rtl-sdr + ldconfig >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? ldconfig rtl-sdr + + tput cup 13 15 echo "[ 5/10] [#####-----]" tput cup 15 5 echo "-> download multimon-ng................" cd $boswatchpath/install -#git clone https://github.com/EliasOenal/multimonNG.git >> $boswatchpath/install/setup_log.txt 2>&1 git clone https://github.com/Schrolli91/multimon-ng.git multimonNG >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? git-clone multimonNG + cd $boswatchpath/install/multimonNG/ @@ -100,8 +127,15 @@ echo "-> compile multimon-ng................." mkdir -p build cd build qmake ../multimon-ng.pro >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? qmake multimonNG + make >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? make multimonNG + + make install >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? qmakeinstall multimonNG + tput cup 13 15 echo "[ 7/10] [#######---]" @@ -109,7 +143,11 @@ tput cup 15 5 echo "-> download MySQL connector for Python." cd $boswatchpath/install wget "http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.0.9.tar.gz/from/http://cdn.mysql.com/" -O mysql-connector.tar >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? download mysql-connector + tar xfv mysql-connector.tar >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? untar mysql-connector + cd $boswatchpath/install/mysql-connector-python* tput cup 13 15 @@ -118,6 +156,8 @@ tput cup 15 5 echo "-> install MySQL connector for Python.." chmod +x ./setup.py ./setup.py install >> $boswatchpath/install/setup_log.txt 2>&1 +exitcodefunction $? setup mysql-connector + tput cup 13 15 echo "[ 9/10] [#########-]" @@ -126,8 +166,10 @@ echo "-> download BOSWatch..................." cd $boswatchpath/ case $branch in - dev) git clone -b develop https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 ;; - *) git clone -b master https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 ;; + dev) git clone -b develop https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch ;; + *) git clone -b master https://github.com/Schrolli91/BOSWatch >> $boswatchpath/install/setup_log.txt 2>&1 && \ + exitcodefunction $? git-clone BOSWatch ;; esac tput cup 13 15 @@ -147,3 +189,4 @@ tput cnorm if [ $reboot = "true" ]; then /sbin/reboot fi +