adsb-receiver/bash/portal/install.sh

525 wiersze
22 KiB
Bash
Czysty Zwykły widok Historia

2015-12-01 11:37:40 +00:00
#!/bin/bash
#####################################################################################
2016-02-18 15:41:39 +00:00
# ADS-B RECEIVER #
2015-12-01 11:37:40 +00:00
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015 Joseph A. Prochazka #
# #
# Permission is hereby granted, free of charge, to any person obtaining a copy #
# of this software and associated documentation files (the "Software"), to deal #
# in the Software without restriction, including without limitation the rights #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell #
# copies of the Software, and to permit persons to whom the Software is #
# furnished to do so, subject to the following conditions: #
# #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software. #
# #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE #
# SOFTWARE. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2016-01-08 17:02:34 +00:00
BUILDDIR=$PWD
BASHDIR=$BUILDDIR/../bash
2016-01-22 21:07:08 +00:00
HTMLDIR=$BUILDDIR/portal/html
# Assign the Lighthttpd document root directory to a variable.
RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`
DOCUMENTROOT=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< $RAWDOCUMENTROOT`
2015-12-01 11:37:40 +00:00
2016-01-08 17:02:34 +00:00
source ../bash/functions.sh
2015-12-01 11:37:40 +00:00
clear
echo -e "\033[31m"
echo "-------------------------------------------"
2016-01-22 21:07:08 +00:00
echo " Now ready to install ADS-B Portal."
2015-12-01 11:37:40 +00:00
echo "-------------------------------------------"
2016-01-22 21:07:08 +00:00
echo -e "\033[33mThe goal of the ADS-B Portal project is to create a very"
2016-02-22 14:30:10 +00:00
echo "light weight easy to manage web interface for dump-1090 installations."
2015-12-01 11:37:40 +00:00
echo "This project is at the moment very young with only a few of the planned"
2016-02-22 14:30:10 +00:00
echo "features currently available at this time."
2015-12-01 11:37:40 +00:00
echo ""
2016-02-22 14:30:10 +00:00
echo "https://github.com/jprochazka/adsb-receiver"
2015-12-01 11:37:40 +00:00
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
clear
2016-04-28 16:20:21 +00:00
## CHECK IF THE PORTAL HAS BEEN INSTALLED ALREADY
2016-04-01 13:46:32 +00:00
2016-04-28 16:20:21 +00:00
if [ -f $DOCUMENTROOT/classes/settings.class.php ]; then
2016-04-01 13:46:32 +00:00
echo -e "\033[31m"
2016-04-28 16:20:21 +00:00
echo "It appears a previous verison of the portal has been installled."
2016-04-01 13:46:32 +00:00
echo -e "\033[33m"
2016-04-28 16:20:21 +00:00
echo "The files and packages making up your portal installation will"
echo "be updated. However you will still need to execute the PHP update"
echo "script to complete the upgrade process by simply visiting the portal"
2016-04-01 13:46:32 +00:00
echo -e "\033[37m"
2016-04-28 16:20:21 +00:00
read -p "Press enter to continue..." CONTINUE
# Set dome needed variables to be used shortly.
INSTALLED="y"
DRIVER=`grep 'db_driver' $DOCUMENTROOT/classes/settings.class.php | tail -n1 | cut -d\' -f2`
HOST=`grep 'db_host' $DOCUMENTROOT/classes/settings.class.php | tail -n1 | cut -d\' -f2`
if [ $DRIVER != "xml" ]; then
ADVANCED="y"
else
ADVANCED="n"
fi
if [ $DRIVER == "sqlite" ]; then
DATABASEENGINE=2
else
DATABASEENGINE=1
fi
2016-05-20 14:32:51 +00:00
if [[ $HOST == "localhost" ]] || [[ $HOST == "127.0.0.1" ]]; then
2016-04-28 16:20:21 +00:00
LOCALDATABASE=1
else
LOCALDATABASE=2
fi
else
## ASK IF ADVANCED FEATURES ARE TO BE USED
INSTALLED="n"
echo -e "\033[31m"
echo "Do you wish to enable advanced features?"
echo -e "\033[33m"
2016-08-18 22:51:00 +00:00
echo "ADVANCED FEATURES ARE ONLY MEANT TO BE ENABLED BY THOSE HELPING TO DEVELOP THEM AND NOT FULLY SUPPORTED"
2016-04-28 16:20:21 +00:00
echo "ENABLING ADVANCED FEATURES ON DEVICES USING SD CARDS CAN SHORTEN THE LIFE OF THE SD CARD IMMENSELY"
echo ""
echo "By enabling advanced features the portal will log all flights seen as well as the path of the flight."
echo "This data is stored in either a MySQL or SQLite database. This will result in a lot more data being"
echo "stored on your devices hard drive. Keep this and your devices hardware capabilities in mind before"
echo "selecting to enable these features."
echo -e "\033[31m"
echo "You have been warned."
echo -e "\033[37m"
read -p "Use portal with advanced features? [y/N] " ADVANCED
if [[ $ADVANCED =~ ^[yY]$ ]]; then
echo -e "\033[31m"
2016-04-28 16:20:21 +00:00
echo "Select Database Engine"
echo -e "\033[33m"
2016-04-28 16:20:21 +00:00
echo " 1) MySQL"
echo " 2) SQLLite"
echo -e "\033[37m"
2016-05-11 02:25:30 +00:00
read -p "Which database engine will be used? [1] " DATABASEENGINE
2016-04-28 16:20:21 +00:00
# Check if the user is using a remote MySQL database.
2016-04-29 16:40:14 +00:00
if [[ $DATABASEENGINE != 2 ]]; then
2016-04-28 16:20:21 +00:00
echo -e "\033[31m"
echo "Will the database be hosted locally on this device or remotely?"
echo -e "\033[33m"
echo " 1) Locally"
echo " 2) Remotely"
echo -e "\033[37m"
2016-05-11 02:25:30 +00:00
read -p "Where will the database hosted? [1] " LOCALDATABASE
2016-04-28 16:20:21 +00:00
fi
fi
2016-04-01 13:46:32 +00:00
fi
2015-12-01 11:37:40 +00:00
## CHECK FOR PREREQUISITE PACKAGES
echo -e "\033[33m"
echo "Installing packages needed to build and fulfill dependencies..."
echo -e "\033[37m"
2015-12-30 16:13:28 +00:00
CheckPackage cron
2016-01-26 16:23:53 +00:00
CheckPackage collectd-core
2015-12-01 11:37:40 +00:00
CheckPackage rrdtool
CheckPackage postfix
2016-01-24 01:53:27 +00:00
CheckPackage lighttpd
2016-05-02 12:55:39 +00:00
# Check if this is Ubuntu 16.04 LTS.
# This needs optimized and made to recognize releases made after 16.04 as well.
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
2016-05-04 04:24:08 +00:00
if [ $DISTRIB_ID == "Ubuntu" ] && [ $DISTRIB_RELEASE == "16.04" ]; then
2016-05-02 12:55:39 +00:00
CheckPackage php7.0-cgi
CheckPackage php7.0-xml
2016-05-02 12:55:39 +00:00
else
CheckPackage php5-cgi
2016-06-08 14:58:49 +00:00
CheckPackage php5-json
2016-05-02 12:55:39 +00:00
fi
else
CheckPackage php5-cgi
2016-06-08 14:58:49 +00:00
CheckPackage php5-json
2016-05-02 12:55:39 +00:00
fi
2016-02-05 16:30:11 +00:00
CheckPackage libpython2.7
2016-04-03 03:01:04 +00:00
if [[ $ADVANCED =~ ^[yY]$ ]]; then
CheckPackage python-pyinotify
2016-04-01 13:46:32 +00:00
if [[ $DATABASEENGINE == 2 ]]; then
2016-05-02 12:55:39 +00:00
CheckPackage sqlite3
# Check if this is Ubuntu 16.04 LTS.
# This needs optimized and made to recognize releases made after 16.04 as well.
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
2016-05-04 04:24:08 +00:00
if [ $DISTRIB_ID == "Ubuntu" ] && [ $DISTRIB_RELEASE == "16.04" ]; then
2016-05-02 12:55:39 +00:00
CheckPackage php7.0-sqlite
else
CheckPackage php5-sqlite
fi
else
CheckPackage php5-sqlite
fi
2016-04-01 13:46:32 +00:00
else
if [[ $LOCALDATABASE != 2 ]]; then
# Install MySQL locally.
CheckPackage mysql-server
fi
CheckPackage mysql-client
2016-04-01 13:46:32 +00:00
CheckPackage python-mysqldb
2016-05-02 12:55:39 +00:00
# Check if this is Ubuntu 16.04 LTS.
# This needs optimized and made to recognize releases made after 16.04 as well.
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
2016-05-04 04:24:08 +00:00
if [ $DISTRIB_ID == "Ubuntu" ] && [ $DISTRIB_RELEASE == "16.04" ]; then
2016-05-02 12:55:39 +00:00
CheckPackage php7.0-mysql
else
CheckPackage php5-mysql
fi
else
CheckPackage php5-mysql
fi
2016-04-01 13:46:32 +00:00
fi
fi
2016-05-13 21:02:21 +00:00
# Restart Lighttpd after installing the prerequisite packages.
echo -e "\033[33m"
echo -e "Restarting lighttpd...\033[37m"
sudo /etc/init.d/lighttpd restart
2016-04-29 16:40:14 +00:00
if [[ $INSTALLED == "n" ]]; then
2016-04-01 13:46:32 +00:00
2016-04-28 16:20:21 +00:00
## CREATE THE DATABASE IF ADVANCED FEATURES WAS SELECTED
if [[ $ADVANCED =~ ^[yY]$ ]]; then
if [[ $DATABASEENGINE != 2 ]]; then
echo -e "\033[31m"
echo "Gathering Database Information"
echo -e "\033[33m"
echo "Please supply the information pertaining to the new password when asked."
echo ""
2016-05-12 16:33:11 +00:00
echo -e "\033[31mNOTE:"
2016-04-28 16:20:21 +00:00
echo "If the database will be hosted locally on this device a database will be"
2016-05-12 16:33:11 +00:00
echo "created automatically for you."
echo ""
echo "If you are hosting your database remotely YOU WILL NEED TO MANUALLY CREATE"
echo "THE DATABASE AND USER BEFORE PROCEEDING WITH THE INSTALLATION."
2016-04-28 16:20:21 +00:00
echo -e "\033[37m"
DATABASEHOST="localhost"
if [[ $LOCALDATABASE != 2 ]]; then
2016-05-18 03:10:13 +00:00
read -p "MySQL user login: [root] " DATABASEADMINUSER
read -p "Password for MySQL user: " DATABASEADMINPASSWORD
if [[ $LOCALDATABASE == "" ]]; then
2016-05-18 03:10:13 +00:00
DATABASEADMINUSER="root"
fi
2016-04-29 23:30:19 +00:00
2016-05-12 16:33:11 +00:00
# Check that the supplied password is correct.
2016-05-18 03:10:13 +00:00
while ! mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD} -e ";" ; do
echo ""
2016-05-12 16:33:11 +00:00
echo -e "\033[31m"
echo -e "Unable to connect to the MySQL server using the supplied login and password.\033[37m"
2016-05-18 03:10:13 +00:00
read -p "MySQL user login: [root] " DATABASEADMINUSER
read -p "Password for MySQL user: " DATABASEADMINPASSWORD
2016-05-12 16:33:11 +00:00
if [[ $LOCALDATABASE == "" ]]; then
2016-05-18 03:10:13 +00:00
DATABASEADMINUSER="root"
2016-05-12 16:33:11 +00:00
fi
done
fi
echo ""
2016-05-12 16:33:11 +00:00
if [[ $LOCALDATABASE == 2 ]]; then
# Ask for remote MySQL address if the database is hosted remotely.
read -p "MySQL Server Address: " DATABASEHOST
fi
read -p "Database Name: " DATABASENAME
read -p "Database User Name: " DATABASEUSER
read -p "Database User Password: " DATABASEPASSWORD
2016-05-18 03:10:13 +00:00
read -p "Confirm Database User Password: " CONFIRMDATABASEPASSWORD
while [ $DATABASEPASSWORD != $CONFIRMDATABASEPASSWORD ]; do
2016-05-18 03:10:13 +00:00
echo -e "\033[31m"
echo -e "The supplied database user passwords did not match.\033[37m"
read -p "Database User Password: " DATABASEPASSWORD
read -p "Confirm Database User Password: " CONFIRMDATABASEPASSWORD
done
2016-04-01 13:46:32 +00:00
2016-05-12 16:33:11 +00:00
if [[ $LOCALDATABASE == 2 ]]; then
# Check the connection to the remote MySQL server.
2016-05-12 17:30:45 +00:00
while ! mysql -u${DATABASEUSER} -p${DATABASEPASSWORD} -h ${DATABASEHOST} -e ";" ; do
2016-05-12 16:33:11 +00:00
echo -e "\033[31m"
echo -e "Unable to connect to the MySQL server using the supplied login and password.\033[37m"
read -p "MySQL Server Address: " DATABASEHOST
2016-05-18 03:10:13 +00:00
read -p "Database User Name: " DATABASEUSER
2016-05-12 17:30:45 +00:00
read -p "Database User Password: " DATABASEPASSWORD
2016-05-12 16:33:11 +00:00
done
else
# Create the database and user if running MySQL locally.
echo -e "\033[33m"
echo -e "Creating MySQL database and user...\033[37m"
2016-05-18 03:10:13 +00:00
mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD} -e "CREATE DATABASE ${DATABASENAME};"
mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD}\";";
mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';"
mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD} -e "FLUSH PRIVILEGES;"
2016-04-28 16:20:21 +00:00
fi
echo -e "\033[31m"
echo "BE SURE TO WRITE THIS INFORMATION DOWN."
echo -e "\033[33m"
2016-04-28 16:20:21 +00:00
echo "This information will be needed in order to complete the installation of the portal."
echo ""
echo "Database Server: ${DATABASEHOST}"
echo "Database User: ${DATABASEUSER}"
echo "Database Password: ${DATABASEPASSWORD}"
echo "Database Name: ${DATABASENAME}"
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
2016-04-03 03:01:04 +00:00
2016-04-28 16:20:21 +00:00
fi
2016-04-01 13:46:32 +00:00
2016-04-28 16:20:21 +00:00
## SETUP FLIGHT LOGGING SCRIPT
2016-04-01 13:46:32 +00:00
2016-04-28 16:20:21 +00:00
echo -e "\033[33m"
echo -e "Creating configuration file...\033[37m"
case $DATABASEENGINE in
"2")
tee $BUILDDIR/portal/logging/config.json > /dev/null <<EOF
2016-04-01 13:46:32 +00:00
{
"database":{"type":"sqlite",
"host":"",
"user":"",
"passwd":"",
2016-04-29 22:08:21 +00:00
"db":"${DOCUMENTROOT}/data/portal.sqlite"}
2016-04-01 13:46:32 +00:00
}
2016-04-03 03:01:04 +00:00
EOF
2016-04-28 16:20:21 +00:00
;;
*)
tee $BUILDDIR/portal/logging/config.json > /dev/null <<EOF
2016-04-01 13:46:32 +00:00
{
"database":{"type":"mysql",
"host":"${DATABASEHOST}",
2016-04-01 13:46:32 +00:00
"user":"${DATABASEUSER}",
"passwd":"${DATABASEPASSWORD}",
"db":"${DATABASENAME}"}
}
EOF
2016-04-28 16:20:21 +00:00
;;
esac
# Create and set permissions on the flight logging and maintainance maintenance scripts.
2016-04-28 16:20:21 +00:00
PYTHONPATH=`which python`
tee $BUILDDIR/portal/logging/flights-maint.sh > /dev/null <<EOF
2016-04-03 03:01:04 +00:00
#!/bin/sh
while true
do
sleep 30
2016-04-28 16:20:21 +00:00
${PYTHONPATH} ${BUILDDIR}/portal/logging/flights.py
done
EOF
tee $BUILDDIR/portal/logging/maintenance-maint.sh > /dev/null <<EOF
#!/bin/sh
while true
do
sleep 30
${PYTHONPATH} ${BUILDDIR}/portal/logging/maintenance.py
done
EOF
2016-04-28 16:20:21 +00:00
chmod +x $BUILDDIR/portal/logging/flights-maint.sh
chmod +x $BUILDDIR/portal/logging/maintenance-maint.sh
2016-04-28 16:20:21 +00:00
# Add flight logging maintenance script to rc.local.
2016-04-28 16:20:21 +00:00
if ! grep -Fxq "${BUILDDIR}/portal/logging/flights-maint.sh &" /etc/rc.local; then
echo -e "\033[33m"
echo -e "Adding flights-maint.sh startup line to rc.local...\033[37m"
2016-04-28 16:20:21 +00:00
lnum=($(sed -n '/exit 0/=' /etc/rc.local))
((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${BUILDDIR}/portal/logging/flights-maint.sh &\n" /etc/rc.local
fi
2016-04-14 15:59:16 +00:00
# Add maintenance maintenance script to rc.local.
if ! grep -Fxq "${BUILDDIR}/portal/logging/maintenance-maint.sh &" /etc/rc.local; then
echo -e "\033[33m"
echo -e "Adding maintenance-maint.sh startup line to rc.local...\033[37m"
lnum=($(sed -n '/exit 0/=' /etc/rc.local))
((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${BUILDDIR}/portal/logging/maintenance-maint.sh &\n" /etc/rc.local
fi
2016-04-28 16:20:21 +00:00
# Start flight logging.
2016-04-03 03:01:04 +00:00
echo -e "\033[33m"
2016-04-28 16:20:21 +00:00
echo -e "Starting flight logging...\033[37m"
2016-04-29 16:40:14 +00:00
nohup ${BUILDDIR}/portal/logging/flights-maint.sh > /dev/null 2>&1 &
# Start maintenance..
echo -e "\033[33m"
echo -e "Starting flight logging...\033[37m"
nohup ${BUILDDIR}/portal/logging/flights-maint.sh > /dev/null 2>&1 &
2016-04-03 03:01:04 +00:00
fi
2016-04-01 13:46:32 +00:00
fi
2015-12-01 11:37:40 +00:00
2016-01-22 21:07:08 +00:00
## SETUP THE PORTAL WEBSITE
2015-12-01 11:37:40 +00:00
2016-01-22 21:07:08 +00:00
echo -e "\033[33m"
echo -e "Placing portal files in Lighttpd's root directory...\033[37m"
sudo cp -R ${HTMLDIR}/* ${DOCUMENTROOT}
2016-01-24 05:09:19 +00:00
echo -e "\033[33m"
echo "Setting permissions on portal folders...\033[37m"
2016-02-02 15:38:32 +00:00
sudo chmod 777 ${DOCUMENTROOT}/graphs/
2016-04-29 16:40:14 +00:00
sudo chmod 777 ${DOCUMENTROOT}/classes/
sudo chmod 777 ${DOCUMENTROOT}/data/
sudo chmod 666 ${DOCUMENTROOT}/data/*
2016-01-24 05:09:19 +00:00
echo -e "\033[33m"
echo "Setting up performance graphs..."
echo -e "\033[37m"
chmod +x $BASHDIR/portal/graphs.sh
$BASHDIR/portal/graphs.sh
2016-01-24 01:53:27 +00:00
## CHECK IF DUMP978 HAS BEEN BUILT
if [ -f $BUILDDIR/dump978/dump978 ] && [ -f $BUILDDIR/dump978/uat2text ] && [ -f $BUILDDIR/dump978/uat2esnt ] && [ -f $BUILDDIR/dump978/uat2json ]; then
echo -e "\033[33m"
echo -e "Configuring dump978 map...\033[37m"
# Check if the heywhatsthis.com range position file has already been downloaded.
if [ ! -f ${HTMLDIR}/dump978/upintheair.json ]; then
# Check if a heywhatsthat.com range file exists in the dump1090 HTML folder.
if [ -f /usr/share/dump1090-mutability/html/upintheair.json ]; then
echo -e "\033[33m"
echo -e "Copying heywhatsthat.com range file from dump1090 installation...\033[37m"
sudo cp /usr/share/dump1090-mutability/html/upintheair.json ${HTMLDIR}/dump978/
else
echo -e "\033[33m"
echo "The dump978 map is able to display terrain limit rings using data obtained"
echo "from the website http://www.heywhatsthat.com. Some work will be required on your"
echo "part including visiting http://www.heywhatsthat.com and generating a new"
echo "panorama set to your location."
echo -e "\033[37m"
read -p "Do you wish to add terrain limit rings to the dump1090 map? [Y/n] " ADDTERRAINRINGS
2016-05-12 16:33:11 +00:00
if [[ ! $ADDTERRAINRINGS =~ ^[Nn]$ ]]; then
2016-01-24 01:53:27 +00:00
echo -e "\033[31m"
echo "READ THE FOLLOWING INSTRUCTION CAREFULLY!"
echo -e "\033[33m"
echo "To set up terrain limit rings you will need to first generate a panorama on the website"
echo "heywhatsthat.com. To do so visit the following URL:"
echo ""
echo " http://www.heywhatsthat.com"
echo ""
echo "Once the webpage has loaded click on the tab titled New panorama. Fill out the required"
echo "information in the form to the left of the map."
echo ""
echo "After submitting the form your request will be put into a queue to be generated shortly."
echo "You will be informed when the generation of your panorama has been completed."
echo ""
echo "Once generated visit your newly created panorama. Near the top left of the page you will"
echo "see a URL displayed which will point you to your newly created panorama. Within this URL's"
echo "query string you will see ?view=XXXXXXXX where XXXXXXXX is the identifier for this panorama."
echo "Enter below the letters and numbers making up the view identifier displayed there."
echo ""
echo "Positions for terrain rings for both 10,000 and 40,000 feet will be downloaded by this"
echo "script once the panorama has been generated and you are ready to continue."
echo -e "\033[37m"
read -p "Your heywhatsthat.com view identifier: " HEYWHATSTHATVIEWID
read -e -p "First ring altitude in meters (default 3048 meters or 10000 feet): " -i "3048" HEYWHATSTHATRINGONE
read -e -p "Second ring altitude in meters (default 12192 meters or 40000 feet): " -i "12192" HEYWHATSTHATRINGTWO
# Download the generated panoramas JSON data.
echo -e "\033[33m"
echo "Downloading JSON data pertaining to the panorama ID you supplied..."
echo -e "\033[37m"
sudo wget -O ${HTMLDIR}/dump978/upintheair.json "http://www.heywhatsthat.com/api/upintheair.json?id=${HEYWHATSTHATVIEWID}&refraction=0.25&alts=$HEYWHATSTHATRINGONE,$HEYWHATSTHATRINGTWO"
fi
fi
fi
fi
2016-01-22 21:07:08 +00:00
echo -e "\033[33m"
echo -e "Setting permissions on data files...\033[37m"
2016-01-26 16:23:53 +00:00
sudo chmod 777 ${DOCUMENTROOT}/data/*.xml
2016-01-22 21:07:08 +00:00
echo -e "\033[33m"
echo -e "Removing conflicting redirect from the Lighttpd dump1090.conf file...\033[37m"
# Remove this line completely.
2016-01-24 05:09:19 +00:00
sudo sed -i "/$(echo ' "^/dump1090$" => "/dump1090/gmap.html"' | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/d" /etc/lighttpd/conf-available/89-dump1090.conf
2016-01-22 21:07:08 +00:00
# Remove the trailing coma from this line.
2016-01-24 05:09:19 +00:00
sudo sed -i "s/$(echo '"^/dump1090/$" => "/dump1090/gmap.html",' | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/$(echo '"^/dump1090/$" => "/dump1090/gmap.html"' | sed -e 's/\\/\\\\/g' -e 's/\//\\\//g' -e 's/&/\\\&/g')/g" /etc/lighttpd/conf-available/89-dump1090.conf
2016-01-22 21:07:08 +00:00
echo -e "\033[33m"
echo -e "Configuring Lighttpd...\033[37m"
2016-01-26 16:23:53 +00:00
sudo tee /etc/lighttpd/conf-available/89-adsb-portal.conf > /dev/null <<EOF
2016-01-22 21:07:08 +00:00
# Block all access to the data directory accept for local requests.
2016-01-24 05:09:19 +00:00
\$HTTP["remoteip"] !~ "127.0.0.1" {
\$HTTP["url"] =~ "^/data/" {
2016-01-22 21:07:08 +00:00
url.access-deny = ( "" )
}
}
EOF
2016-01-24 05:09:19 +00:00
echo -e "\033[33m"
echo -e "Enabling Lighttpd portal configuration...\033[37m"
sudo ln -s /etc/lighttpd/conf-available/89-adsb-portal.conf /etc/lighttpd/conf-enabled/89-adsb-portal.conf
2016-01-22 21:07:08 +00:00
echo -e "\033[33m"
2016-01-24 01:53:27 +00:00
echo -e "Enabling the Lighttpd fastcgi-php module...\033[37m"
sudo lighty-enable-mod fastcgi-php
echo -e "\033[33m"
if pgrep "lighttpd" > /dev/null; then
echo "Reloading Lighttpd..."
2016-01-24 05:09:19 +00:00
echo -e "\033[37m"
2016-01-24 01:53:27 +00:00
sudo /etc/init.d/lighttpd force-reload
else
echo "Starting Lighttpd..."
2016-01-24 05:09:19 +00:00
echo -e "\033[37m"
2016-01-24 01:53:27 +00:00
sudo /etc/init.d/lighttpd start
fi
2016-01-22 21:07:08 +00:00
## SETUP COMPLETE
2015-12-01 11:37:40 +00:00
echo -e "\033[33m"
echo "Installation and configuration of the performance graphs is now complete."
echo "Please look over the output generated to be sure no errors were encountered."
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE
2016-04-14 15:59:16 +00:00
clear
2016-05-12 16:33:11 +00:00
# This assigns the first IP address in the list to the $IPADDRESS variable.
IPADDRESS=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'`
2016-05-12 16:33:11 +00:00
2016-04-14 15:59:16 +00:00
# Display further portal setup instructions.
2016-04-22 18:58:55 +00:00
echo -e "\033[31m"
2016-04-14 15:59:16 +00:00
echo "PORTAL SETUP IS NOT YET COMPLETE"
echo -e "\033[33m"
echo "In order to complete the portal setup process visit the following URL in your favorite web browser."
echo ""
2016-05-12 16:33:11 +00:00
echo "http://${IPADDRESS}/install/"
2016-04-14 15:59:16 +00:00
echo ""
echo "Enter the requested information and submit the form to complete the portal setup."
echo "It is recomended that after setting up the portal you delete the install directory."
2016-04-14 15:59:16 +00:00
echo -e "\033[37m"
read -p "Press enter to continue..." CONTINUE