kopia lustrzana https://github.com/jprochazka/adsb-receiver
Beast Splitter and Duck DNS - Harmonized variables from $BLAH to ${BLAH}
rodzic
f43bdb06c1
commit
e2c2573682
|
|
@ -33,25 +33,25 @@
|
|||
|
||||
### INCLUDE EXTERNAL SCRIPTS
|
||||
|
||||
source $RECEIVER_BASH_DIRECTORY/variables.sh
|
||||
source $RECEIVER_BASH_DIRECTORY/functions.sh
|
||||
source ${RECEIVER_BASH_DIRECTORY}/variables.sh
|
||||
source ${RECEIVER_BASH_DIRECTORY}/functions.sh
|
||||
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "true" ]] ; then
|
||||
source $RECEIVER_CONFIGURATION_FILE
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "true" ]] ; then
|
||||
source ${RECEIVER_CONFIGURATION_FILE}
|
||||
fi
|
||||
|
||||
### BEGIN SETUP
|
||||
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
clear
|
||||
echo -e "\n\e[91m $RECEIVER_PROJECT_TITLE"
|
||||
echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}"
|
||||
fi
|
||||
echo ""
|
||||
echo -e "\e[92m Setting up beast-splitter..."
|
||||
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[96m"
|
||||
echo ""
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
whiptail --backtitle "$RECEIVER_PROJECT_TITLE" --title "Beast-Splitter Setup" --yesno "This is a helper utility for the Mode-S Beast.\n\nThe Beast provides a single data stream over a (USB) serial port. If you have more than one thing that wants to read that data stream, you need something to redistribute the data. This is what beast-splitter does.\n\n https://github.com/flightaware/beast-splitter\n\nContinue beast-splitter setup?" 15 78
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Beast-Splitter Setup" --yesno "This is a helper utility for the Mode-S Beast.\n\nThe Beast provides a single data stream over a (USB) serial port. If you have more than one thing that wants to read that data stream, you need something to redistribute the data. This is what beast-splitter does.\n\n https://github.com/flightaware/beast-splitter\n\nContinue beast-splitter setup?" 15 78
|
||||
if [[ $? -eq 1 ]] ; then
|
||||
# Setup has been halted by the user.
|
||||
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
|
||||
|
|
@ -83,21 +83,21 @@ CheckPackage dh-systemd
|
|||
### CONFIRM SETTINGS
|
||||
|
||||
# Confirm settings with user.
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
# Ask the beast-splitter listen port.
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
BEASTSPLITTER_LISTEN_PORT_TITLE="Listen Port"
|
||||
while [[ -z $BEASTSPLITTER_LISTEN_PORT ]]; do
|
||||
BEASTSPLITTER_LISTEN_PORT=$(whiptail --backtitle "$RECEIVER_PROJECT_TITLE" --title "$BEASTSPLITTER_LISTEN_PORT_TITLE" --nocancel --inputbox "\nPlease enter the port beast-splitter will listen on.\nThis must be a port which is currently not in use." 10 78 "30005" 3>&1 1>&2 2>&3)
|
||||
while [[ -z ${BEASTSPLITTER_LISTEN_PORT} ]]; do
|
||||
BEASTSPLITTER_LISTEN_PORT=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${BEASTSPLITTER_LISTEN_PORT}_TITLE" --nocancel --inputbox "\nPlease enter the port beast-splitter will listen on.\nThis must be a port which is currently not in use." 10 78 "30005" 3>&1 1>&2 2>&3)
|
||||
BEASTSPLITTER_LISTEN_PORT_TITLE="Listen Port (REQUIRED)"
|
||||
done
|
||||
fi
|
||||
|
||||
# Ask the beast-splitter connect port.
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
BEASTSPLITTER_CONNECT_PORT_TITLE="Connect Port"
|
||||
while [[ -z $BEASTSPLITTER_CONNECT_PORT ]]; do
|
||||
BEASTSPLITTER_CONNECT_PORT=$(whiptail --backtitle "$RECEIVER_PROJECT_TITLE" --title "$BEASTSPLITTER_CONNECT_PORT_TITLE" --nocancel --inputbox "\nPlease enter the port beast-splitter will connect to.\nThis is generally port 30104 on dump1090." 10 78 "30104" 3>&1 1>&2 2>&3)
|
||||
while [[ -z ${BEASTSPLITTER_CONNECT_PORT} ]]; do
|
||||
BEASTSPLITTER_CONNECT_PORT=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${BEASTSPLITTER_CONNECT_PORT}_TITLE" --nocancel --inputbox "\nPlease enter the port beast-splitter will connect to.\nThis is generally port 30104 on dump1090." 10 78 "30104" 3>&1 1>&2 2>&3)
|
||||
BEASTSPLITTER_CONNECT_PORT_TITLE="Connect Port (REQUIRED)"
|
||||
done
|
||||
fi
|
||||
|
|
@ -108,17 +108,17 @@ fi
|
|||
echo ""
|
||||
echo -e "\e[95m Preparing the beast-splitter Git repository...\e[97m"
|
||||
echo ""
|
||||
if [[ -d $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter ]] && [[ -d $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter/.git ]] ; then
|
||||
if [[ -d ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter ]] && [[ -d ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter/.git ]] ; then
|
||||
# A directory with a git repository containing the source code already exists.
|
||||
echo -e "\e[94m Entering the beast-splitter git repository directory...\e[97m"
|
||||
cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter
|
||||
cd ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter
|
||||
echo -e "\e[94m Updating the local beast-splitter git repository...\e[97m"
|
||||
echo ""
|
||||
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"
|
||||
cd $RECEIVER_BUILD_DIRECTORY/beast-splitter
|
||||
cd ${RECEIVER_BUILD_DIRECTORY}/beast-splitter
|
||||
echo -e "\e[94m Cloning the beast-splitter git repository locally...\e[97m"
|
||||
echo ""
|
||||
git clone https://github.com/flightaware/beast-splitter.git
|
||||
|
|
@ -129,39 +129,39 @@ fi
|
|||
echo ""
|
||||
echo -e "\e[95m Building and installing the beast-splitter package...\e[97m"
|
||||
echo ""
|
||||
if [[ ! "$PWD" = $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter ]] ; then
|
||||
if [[ ! "${PWD}" = ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter ]] ; then
|
||||
echo -e "\e[94m Entering the piaware_builder git repository directory...\e[97m"
|
||||
cd $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter
|
||||
cd ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter
|
||||
fi
|
||||
echo -e "\e[94m Executing the beast-splitter build script...\e[97m"
|
||||
echo ""
|
||||
dpkg-buildpackage -b
|
||||
echo ""
|
||||
echo -e "\e[94m Entering the ADS-B Receiver Project build directory...\e[97m"
|
||||
cd $RECEIVER_BUILD_DIRECTORY/beast-splitter
|
||||
cd ${RECEIVER_BUILD_DIRECTORY}/beast-splitter
|
||||
echo -e "\e[94m Installing the beast-splitter package...\e[97m"
|
||||
sudo dpkg -i beast-splitter_*.deb
|
||||
|
||||
## CREATE THE SCRIPT TO BE USED TO EXECUTE BEAST-SPLITTER
|
||||
|
||||
echo -e "\e[94m Creating the file beast-splitter_maint.sh...\e[97m"
|
||||
tee $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_maint.sh > /dev/null <<EOF
|
||||
tee ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter_maint.sh > /dev/null <<EOF
|
||||
#! /bin/sh
|
||||
while true
|
||||
do
|
||||
sleep 30
|
||||
beast-splitter --serial /dev/beast --listen $BEASTSPLITTER_LISTEN_PORT:R --connect localhost:$BEASTSPLITTER_CONNECT_PORT:R
|
||||
beast-splitter --serial /dev/beast --listen ${BEASTSPLITTER_LISTEN_PORT}:R --connect localhost:${BEASTSPLITTER_CONNECT_PORT}:R
|
||||
done
|
||||
EOF
|
||||
|
||||
echo -e "\e[94m Setting file permissions for beast-splitter_maint.sh...\e[97m"
|
||||
sudo chmod +x $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_maint.sh
|
||||
sudo chmod +x ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter_maint.sh
|
||||
|
||||
echo -e "\e[94m Checking if the beast-splitter startup line is contained within the file /etc/rc.local...\e[97m"
|
||||
if ! grep -Fxq "$RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_maint.sh &" /etc/rc.local; then
|
||||
if ! grep -Fxq "${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter_maint.sh &" /etc/rc.local; then
|
||||
echo -e "\e[94m Adding the beast-splitter 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 $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_maint.sh &\n" /etc/rc.local
|
||||
((lnum>0)) && sudo sed -i "${lnum[$((${#lnum[@]}-1))]}i ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter_maint.sh &\n" /etc/rc.local
|
||||
fi
|
||||
|
||||
## START BEAST-SPLITTER
|
||||
|
|
@ -173,30 +173,30 @@ echo ""
|
|||
# Kill any currently running instances of the beast-splitter_maint.sh script.
|
||||
echo -e "\e[94m Checking for any running beast-splitter_maint.sh processes...\e[97m"
|
||||
PIDS=`ps -efww | grep -w "beast-splitter_maint.sh" | awk -vpid=$$ '$2 != pid { print $2 }'`
|
||||
if [[ ! -z "$PIDS" ]] ; then
|
||||
if [[ ! -z "${PIDS}" ]] ; then
|
||||
echo -e "\e[94m Killing any running beast-splitter_maint.sh processes...\e[97m"
|
||||
sudo kill $PIDS
|
||||
sudo kill -9 $PIDS
|
||||
sudo kill ${PIDS}
|
||||
sudo kill -9 ${PIDS}
|
||||
fi
|
||||
# Kill any currently running instances beast-splitter.
|
||||
echo -e "\e[94m Checking for any running beast-splitter processes...\e[97m"
|
||||
PIDS=`ps -efww | grep -w "beast-splitter" | awk -vpid=$$ '$2 != pid { print $2 }'`
|
||||
if [[ ! -z "$PIDS" ]] ; then
|
||||
if [[ ! -z "${PIDS}" ]] ; then
|
||||
echo -e "\e[94m Killing any running beast-splitter processes...\e[97m"
|
||||
sudo kill $PIDS
|
||||
sudo kill -9 $PIDS
|
||||
sudo kill ${PIDS}
|
||||
sudo kill -9 ${PIDS}
|
||||
fi
|
||||
|
||||
echo -e "\e[94m Executing the beast-splitter_maint.sh script...\e[97m"
|
||||
echo ""
|
||||
sudo nohup $RECEIVER_BUILD_DIRECTORY/beast-splitter/beast-splitter_maint.sh > /dev/null 2>&1 &
|
||||
sudo nohup ${RECEIVER_BUILD_DIRECTORY}/beast-splitter/beast-splitter_maint.sh > /dev/null 2>&1 &
|
||||
echo ""
|
||||
|
||||
### SETUP COMPLETE
|
||||
|
||||
# Enter into the project root directory.
|
||||
echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m"
|
||||
cd $RECEIVER_ROOT_DIRECTORY
|
||||
cd ${RECEIVER_ROOT_DIRECTORY}
|
||||
|
||||
echo ""
|
||||
echo -e "\e[93m-------------------------------------------------------------------------------------------------------"
|
||||
|
|
|
|||
|
|
@ -33,25 +33,25 @@
|
|||
|
||||
### INCLUDE EXTERNAL SCRIPTS
|
||||
|
||||
source $RECEIVER_BASH_DIRECTORY/variables.sh
|
||||
source $RECEIVER_BASH_DIRECTORY/functions.sh
|
||||
source ${RECEIVER_BASH_DIRECTORY}/variables.sh
|
||||
source ${RECEIVER_BASH_DIRECTORY}/functions.sh
|
||||
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "true" ]] ; then
|
||||
source $RECEIVER_CONFIGURATION_FILE
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "true" ]] ; then
|
||||
source ${RECEIVER_CONFIGURATION_FILE}
|
||||
fi
|
||||
|
||||
### BEGIN SETUP
|
||||
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
clear
|
||||
echo -e "\n\e[91m $RECEIVER_PROJECT_TITLE"
|
||||
echo -e "\n\e[91m ${RECEIVER_PROJECT_TITLE}"
|
||||
fi
|
||||
echo ""
|
||||
echo -e "\e[92m Setting up the Duck DNS dynamic DNS update script..."
|
||||
echo -e "\e[93m----------------------------------------------------------------------------------------------------\e[96m"
|
||||
echo ""
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
whiptail --backtitle "$RECEIVER_PROJECT_TITLE" --title "Duck DNS Dynamic DNS" --yesno "Duck DNS is a free dynamic DNS service hosted on Amazon VPC.\n\nPLEASE NOTE:\n\nBefore continuing this setup it is recommended that you visit the Duck DNS website and signup for then setup a sub domain which will be used by this device. You will need both the domain and token supplied to you after setting up your account.\n\nhttp://www.duckdns.org\n\nContinue with Duck DNS update script setup?" 18 78
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "Duck DNS Dynamic DNS" --yesno "Duck DNS is a free dynamic DNS service hosted on Amazon VPC.\n\nPLEASE NOTE:\n\nBefore continuing this setup it is recommended that you visit the Duck DNS website and signup for then setup a sub domain which will be used by this device. You will need both the domain and token supplied to you after setting up your account.\n\nhttp://www.duckdns.org\n\nContinue with Duck DNS update script setup?" 18 78
|
||||
if [[ $? -eq 1 ]] ; then
|
||||
# Setup has been halted by the user.
|
||||
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
|
||||
|
|
@ -79,58 +79,58 @@ CheckPackage curl
|
|||
### CONFIRM SETTINGS
|
||||
|
||||
# Confirm settings with user.
|
||||
if [[ "$RECEIVER_AUTOMATED_INSTALL" = "false" ]] ; then
|
||||
if [[ "${RECEIVER_AUTOMATED_INSTALL}" = "false" ]] ; then
|
||||
# Ask for the user sub domain to be assigned to this device.
|
||||
DUCKDNS_DOMAIN_TITLE="Duck DNS Sub Domain"
|
||||
while [[ -z $DOMAIN ]]; do
|
||||
DUCKDNS_DOMAIN=$(whiptail --backtitle "$RECEIVER_PROJECT_TITLE" --title "$DUCKDNS_DOMAIN_TITLE" --nocancel --inputbox "\nPlease enter the Duck DNS sub domain you selected after registering.\nIf you do not have one yet visit http://www.ducknds.org to obtain one." 9 78 3>&1 1>&2 2>&3)
|
||||
while [[ -z ${DOMAIN} ]]; do
|
||||
DUCKDNS_DOMAIN=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DUCKDNS_DOMAIN_TITLE}" --nocancel --inputbox "\nPlease enter the Duck DNS sub domain you selected after registering.\nIf you do not have one yet visit http://www.ducknds.org to obtain one." 9 78 3>&1 1>&2 2>&3)
|
||||
DUCKDNS_DOMAIN_TITLE="Duck DNS Sub Domain (REQUIRED)"
|
||||
done
|
||||
# Ask for the Duck DNS token to be assigned to this receiver.
|
||||
DUCKDNS_TOKEN_TITLE="Duck DNS Token"
|
||||
while [[ -z $TOKEN ]]; do
|
||||
DUCKDNS_TOKEN=$(whiptail --backtitle "$RECEIVER_PROJECT_TITLE" --title "$DUCKDNS_TOKEN_TITLE" --nocancel --inputbox "\nPlease enter your Duck DNS token." 8 78 3>&1 1>&2 2>&3)
|
||||
while [[ -z ${TOKEN} ]]; do
|
||||
DUCKDNS_TOKEN=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" --title "${DUCKDNS_TOKEN_TITLE}" --nocancel --inputbox "\nPlease enter your Duck DNS token." 8 78 3>&1 1>&2 2>&3)
|
||||
DUCKDNS_TOKEN_TITLE="Duck DNS Token (REQUIRED)"
|
||||
done
|
||||
fi
|
||||
|
||||
# Create a duckdns directory within the build directory if it does not already exist.
|
||||
if [[ ! -d $RECEIVER_BUILD_DIRECTORY/duckdns ]] ; then
|
||||
echo -e "\e[94m Creating the directory $RECEIVER_BUILD_DIRECTORY/duckdns...\e[97m"
|
||||
mkdir $RECEIVER_BUILD_DIRECTORY/duckdns
|
||||
if [[ ! -d ${RECEIVER_BUILD_DIRECTORY}/duckdns ]] ; then
|
||||
echo -e "\e[94m Creating the directory ${RECEIVER_BUILD_DIRECTORY}/duckdns...\e[97m"
|
||||
mkdir ${RECEIVER_BUILD_DIRECTORY}/duckdns
|
||||
fi
|
||||
|
||||
# Create then set permissions on the file duck.sh.
|
||||
echo -e "\e[94m Creating the Duck DNS update script...\e[97m"
|
||||
tee $RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh > /dev/null <<EOF
|
||||
echo url="https://www.duckdns.org/update?domains=$DOMAIN&token=$TOKEN&ip=" | curl -k -o $RECEIVER_BUILD_DIRECTORY/duckdns/duck.log -K -
|
||||
tee ${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.sh > /dev/null <<EOF
|
||||
echo url="https://www.duckdns.org/update?domains=${DOMAIN}&token=${TOKEN}&ip=" | curl -k -o ${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.log -K -
|
||||
EOF
|
||||
|
||||
echo -e "\e[94m Setting execute permissions for only this user on the Duck DNS update script...\e[97m"
|
||||
chmod 700 $RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh
|
||||
chmod 700 ${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.sh
|
||||
|
||||
# Add job to the users crontab if it does not exist.
|
||||
echo -e "\e[94m Adding the Duck DNS update command to your crontab if it does not exist already...\e[97m"
|
||||
COMMAND="$RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh >/dev/null 2>&1"
|
||||
JOB="*/5 * * * * $COMMAND"
|
||||
COMMAND="${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.sh >/dev/null 2>&1"
|
||||
JOB="*/5 * * * * ${COMMAND}
|
||||
|
||||
# Should only add the job if the COMMAND does not already exist in the users crontab.
|
||||
(crontab -l | grep -v -F "$COMMAND" ; echo "$JOB") | crontab -
|
||||
(crontab -l | grep -v -F "${COMMAND}" ; echo "${JOB}") | crontab -
|
||||
|
||||
# The following command should remove the job from the users crontab.
|
||||
#(crontab -l | grep -v -F "$COMMAND" ) | crontab -
|
||||
#(crontab -l | grep -v -F "${COMMAND}" ) | crontab -
|
||||
|
||||
# Run the Duck DNS update script for the first time..
|
||||
echo -e "\e[94m Executing the Duck DNS update script...\e[97m"
|
||||
echo ""
|
||||
$RECEIVER_BUILD_DIRECTORY/duckdns/duck.sh
|
||||
${RECEIVER_BUILD_DIRECTORY}/duckdns/duck.sh
|
||||
echo ""
|
||||
|
||||
### SETUP COMPLETE
|
||||
|
||||
# Enter into the project root directory.
|
||||
echo -e "\e[94m Entering the ADS-B Receiver Project root directory...\e[97m"
|
||||
cd $RECEIVER_ROOT_DIRECTORY
|
||||
cd ${RECEIVER_ROOT_DIRECTORY}
|
||||
|
||||
echo ""
|
||||
echo -e "\e[93m-------------------------------------------------------------------------------------------------------"
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue