kopia lustrzana https://github.com/jprochazka/adsb-receiver
				
				
				
			AboveTustin Setup about complete.
							rodzic
							
								
									64fb59691a
								
							
						
					
					
						commit
						0fdca06e28
					
				| 
						 | 
				
			
			@ -23,6 +23,7 @@ The following is a history of the changes made to this project.
 | 
			
		|||
* Yes set to default when asked whether to bind dump1090-mutability to all IP addresses.
 | 
			
		||||
* Fixed issue with install script causing PiAware to not upgrade.
 | 
			
		||||
* Fixed collectd graph generation script so it works with newer versions of rrdtool.
 | 
			
		||||
* The navigation bar for the default portal template has been modified to fit better.
 | 
			
		||||
 | 
			
		||||
## v2.4.0 *(September 27th, 2016)*
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,12 +31,6 @@
 | 
			
		|||
#                                                                                   #
 | 
			
		||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
########################################
 | 
			
		||||
# ADD PHANTOMJSVERSION TO VARIABLES.SH #
 | 
			
		||||
########################################
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## VARIABLES
 | 
			
		||||
 | 
			
		||||
PROJECTROOTDIRECTORY="$PWD"
 | 
			
		||||
| 
						 | 
				
			
			@ -56,7 +50,7 @@ echo ""
 | 
			
		|||
echo -e "\e[92m  Setting up AboveTustin..."
 | 
			
		||||
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[96m"
 | 
			
		||||
echo ""
 | 
			
		||||
whiptail --backtitle "$ADSB_PROJECTTITLE" --title "PiAware Setup" --yesno "AboveTustin is an ADS-B Twitter Bot. Uses dump1090-mutability to track airplanes and then tweets whenever an airplane flies overhead.\n\n  https://github.com/kevinabrandon/AboveTustin\n\nContinue setting up AboveTustin?" 13 78
 | 
			
		||||
whiptail --backtitle "$ADSB_PROJECTTITLE" --title "AboveTustin Setup" --yesno "AboveTustin is an ADS-B Twitter Bot. Uses dump1090-mutability to track airplanes and then tweets whenever an airplane flies overhead.\n\n  https://github.com/kevinabrandon/AboveTustin\n\nContinue setting up AboveTustin?" 13 78
 | 
			
		||||
CONTINUESETUP=$?
 | 
			
		||||
if [ $CONTINUESETUP = 1 ]; then
 | 
			
		||||
    # Setup has been halted by the user.
 | 
			
		||||
| 
						 | 
				
			
			@ -70,30 +64,119 @@ if [ $CONTINUESETUP = 1 ]; then
 | 
			
		|||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
ADDCONTRIB=""
 | 
			
		||||
BUILDPHANTOMJS=""
 | 
			
		||||
PHANTOMJSEXISTS="false"
 | 
			
		||||
## CHECK IF A PHANTOMJS ALREADY EXISTS OR IF A PRECOMPILED BINARY IS AVAILABLE FOR THIS DEVICE
 | 
			
		||||
 | 
			
		||||
echo -e "\e[95m  Checking for PhantomJS...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
if [ -f /usr/bin/phantomjs ] && [ `phantomjs --version` = $PHANTOMJSVERSION ]; then
 | 
			
		||||
    # A PhantomJS binary which is the proper version appears to exist on this device.
 | 
			
		||||
    echo -e "\e[94m  PhantomJS is present on this device and is the proper version...\e[97m"
 | 
			
		||||
    PHANTOMJSEXISTS="true"
 | 
			
		||||
else
 | 
			
		||||
    echo -e "\e[91m  PhantomJS is not present on this device or is not the proper version...\e[97m"
 | 
			
		||||
    PHANTOMJSEXISTS="false"
 | 
			
		||||
    echo -e "\e[94m  Checking if a precompiled PhantomJS binary is available for download...\e[97m"
 | 
			
		||||
    echo -e "\e[94m  Detecting CPU architeture...\e[97m"
 | 
			
		||||
    CPUARCHITECTURE=`uname -m`
 | 
			
		||||
    echo -e "\e[94m  CPU architecture detected as $CPUARCHITECTURE...\e[97m"
 | 
			
		||||
    if [ $CPUARCHITECTURE = "x86_64" ] || or [  $CPUARCHITECTURE = "i686" ]; then
 | 
			
		||||
        # A precompiled binary should be available for this device.
 | 
			
		||||
        echo -e "\e[94m  A precompiled PhantomJS binary appears to be available for this CPU's arcitecture...\e[97m"
 | 
			
		||||
        BINARYAVAILABLE="true"
 | 
			
		||||
    else
 | 
			
		||||
        # A precompiled binary does not appear to be available for this device.
 | 
			
		||||
        echo -e "\e[94m  A precompiled PhantomJS binary does not appear to be available for this CPU's arcitecture...\e[97m"
 | 
			
		||||
        BINARYAVAILABLE="false"
 | 
			
		||||
        # Warn the user of the build time if there is no binary available for download.
 | 
			
		||||
        # The user should be allowed to cancel out of the setup process at this time.
 | 
			
		||||
        whiptail --backtitle "$ADSB_PROJECTTITLE" --title "PhantomJS Binary Not Available" --yesno "It appears there is not a precompiled PhantomJS binary available for your devices architecture.\n\nThis script is capable of downloading and compiling the PhantomJS source but THIS MAY TAKE AN EXTREMELY LONG TO TO COMPLETE. Expect the build process to range anywhere from a half our to literally hours.\n\nDo you wish to compile PhantomJS from source?" 13 78
 | 
			
		||||
        CONTINUESETUP=$?
 | 
			
		||||
        if [ $CONTINUESETUP = 1 ]; then
 | 
			
		||||
            # Setup has been halted by the user.
 | 
			
		||||
            echo -e "\e[91m  \e[5mINSTALLATION HALTED!\e[25m"
 | 
			
		||||
            echo -e "  Setup has been halted at the request of the user."
 | 
			
		||||
            echo ""
 | 
			
		||||
            echo -e "\e[93m----------------------------------------------------------------------------------------------------"
 | 
			
		||||
            echo -e "\e[92m  AboveTustin setup halted.\e[39m"
 | 
			
		||||
            echo ""
 | 
			
		||||
            read -p "Press enter to continue..." CONTINUE
 | 
			
		||||
            exit 1
 | 
			
		||||
        fi
 | 
			
		||||
        echo -e "\e[94m  Will attempt to build the PhantomJS binary from source...\e[97m"
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
## GATHER TWITTER API INFORMATION FROM THE USER
 | 
			
		||||
 | 
			
		||||
whiptail --backtitle "$ADSB_PROJECTTITLE" --title "Twiter Keys and Tokens" --yesno "In order to send Tweets to Twitter using AboveTustin you will need to obtain the proper keys and tokens from Twitter. You will need to sign up for a Twitter developer account at https://apps.twitter.com and create an application there in order to obtain this information.\n\nMore information on obtaining Twitter keys and access tokens can be found in the projects wiki page.\n\nhttps://github.com/jprochazka/adsb-receiver/wiki/Setting-Up-AboveTustin\n\nProceed with the AboveTustin setup?" 20 78
 | 
			
		||||
CONTINUESETUP=$?
 | 
			
		||||
if [ $CONTINUESETUP = 1 ]; then
 | 
			
		||||
    # Setup has been halted by the user.
 | 
			
		||||
    echo -e "\e[91m  \e[5mINSTALLATION HALTED!\e[25m"
 | 
			
		||||
    echo -e "  Setup has been halted at the request of the user."
 | 
			
		||||
    echo ""
 | 
			
		||||
    echo -e "\e[93m----------------------------------------------------------------------------------------------------"
 | 
			
		||||
    echo -e "\e[92m  AboveTustin setup halted.\e[39m"
 | 
			
		||||
    echo ""
 | 
			
		||||
    read -p "Press enter to continue..." CONTINUE
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# If any exist assign the current Twitter keys and access tokens to variables.
 | 
			
		||||
 | 
			
		||||
TWITTERACCESSTOKEN_TITLE="Twitter Access Token"
 | 
			
		||||
while [[ -z $TWITTERACCESSTOKEN ]]; do
 | 
			
		||||
    TWITTERACCESSTOKEN=""
 | 
			
		||||
    if [ -f $BUILDDIRECTORY/AboveTustin/keys/token ]; then
 | 
			
		||||
        TWITTERACCESSTOKEN=`cat $BUILDDIRECTORY/AboveTustin/keys/token`
 | 
			
		||||
    fi
 | 
			
		||||
    TWITTERACCESSTOKEN=$(whiptail --backtitle "$ADSB_PROJECTTITLE" --title "$TWITTERACCESSTOKEN_TITLE" --nocancel --inputbox "\nEnter your Twitter Access Token." 7 78 "$TWITTERACCESSTOKEN" 3>&1 1>&2 2>&3)
 | 
			
		||||
    TWITTERACCESSTOKEN_TITLE="Twitter Access Token (REQUIRED)"
 | 
			
		||||
done
 | 
			
		||||
TWITTERACCESSTOKENSECRET_TITLE="Twitter Access Token Secret"
 | 
			
		||||
while [[ -z $TWITTERACCESSTOKENSECRET ]]; do
 | 
			
		||||
    TWITTERACCESSTOKENSECRET=""
 | 
			
		||||
    if [ -f $BUILDDIRECTORY/AboveTustin/keys/token_secret ]; then
 | 
			
		||||
        TWITTERACCESSTOKENSECRET=`cat $BUILDDIRECTORY/AboveTustin/keys/token_secret`
 | 
			
		||||
    fi
 | 
			
		||||
    TWITTERACCESSTOKENSECRET=$(whiptail --backtitle "$ADSB_PROJECTTITLE" --title "$TWITTERACCESSTOKENSECRET_TITLE" --nocancel --inputbox "\nEnter your Twitter Access Token Secret." 7 " $TWITTERACCESSTOKENSECRET"78 3>&1 1>&2 2>&3)
 | 
			
		||||
    TWITTERACCESSTOKENSECRET_TITLE="Twitter Access Token Secret (REQUIRED)"
 | 
			
		||||
done
 | 
			
		||||
TWITTERCONSUMERKEY_TITLE="Twitter Consumer Key"
 | 
			
		||||
while [[ -z $TWITTERCONSUMERKEY ]]; do
 | 
			
		||||
    TWITTERCONSUMERKEY=""
 | 
			
		||||
    if [ -f $BUILDDIRECTORY/AboveTustin/keys/consumer_key ]; then
 | 
			
		||||
        TWITTERCONSUMERKEY=`cat $BUILDDIRECTORY/AboveTustin/keys/consumer_key`
 | 
			
		||||
    fi
 | 
			
		||||
    TWITTERCONSUMERKEY=$(whiptail --backtitle "$ADSB_PROJECTTITLE" --title "$TWITTERCONSUMERKEY_TITLE" --nocancel --inputbox "\nEnter your Twitter Consumer Key." 7 78 "TWITTERCONSUMERKEY" 3>&1 1>&2 2>&3)
 | 
			
		||||
    TWITTERCONSUMERKEY_TITLE="Twitter Consumer Key (REQUIRED)"
 | 
			
		||||
done
 | 
			
		||||
TWITTERCONSUMERSECRET_TITLE="Twitter Consumer Secret"
 | 
			
		||||
while [[ -z $TWITTERCONSUMERSECRET ]]; do
 | 
			
		||||
    TWITTERCONSUMERSECRET=""
 | 
			
		||||
    if [ -f $BUILDDIRECTORY/AboveTustin/keys/consumer_secret ]; then
 | 
			
		||||
        TWITTERCONSUMERSECRET=`cat $BUILDDIRECTORY/AboveTustin/keys/consumer_secret`
 | 
			
		||||
    fi
 | 
			
		||||
    TWITTERCONSUMERSECRET=$(whiptail --backtitle "$ADSB_PROJECTTITLE" --title "$TWITTERCONSUMERSECRET_TITLE" --nocancel --inputbox "\nEnter your Twitter Consumer Secret." 7 78 "$TWITTERCONSUMERSECRET" 3>&1 1>&2 2>&3)
 | 
			
		||||
    TWITTERCONSUMERSECRET_TITLE="Twitter Consumer Secret (REQUIRED)"
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
## CHECK FOR PREREQUISITE PACKAGES
 | 
			
		||||
 | 
			
		||||
echo -e "\e[95m  Installing packages needed to build and fulfill dependencies...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
 | 
			
		||||
# The package ttf-mscorefonts-installer requires contrib be added to the Debian repositories contained in /etc/apt/sources.list.
 | 
			
		||||
# The contrib flag does not need to be added for Raspbian Jessie and Ubuntu only Debian so far.
 | 
			
		||||
if [ `lsb_release -si` = "Debian" ]; then
 | 
			
		||||
    echo -e "\e[94m  Adding the contrib component to the repositories contained sources.list...\e[97m"
 | 
			
		||||
    sudo sed -i 's/main/main contrib/g' /etc/apt/sources.list
 | 
			
		||||
    echo -e "\e[94m  Updating the repository package lists...\e[97m"
 | 
			
		||||
    sudo apt-get update
 | 
			
		||||
fi
 | 
			
		||||
CheckPackage ttf-mscorefonts-installer
 | 
			
		||||
CheckPackage python3-pip
 | 
			
		||||
 | 
			
		||||
# These packages are only needed if the user decided to build PhantomJS.
 | 
			
		||||
CheckPackage build-essential
 | 
			
		||||
CheckPackage g++
 | 
			
		||||
 | 
			
		||||
# Needed if the PhantomJS binary is downloaded.
 | 
			
		||||
CheckPackage bzip2
 | 
			
		||||
 | 
			
		||||
# These ackages are required even if the user chooses to download the binary.
 | 
			
		||||
CheckPackage libstdc++6
 | 
			
		||||
 | 
			
		||||
# This package is libc6 in Ubuntu.
 | 
			
		||||
CheckPackage glibc
 | 
			
		||||
CheckPackage libc6
 | 
			
		||||
 | 
			
		||||
CheckPackage flex
 | 
			
		||||
CheckPackage bison
 | 
			
		||||
CheckPackage gperf
 | 
			
		||||
| 
						 | 
				
			
			@ -105,121 +188,280 @@ CheckPackage libfontconfig1-dev
 | 
			
		|||
CheckPackage libicu-dev
 | 
			
		||||
CheckPackage libfreetype6
 | 
			
		||||
CheckPackage libssl-dev
 | 
			
		||||
 | 
			
		||||
# This package is libpng12-dev in Ubuntu.
 | 
			
		||||
CheckPackage libpng-dev
 | 
			
		||||
CheckPackage libpng12-dev
 | 
			
		||||
 | 
			
		||||
CheckPackage libjpeg-dev
 | 
			
		||||
CheckPackage python
 | 
			
		||||
CheckPackage libx11-dev
 | 
			
		||||
CheckPackage libxext-dev
 | 
			
		||||
CheckPackage libpng12-dev
 | 
			
		||||
CheckPackage libc6
 | 
			
		||||
 | 
			
		||||
# The package ttf-mscorefonts-installer requires contrib be added to the repositories contained in /etc/apt/sources.list.
 | 
			
		||||
# This package appears to be optional but without it the images generated may not look as good.
 | 
			
		||||
# The contrib flag does not need to be added for Raspbian Jessie and Ubuntu only Debian so far.
 | 
			
		||||
if [ $ADDCONTRIB = "" ]; then
 | 
			
		||||
 | 
			
		||||
    # THIS LINE NEEDS TO BE CHANGED TO WORK ON ALL DEBIAN FLAVORS!!!
 | 
			
		||||
    sudo sed -i '/deb http:\/\/ftp.us.debian.org\/debian\/wheezy main/s/$/ contrib/' file.sh
 | 
			
		||||
 | 
			
		||||
    sudo apt-get update
 | 
			
		||||
    CheckPackage ttf-mscorefonts-installer
 | 
			
		||||
if [ $BINARYAVAILABLE = "false" ]; then
 | 
			
		||||
    # These packages are only needed if the user decided to build PhantomJS.
 | 
			
		||||
    CheckPackage build-essential
 | 
			
		||||
    CheckPackage g++
 | 
			
		||||
else
 | 
			
		||||
    # Package needed if the prebuilt PhantomJS binary is to be downloaded.
 | 
			
		||||
    CheckPackage bzip2
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
## SETUP PHANTOMJS
 | 
			
		||||
## SETUP PHANTOMJS IF IT DOES NOT ALREADY EXIST ON THIS DEVICE
 | 
			
		||||
 | 
			
		||||
if [ $PHANTOMJSEXISTS = "false" ]; then
 | 
			
		||||
    if [ $BINARYAVAILABLE = "true" ]; then
 | 
			
		||||
 | 
			
		||||
        # DOWNLOAD THE PHANTOMJS BINARY
 | 
			
		||||
 | 
			
		||||
# Check if the PhantomJS binary already exists and it is the correct version.
 | 
			
		||||
if [ -f /usr/bin/phantomjs ] && [ `/usr/bin/phantomjs --version` = $PHANTOMJSVERSION ]; then
 | 
			
		||||
    PHANTOMJSEXISTS="true"
 | 
			
		||||
        echo ""
 | 
			
		||||
        echo -e "\e[95m  Downloading then placing the PhantomJS binary...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
 | 
			
		||||
        # Enter the root of the project build directory.
 | 
			
		||||
        echo -e "\e[94m  Entering the ADS-B Receiver Project build directory...\e[97m"
 | 
			
		||||
        cd $BUILDDIRECTORY
 | 
			
		||||
 | 
			
		||||
        # Download the proper PhantomJS binary.
 | 
			
		||||
        case $CPUARCHITECTURE in
 | 
			
		||||
            "x86_64")
 | 
			
		||||
                # Download the x86_64 version of the PhantomJS binary.
 | 
			
		||||
                echo -e "\e[94m  Downloading the official x86_64 PhantomJS v$PHANTOMJSVERSION binary for Linux...\e[97m"
 | 
			
		||||
                echo ""
 | 
			
		||||
                wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
 | 
			
		||||
                ;;
 | 
			
		||||
            "i686"
 | 
			
		||||
                # Download the i686 version of the PantomJS binary.
 | 
			
		||||
                echo -e "\e[94m  Downloading the official i686 PhantomJS v$PHANTOMJSVERSION binary for Linux...\e[97m"
 | 
			
		||||
                echo ""
 | 
			
		||||
                wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-i686.tar.bz2
 | 
			
		||||
                ;;
 | 
			
		||||
        esac
 | 
			
		||||
 | 
			
		||||
        echo -e "\e[94m  Extracting the PhantomJS binary archive...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
        bunzip2 -v phantomjs-${PHANTOMJSVERSION}-linux-$PHANTOMJSVERSION.tar.bz2
 | 
			
		||||
        tar -vxf phantomjs-${PHANTOMJSVERSION}-linux-$PHANTOMJSVERSION.tar
 | 
			
		||||
        rm -f phantomjs-${PHANTOMJSVERSION}-linux-$PHANTOMJSVERSION.tar
 | 
			
		||||
 | 
			
		||||
        # Move the binary into the /usr/bin directory and make it executable.
 | 
			
		||||
        echo -e "\e[94m  Copying the PhantomJS binary into the directory /usr/bin...\e[97m"
 | 
			
		||||
        sudo cp phantomjs-${PHANTOMJSVERSION}-linux-$PHANTOMJSVERSION/bin/phantomjs /usr/bin
 | 
			
		||||
        echo -e "\e[94m  Making the file /usr/bin/phantomjs executable...\e[97m"
 | 
			
		||||
        sudo chmod +x /usr/bin/phantomjs
 | 
			
		||||
 | 
			
		||||
    else
 | 
			
		||||
 | 
			
		||||
        # BUILD PHANTOMJS
 | 
			
		||||
 | 
			
		||||
        echo ""
 | 
			
		||||
        echo -e "\e[95m  Building then placing the PhantomJS binary...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
 | 
			
		||||
        # Download the source code.
 | 
			
		||||
        echo ""
 | 
			
		||||
        echo -e "\e[95m  Preparing the PhantomJS Git repository...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
        if [ -d $PHANTOMJSBUILDDIRECTORY ] && [ -d $PHANTOMJSBUILDDIRECTORY/.git ]; then
 | 
			
		||||
            # A directory with a git repository containing the source code already exists.
 | 
			
		||||
            echo -e "\e[94m  Entering the PhantomJS git repository directory...\e[97m"
 | 
			
		||||
            cd $PHANTOMJSBUILDDIRECTORY
 | 
			
		||||
            echo -e "\e[94m  Updating the local PhantomJS git repository...\e[97m"
 | 
			
		||||
            echo ""
 | 
			
		||||
            git pull --all
 | 
			
		||||
        else
 | 
			
		||||
            # A directory containing the source code does not exist in the build directory.
 | 
			
		||||
            echo -e "\e[94m  Entering the ADS-B Receiver Project build directory...\e[97m"
 | 
			
		||||
            cd $BUILDDIRECTORY
 | 
			
		||||
            echo -e "\e[94m  Cloning the PhantomJS git repository locally...\e[97m"
 | 
			
		||||
            echo ""
 | 
			
		||||
            git clone git://github.com/ariya/phantomjs.git
 | 
			
		||||
            echo ""
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        # Enter the PhantomJS build directory if not already there.
 | 
			
		||||
        if [ ! $PWD = $PHANTOMJSBUILDDIRECTORY ]; then
 | 
			
		||||
            echo -e "\e[94m  Entering the PhantomJS Git repository directory...\e[97m"
 | 
			
		||||
            cd $PHANTOMJSBUILDDIRECTORY
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        # Checkout the proper branch then init and update the submodules.
 | 
			
		||||
        echo -e "\e[94m  Checking out the branch $PHANTOMJSVERSION...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
        git checkout $PHANTOMJSVERSION
 | 
			
		||||
        echo ""
 | 
			
		||||
        echo -e "\e[94m  Initializing Git submodules...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
        git submodule init
 | 
			
		||||
        echo ""
 | 
			
		||||
        echo -e "\e[94m  Updating Git submodules...\e[97m"
 | 
			
		||||
        echo ""
 | 
			
		||||
        git submodule update
 | 
			
		||||
        echo ""
 | 
			
		||||
 | 
			
		||||
        # Compile and link the code.
 | 
			
		||||
        if [[ `uname -m` == "armv7l" ]] || [[ `uname -m` == "armv6l" ]] || [[ `uname -m` == "aarch64" ]]; then
 | 
			
		||||
            # Limit the amount of processors being used on Raspberry Pi devices.
 | 
			
		||||
            # Not doing will very likely cause the compile to fail due to an out of memory error.
 | 
			
		||||
            echo -e "\e[94m  Building PhantomJS... (Job will be limited to using 1 processor.)\e[97m"
 | 
			
		||||
            python build.py -j 1
 | 
			
		||||
        else
 | 
			
		||||
            echo -e "\e[94m  Building PhantomJS...\e[97m"
 | 
			
		||||
            python build.py
 | 
			
		||||
        fi
 | 
			
		||||
        echo ""
 | 
			
		||||
 | 
			
		||||
        # Test that the binary was built properly.
 | 
			
		||||
        if [ ! -f bin/pahntomjs ] || [ ! `bin/phantomjs --version` = $PHANTOMJSVERSION ]; then
 | 
			
		||||
            # If the dump978 binaries could not be found halt setup.
 | 
			
		||||
            echo ""
 | 
			
		||||
            echo -e "\e[91m  \e[5mINSTALLATION HALTED!\e[25m"
 | 
			
		||||
            echo -e "  THE PHANTOMJS BINARIES BUILD APPEARS TO HAVE FAILED."
 | 
			
		||||
            echo -e "  SETUP HAS BEEN TERMINATED!"
 | 
			
		||||
            echo ""
 | 
			
		||||
            echo -e "\e[93mThe PhantomJS binary appear to have not been built successfully..\e[39m"
 | 
			
		||||
            echo ""
 | 
			
		||||
            echo -e "\e[93m-------------------------------------------------------------------------------------------------------"
 | 
			
		||||
            echo -e "\e[92m  AboveTustin setup halted.\e[39m"
 | 
			
		||||
            echo ""
 | 
			
		||||
            read -p "Press enter to continue..." CONTINUE
 | 
			
		||||
            exit 1
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
        # Move the binary into the /usr/bin directory and make it executable.
 | 
			
		||||
        echo -e "\e[94m  Copying the PhantomJS binary into the directory /usr/bin...\e[97m"
 | 
			
		||||
        sudo cp bin/phantomjs /usr/bin
 | 
			
		||||
        echo -e "\e[94m  Making the file /usr/bin/phantomjs executable...\e[97m"
 | 
			
		||||
        sudo chmod +x /usr/bin/phantomjs
 | 
			
		||||
 | 
			
		||||
    fi
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# DOWNLOAD THE PHANTOMJS BINARY
 | 
			
		||||
