From a06f1332be7a5f341bd1f1476f4feed2c8fe5350 Mon Sep 17 00:00:00 2001 From: Joe Prochazka Date: Mon, 23 Nov 2015 16:53:34 -0500 Subject: [PATCH] Added whiptail guages. --- setup.sh | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/setup.sh b/setup.sh index 9d671a6..dd03517 100755 --- a/setup.sh +++ b/setup.sh @@ -13,37 +13,72 @@ function ConfigurePiAware() { # Retreive and clean the current PiAware mlatResultFormat setting. ORIGINALFORMAT=`sudo piaware-config -show | sed -n 's/.*{\(.*\)}.*/\1/p'` CLEANFORMAT=`sed 's/ beast,connect,feed.adsbexchange.com:30005//g' <<< $ORIGINALFORMAT` + for ((i = 0 ; i <= 33 ; i+=1)); do + sleep 0.01 + echo $i + done # Set the new PiAware mlatResultFormat setting. sudo piaware-config -mlatResultsFormat "${CLEANFORMAT} beast,connect,feed.adsbexchange.com:30005" + for ((i = 33 ; i <= 66 ; i+=1)); do + sleep 0.01 + echo $i + done # Restart PiAware. - sudo piaware-config -restart + sudo piaware-config -restart &>/dev/null + for ((i = 66 ; i <= 100 ; i+=1)); do + sleep 0.01 + echo $i + done + + sleep 2 } # Setup the Netcat script and execute it. function SetupNetcat() { # Set permissions on teh file adsbexchange-maint.sh. chmod 755 $SCRIPTPATH/adsbexchange-maint.sh + for ((i = 0 ; i <= 20 ; i+=1)); do + sleep 0.01 + echo $i + done # Add the ADS-B maintainance script to the file /etc/rc.local. if ! grep -Fxq "${SCRIPTPATH}/adsbexchange-maint.sh &" /etc/rc.local; then lnum=($(sed -n '/exit 0/=' /etc/rc.local)) ((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${SCRIPTPATH}/adsbexchange-maint.sh &\n" /etc/rc.local fi + for ((i = 20 ; i <= 40 ; i+=1)); do + sleep 0.01 + echo $i + done # Kill any currently running instances of the adsbexchange-maint.sh script. PIDS=`ps -efww | grep -w "adsbexchange-maint.sh" | awk -vpid=$$ '$2 != pid { print $2 }'` if [ ! -z "$PIDS" ]; then sudo kill $PIDS - for ((i = i ; i <= 5 ; i+=1)); do - sleep 1 + for ((i = 40 ; i <= 90 ; i+=1)); do + sleep 0.1 + echo $i done sudo kill -9 $PIDS + echo 90 + else + for ((i = 40 ; i <= 90 ; i+=1)); do + sleep 0.1 + echo $i + done fi # Execute the ADS-B maintainance script. sudo $SCRIPTPATH/adsbexchange-maint.sh & + for ((i = 90 ; i <= 100 ; i+=1)); do + sleep 0.01 + echo $i + done + + sleep 2 } ############# @@ -67,14 +102,15 @@ EOF whiptail --title "ADS-B Exchange Setup Script" --msgbox "$WELCOME" 17 65 # Check if the PiAware package is installed. -if [ $(dpkg-query -W -f='${STATUS}' $1 2>/dev/null | grep -c "ok installed") -eq 0 ]; then +if [ $(dpkg-query -W -f='${STATUS}' $1 2>/dev/null | grep -c "ok installed") -eq 1 ]; then # PiAware does not appear to be installed. - ConfigurePiAware + { + ConfigurePiAware + } > >(whiptail --gauge "Configuring PiAware to send MLAT data to ADS-B Exchange..." 6 65 0) fi # Setup the Netcat script. - -SetupNetcat +SetupNetcat > >(whiptail --title "ADS-B Exchange Setup Script" --gauge "Setting up and executing the ADS-B Exchange Netcat script..." 6 65 0) # Thank you text. read -d '' THANKS <<"EOF" @@ -87,5 +123,3 @@ EOF # Display the thank you message box. whiptail --title "ADS-B Exchange Setup Script" --msgbox "$THANKS" 17 65 - -exit 0