diff --git a/bash/portal/graphs.sh b/bash/portal/graphs.sh index e0357ef..2e4e13c 100755 --- a/bash/portal/graphs.sh +++ b/bash/portal/graphs.sh @@ -40,6 +40,17 @@ PORTALBUILDDIRECTORY="${BUILDDIRECTORY}/portal" COLLECTD_CONFIG="/etc/collectd/collectd.conf" COLLECTD_CRON_FILE="/etc/cron.d/adsb-feeder-performance-graphs" +## CONFIRM INSTALLED PACKAGES + +if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then + DUMP1090_FORK="mutability" + DUMP1090_INSTALLED="true" +fi +if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then + DUMP1090_FORK="fa" + DUMP1090_INSTALLED="true" +fi + ## CHECK FOR PREREQUISITE PACKAGES echo "" @@ -48,7 +59,7 @@ echo "" ## MODIFY THE DUMP1090-MUTABILITY INIT SCRIPT TO MEASURE AND RETAIN NOISE DATA -if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then +if [[ ${DUMP1090_INSTALLED} = "true" ]] && [[ ${DUMP1090_FORK} = "mutability" ]] ; then echo -e "\e[94m Modifying the dump1090-mutability init script to add noise measurements...\e[97m" sudo sed -i 's/ARGS=""/ARGS="--measure-noise "/g' /etc/init.d/dump1090-mutability echo -e "\e[94m Reloading the systemd manager configuration...\e[97m" @@ -69,7 +80,6 @@ fi # Generate new collectd config. echo -e "\e[94m Replacing the current collectd.conf file...\e[97m" - sudo tee ${COLLECTD_CONFIG} > /dev/null < /dev/null < /dev/null < /dev/null < EOF +fi # Raspberry Pi specific values. sudo tee -a ${COLLECTD_CONFIG} > /dev/null < /dev/null < @@ -231,22 +247,21 @@ echo "" ## EDIT CRONTAB echo -e "\e[94m Making the make-collectd-graphs.sh script executable...\e[97m" -chmod +x ${PORTALBUILDDIRECTORY}/graphs/make-collectd-graphs.sh +chmod +x ${PORTALBUILDDIRECTORY}/graphs/make-collectd-graphs.sh 2>&1 # The next block is temporary in order to insure this file is # deleted on older installation before the project renaming. if [ -f /etc/cron.d/adsb-feeder-performance-graphs ]; then echo -e "\e[94m Removing outdated performance graphs cron file...\e[97m" - sudo rm -f /etc/cron.d/adsb-feeder-performance-graphs + sudo rm -f /etc/cron.d/adsb-feeder-performance-graphs 2>&1 fi if [ -f ${COLLECTD_CRON_FILE} ]; then echo -e "\e[94m Removing previously installed performance graphs cron file...\e[97m" - sudo rm -f ${COLLECTD_CRON_FILE} + sudo rm -f ${COLLECTD_CRON_FILE} 2>&1 fi echo -e "\e[94m Adding performance graphs cron file...\e[97m" - sudo tee ${COLLECTD_CRON_FILE} > /dev/null <