## INSTALL THE NEEDED PYTHON MODULES
 | 
			
		||||
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[95m  Setting up the required Python modules...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
 | 
			
		||||
# Upgrade pip.
 | 
			
		||||
echo -e "\e[94m  Upgrading pip...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
sudo pip3 install --upgrade pip
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[94m  Upgrading virtualenv...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
sudo pip3 install --upgrade virtualenv
 | 
			
		||||
echo ""
 | 
			
		||||
 | 
			
		||||
# Install Python modules.
 | 
			
		||||
echo -e "\e[94m  Installing the selenium Python module...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
sudo pip3 install selenium
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[94m  Installing the twitter Python module...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
sudo pip3 install twitter
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[94m  Installing the python-dateutil Python module...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
sudo pip3 install python-dateutil
 | 
			
		||||
echo ""
 | 
			
		||||
 | 
			
		||||
## SETUP ABOVETUSTIN
 | 
			
		||||
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[95m  Downloading and configuring AboveTustin...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
 | 
			
		||||
echo -e "\e[94m  Entering the ADS-B Receiver Project build directory...\e[97m"
 | 
			
		||||
cd $BUILDDIRECTORY
 | 
			
		||||
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
 | 
			
		||||
#wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-i686.tar.bz2
 | 
			
		||||
bunzip2 -v phantomjs-2.1.1-linux-i686.tar.bz2
 | 
			
		||||
tar -vcxf phantomjs-2.1.1-linux-i686.tar
 | 
			
		||||
rm -f phantomjs-2.1.1-linux-i686.tar
 | 
			
		||||
sudo cp phantomjs-2.1.1-linux-i686/bin/phantomjs /usr/bin
 | 
			
		||||
sudo chmod +x /usr/bin/phantomjs
 | 
			
		||||
 | 
			
		||||
# BUILD PHANTOMJS
 | 
			
		||||
 | 
			
		||||
# Download the source code.
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[95m  Preparing the PhantomJS Git repository...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
if [ -d $PHANTOMJSBUILDDIRECTORY ] && [ -d $PHANTOMJSBUILDDIRECTORY/.git ]; then
 | 
			
		||||
echo -e "\e[94m  Checking if the AboveTustin Git repository has been cloned...\e[97m"
 | 
			
		||||
if [ -d $BUILDDIRECTORY/AboveTustin ] && [ -d $BUILDDIRECTORY/AboveTustin/.git ]; then
 | 
			
		||||
    # A directory with a git repository containing the source code already exists.
 | 
			
		||||
    echo -e "\e[94m  Entering the PhantomJS git repository directory...\e[97m"
 | 
			
		||||
    cd $PHANTOMJSBUILDDIRECTORY
 | 
			
		||||
    echo -e "\e[94m  Updating the local PhantomJS git repository...\e[97m"
 | 
			
		||||
    echo -e "\e[94m  Entering the AboveTustin git repository directory...\e[97m"
 | 
			
		||||
    cd $BUILDDIRECTORY/AboveTustin
 | 
			
		||||
    echo -e "\e[94m  Updating the local AboveTustin git repository...\e[97m"
 | 
			
		||||
    echo ""
 | 
			
		||||
    git pull --all
 | 
			
		||||
    git pull
 | 
			
		||||
else
 | 
			
		||||
    # A directory containing the source code does not exist in the build directory.
 | 
			
		||||
    echo -e "\e[94m  Entering the ADS-B Receiver Project build directory...\e[97m"
 | 
			
		||||
    mkdir -p $BUILDDIRECTORY
 | 
			
		||||
    cd $BUILDDIRECTORY
 | 
			
		||||
    echo -e "\e[94m  Cloning the PhantomJS git repository locally...\e[97m"
 | 
			
		||||
    echo -e "\e[94m  Cloning the AboveTustin git repository locally...\e[97m"
 | 
			
		||||
    echo ""
 | 
			
		||||
    git clone git://github.com/ariya/phantomjs.git
 | 
			
		||||
    git clone https://github.com/kevinabrandon/AboveTustin.git
 | 
			
		||||
    echo ""
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ ! $PWD = $PHANTOMJSBUILDDIRECTORY ]; then
 | 
			
		||||
    echo -e "\e[94m  Entering the PhantomJS Git repository directory...\e[97m"
 | 
			
		||||
    cd $PHANTOMJSBUILDDIRECTORY
 | 
			
		||||
# Make the logs directory if it does not already exist.
 | 
			
		||||
cho -e "Checking if the directory $BUILDDIRECTORY/AboveTustin/logs exists...\e[97m"
 | 
			
		||||
if [ ! -d $BUILDDIRECTORY/AboveTustin/logs ]; then
 | 
			
		||||
    echo -e "\e[94m  Creating the directory $BUILDDIRECTORY/AboveTustin/logs...\e[97m"
 | 
			
		||||
    mkdir $BUILDDIRECTORY/AboveTustin/logs
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo -e "\e[94m  Checking out the branch $PHANTOMJSVERSION...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
git checkout $PHANTOMJSVERSION
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[94m  Initializing Git submodules...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
git submodule init
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[94m  Updating Git submodules...\e[97m"
 | 
			
		||||
echo ""
 | 
			
		||||
git submodule update
 | 
			
		||||
 | 
			
		||||
# Compile and link the code.
 | 
			
		||||
if [[ `uname -m` == "armv7l" ]] || [[ `uname -m` == "armv6l" ]] || [[ `uname -m` == "aarch64" ]]; then
 | 
			
		||||
    # Limit the amount of processors being used on Raspberry Pi devices.
 | 
			
		||||
    echo ""
 | 
			
		||||
    echo -e "\e[94m  Building PhantomJS... (Job has been limited to using only 2 processors.)\e[97m"
 | 
			
		||||
    python build.py -j 2
 | 
			
		||||
else
 | 
			
		||||
    echo ""
 | 
			
		||||
    echo -e "\e[94m  Building PhantomJS...\e[97m"
 | 
			
		||||
    python build.py
 | 
			
		||||
# Make the key directory if it does not already exist.
 | 
			
		||||
echo -e "Checking if the directory $BUILDDIRECTORY/AboveTustin/keys exists...\e[97m"
 | 
			
		||||
if [ ! -d $BUILDDIRECTORY/AboveTustin/keys ]; then
 | 
			
		||||
    echo -e "\e[94m  Creating the directory $BUILDDIRECTORY/AboveTustin/keys...\e[97m"
 | 
			
		||||
    mkdir $BUILDDIRECTORY/AboveTustin/keys
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# MOVE THE PHANTOMJS BINARY AND SET THE PROPER PERMISSIONS
 | 
			
		||||
# Write out the files which will contain the user's Twitter keys and access tokens.
 | 
			
		||||
echo -e "\e[94m  Adding the supplied token to the Twitter Token file...\e[97m"
 | 
			
		||||
echo "$TWITTERACCESSTOKEN" > $BUILDDIRECTORY/AboveTustin/keys/token
 | 
			
		||||
echo -e "\e[94m  Adding the supplied token secret to the Twitter Token Secret file...\e[97m"
 | 
			
		||||
echo "$TWITTERACCESSTOKENSECRET" > $BUILDDIRECTORY/AboveTustin/keys/token_secret
 | 
			
		||||
echo -e "\e[94m  Adding the supplied consumer key to the Twitter Consumer Key file...\e[97m"
 | 
			
		||||
echo "$TWITTERCONSUMERKEY" > $BUILDDIRECTORY/AboveTustin/keys/consumer_key
 | 
			
		||||
echo -e "\e[94m  Adding the supplied consumer secret to the Twitter Consumer Secret file...\e[97m"
 | 
			
		||||
echo "$TWITTERCONSUMERSECRET" > $BUILDDIRECTORY/AboveTustin/keys/consumer_secret
 | 
			
		||||
 | 
			
		||||
# Add the run_tracker.sh script to /etc/rc.local so it is executed at boot up.
 | 
			
		||||
echo -e "\e[94m  Checking if the AboveTustin startup line is contained within the file /etc/rc.local...\e[97m"
 | 
			
		||||
if ! grep -Fxq "$BUILDDIRECTORY/AboveTustin/run_tracker.sh &" /etc/rc.local; then
 | 
			
		||||
    echo -e "\e[94m  Adding the AboveTustin startup line to the file /etc/rc.local...\e[97m"
 | 
			
		||||
    lnum=($(sed -n '/exit 0/=' /etc/rc.local))
 | 
			
		||||
    ((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i $BUILDDIRECTORY/AboveTustin/run_tracker.sh &\n" /etc/rc.local
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Kill any currently running instances of the run_tracker.sh script.
 | 
			
		||||
echo -e "\e[94m  Checking for any running run_tracker.sh processes...\e[97m"
 | 
			
		||||
PIDS=`ps -efww | grep -w "run_tracker.sh" | awk -vpid=$$ '$2 != pid { print $2 }'`
 | 
			
		||||
if [ ! -z "$PIDS" ]; then
 | 
			
		||||
    echo -e "\e[94m  Killing any running run_tracker.sh processes...\e[97m"
 | 
			
		||||
    sudo kill $PIDS
 | 
			
		||||
    sudo kill -9 $PIDS
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo -e "\e[94m  Checking for any running tracker.py processes...\e[97m"
 | 
			
		||||
PIDS=`ps -efww | grep -w "tracker.py" | awk -vpid=$$ '$2 != pid { print $2 }'`
 | 
			
		||||
if [ ! -z "$PIDS" ]; then
 | 
			
		||||
    echo -e "\e[94m  Killing any running tracker.py processes...\e[97m"
 | 
			
		||||
    sudo kill $PIDS
 | 
			
		||||
    sudo kill -9 $PIDS
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo -e "\e[94m  Checking for any running phantomjs processes...\e[97m"
 | 
			
		||||
PIDS=`ps -efww | grep -w "phantomjs" | awk -vpid=$$ '$2 != pid { print $2 }'`
 | 
			
		||||
if [ ! -z "$PIDS" ]; then
 | 
			
		||||
    echo -e "\e[94m  Killing any running phantomjs processes...\e[97m"
 | 
			
		||||
    sudo kill $PIDS
 | 
			
		||||
    sudo kill -9 $PIDS
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
echo -e "\e[94m  Executing the adsbexchange-netcat_maint.sh script...\e[97m"
 | 
			
		||||
sudo nohup $BUILDDIRECTORY/AboveTustin/run_tracker.sh > /dev/null 2>&1 &
 | 
			
		||||
 | 
			
		||||
## OVERTUSTIN SETUP COMPLETE
 | 
			
		||||
 | 
			
		||||
# Enter into the project root directory.
 | 
			
		||||
echo -e "\e[94m  Entering the ADS-B Receiver Project root directory...\e[97m"
 | 
			
		||||
cd $PROJECTROOTDIRECTORY
 | 
			
		||||
 | 
			
		||||
echo ""
 | 
			
		||||
echo -e "\e[94m  Moving the phantomjs binary into the directory /usr/bin...\e[97m"
 | 
			
		||||
sudo cp phantomjs /usr/bin
 | 
			
		||||
echo -e "\e[94m  Making the phantomjs binary executable...\e[97m"
 | 
			
		||||
sudo chmod +x /usr/bin/phantomjs
 | 
			
		||||
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
 | 
			
		||||
echo -e "\e[92m  OverTustin setup is complete.\e[39m"
 | 
			
		||||
echo ""
 | 
			
		||||
read -p "Press enter to continue..." CONTINUE
 | 
			
		||||
 | 
			
		||||
## SETUP SELENIUM
 | 
			
		||||
 | 
			
		||||
# Upgrade pip.
 | 
			
		||||
sudo pip3 install --upgrade pip
 | 
			
		||||
sudo pip3 install --upgrade virtualenv
 | 
			
		||||
 | 
			
		||||
sudo pip3 install selenium
 | 
			
		||||
 | 
			
		||||
## INSTALL THE PYTHON TWITTER PLUGIN
 | 
			
		||||
 | 
			
		||||
sudo pip3 install twitter
 | 
			
		||||
sudo pip3 install python-dateutil
 | 
			
		||||
 | 
			
		||||
## ABOVETUSTIN
 | 
			
		||||
 | 
			
		||||
git clone https://github.com/kevinabrandon/AboveTustin.git
 | 
			
		||||
exit 0
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -49,3 +49,6 @@ FR24CLIENTVERSIONI386="1.0.18-5"
 | 
			
		|||
# mlat-client
 | 
			
		||||
MLATCLIENTVERSION="0.2.6"
 | 
			
		||||
MLATCLIENTTAG="v0.2.6"
 | 
			
		||||
 | 
			
		||||
# PhantomJS
 | 
			
		||||
PHANTOMJSVERSION="2.1.1"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue