Script clean up.

pull/599/head
jprochazka 2024-08-13 12:27:56 -04:00
rodzic 6f8c727ced
commit b73b8ea016
8 zmienionych plików z 287 dodań i 364 usunięć

1
.gitignore vendored
Wyświetl plik

@ -14,4 +14,5 @@ build/libacars
build/piaware_builder
build/planefinder
build/package-archive
build/portal/graphs/__pycache__/
logs

Wyświetl plik

@ -2,10 +2,10 @@
The following is a history of the changes made to this project.
## v2.8.6 *(in development)*
## v2.8.6 *(August 13th, 2024)*
* The option to install ACARSDEC and ACARSERV is now available as a decoder option.
* ACARS data can be viewed via the existing PHP portal has been added.
* The option to install ACARSDEC and ACARSSERV is now available as a decoder option.
* ACARS data stored by ACARSSERV can be viewed via the existing PHP portal.
* Added the ability to reconfigure, rebuild, and reinstall both dump1090-fa and dump978.fa.
* Decoder scripts now ask for device assignments when additional decoders are being installed.
* Added "Contributors" to the copyright notice in the software license.

Wyświetl plik

@ -5,9 +5,6 @@
source $RECEIVER_BASH_DIRECTORY/variables.sh
source $RECEIVER_BASH_DIRECTORY/functions.sh
## BEGIN SETUP
clear
log_project_title
log_title_heading "Setting up the FlightAware Dump1090 decoder"

Wyświetl plik

@ -5,9 +5,6 @@
source $RECEIVER_BASH_DIRECTORY/variables.sh
source $RECEIVER_BASH_DIRECTORY/functions.sh
## BEGIN SETUP
clear
log_project_title
log_title_heading "Setting up the FlightAware Dump978 decoder"

Wyświetl plik

@ -1,79 +1,41 @@
#!/bin/bash
#####################################################################################
# ADS-B RECEIVER #
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015-2024 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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
## VARIABLES
PORTAL_BUILD_DIRECTORY="${RECEIVER_BUILD_DIRECTORY}/portal"
PORTAL_PYTHON_DIRECTORY="${PORTAL_BUILD_DIRECTORY}/python"
DATABASEENGINE=${ADSB_DATABASEENGINE}
DATABASEHOSTNAME=${ADSB_DATABASEHOSTNAME}
DATABASEUSER=${ADSB_DATABASEUSER}
DATABASEPASSWORD1=${ADSB_DATABASEPASSWORD1}
DATABASENAME=${ADSB_DATABASENAME}
## SETUP FLIGHT LOGGING
echo -e ""
echo -e "\e[95m Setting up core advanced portal features...\e[97m"
echo -e ""
log_heading "Setting up core advanced portal features"
case ${DATABASEENGINE} in
case $ADSB_PORTAL_DATABASE_ENGINE in
"MySQL")
echo -e "\e[94m Creating the flight Python configuration file for MySQL...\e[97m"
log_message "Creating the flight Python configuration file for MySQL"
tee ${PORTAL_PYTHON_DIRECTORY}/config.json > /dev/null <<EOF
{
"database":{"type":"mysql",
"host":"${DATABASEHOSTNAME}",
"user":"${DATABASEUSER}",
"passwd":"${DATABASEPASSWORD1}",
"db":"${DATABASENAME}"}
"host":"${ADSB_PORTAL_DATABASE_HOSTNAME}",
"user":"${ADSB_PORTAL_DATABASE_USER}",
"passwd":"${ADSB_PORTAL_DATABASE_PASSWORD1}",
"db":"${ADSB_PORTAL_DATABASE_NAME}"}
}
EOF
;;
"SQLite")
echo -e "\e[94m Creating the Python configuration file for SQLite...\e[97m"
log_message "Creating the Python configuration file for SQLite"
tee ${PORTAL_PYTHON_DIRECTORY}/config.json > /dev/null <<EOF
{
"database":{"type":"sqlite",
"host":"${DATABASEHOSTNAME}",
"user":"${DATABASEUSER}",
"passwd":"${DATABASEPASSWORD1}",
"db":"${DATABASENAME}"}
"host":"${ADSB_PORTAL_DATABASE_HOSTNAME}",
"user":"${ADSB_PORTAL_DATABASE_USER}",
"passwd":"${ADSB_PORTAL_DATABASE_PASSWORD1}",
"db":"${ADSB_PORTAL_DATABASE_NAME}"}
}
EOF
;;
*)
echo -e "\e[94m No core setup required...\e[97m"
log_message "No core setup required"
;;
esac

Wyświetl plik

@ -1,36 +1,5 @@
#!/bin/bash
#####################################################################################
# ADS-B RECEIVER #
#####################################################################################
# #
# This script is not meant to be executed directly. #
# Instead execute install.sh to begin the installation process. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# Copyright (c) 2015-2024 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. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
### VARIABLES
PORTAL_BUILD_DIRECTORY="${RECEIVER_BUILD_DIRECTORY}/portal"

Wyświetl plik

@ -31,8 +31,8 @@ log_heading "Installing Lighttpd if not already installed"
check_package lighttpd
log_message "Determining the lighttpd document root"
RAW_DOCUMENT_ROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`
LIGHTTPD_DOCUMENT_ROOT=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< ${RAW_DOCUMENT_ROOT}`
raw_document_root=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`
lighttpd_document_root=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< $raw_document_root`
## GATHER REQUIRED INFORMATION
@ -40,39 +40,39 @@ LIGHTTPD_DOCUMENT_ROOT=`sed 's/.*"\(.*\)"[^"]*$/\1/' <<< ${RAW_DOCUMENT_ROOT}`
log_heading "Gather information required to configure the portal"
log_message "Determining if a portal installation exists"
if [[ -f "${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php" ]]; then
if [[ -f $lighttpd_document_root/classes/settings.class.php ]]; then
log_message "An instance of The ADS-B Portal is installed"
RECEIVER_PORTAL_INSTALLED="true"
portal_installed="true"
else
log_message "The ADS-B Portal is not installed"
RECEIVER_PORTAL_INSTALLED="false"
portal_installed="false"
fi
if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" ]]; then
if [[ "${portal_installed}" = "true" ]]; then
log_message "Gathering information needed to proceed with setup"
DATABASEENGINE=`grep 'db_driver' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2`
if [[ "${DATABASEENGINE}" = "xml" ]]; then
database_engine=`grep 'db_driver' $lighttpd_document_root/classes/settings.class.php | tail -n1 | cut -d\' -f2`
if [[ "${database_engine}" = "xml" ]]; then
log_message "This is a lite installation of the portal"
ADVANCED="false"
advanced_installation="false"
else
log_message "This is an advanced installation of the portal"
ADVANCED="true"
advanced_installation="true"
fi
if [[ "${ADVANCED}" = "true" ]]; then
case "${DATABASEENGINE}" in
if [[ "${advanced_installation}" = "true" ]]; then
case "${database_engine}" in
"mysql")
log_message "The MySQL database engine is being used"
DATABASEENGINE="MySQL"
database_engine="MySQL"
;;
"sqlite")
log_message "The SQLite database engine is being used"
DATABASEENGINE="SQLite"
database_engine="SQLite"
;;
esac
DATABASEHOSTNAME=`grep 'db_host' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2`
DATABASEUSER=`grep 'db_username' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2`
DATABASEPASSWORD1=`grep 'db_password' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2`
DATABASENAME=`grep 'db_database' ${LIGHTTPD_DOCUMENT_ROOT}/classes/settings.class.php | tail -n1 | cut -d\' -f2`
database_hostname=`grep 'db_host' $lighttpd_document_root/classes/settings.class.php | tail -n1 | cut -d\' -f2`
database_user=`grep 'db_username' $lighttpd_document_root/classes/settings.class.php | tail -n1 | cut -d\' -f2`
database_password1=`grep 'db_password' $lighttpd_document_root/classes/settings.class.php | tail -n1 | cut -d\' -f2`
database_name=`grep 'db_database' $lighttpd_document_root/classes/settings.class.php | tail -n1 | cut -d\' -f2`
fi
else
log_message "Asking if advanced features should be utilized"
@ -82,40 +82,40 @@ else
--yesno "NOTE THAT THE ADVANCED FEATURES ARE STILL IN DEVELOPMENT AT THIS TIME\nADVANCED FEATURES SHOULD ONLY BE ENABLED BY DEVELOPERS AND TESTERS ONLY\n\nBy enabling advanced features the portal will log all flights seen as well as the path of the flight. This data is stored in either a MySQL or SQLite database. This will result in a lot more data being stored on your devices hard drive. Keep this and your devices hardware capabilities in mind before selecting to enable these features.\n\nENABLING ADVANCED FEATURES ON DEVICES USING SD CARDS CAN SHORTEN THE LIFE OF THE SD CARD IMMENSELY\n\nDo you wish to enable the portal advanced features?" \
19 78; then
log_message "Advanced features will be setup"
ADVANCED="true"
advanced_installation="true"
else
log_message "Lite features will be setup"
ADVANCED="false"
advanced_installation="false"
fi
if [[ "${ADVANCED}" = "true" ]]; then
if [[ "${advanced_installation}" = "true" ]]; then
log_message "Asking for the location of the MySQL server"
DATABASEENGINE=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Choose Database Type" \
--nocancel \
--menu "Choose which database engine to use." 11 80 2 \
"MySQL" "" "SQLite" "" 3>&1 1>&2 2>&3)
if [[ "${DATABASEENGINE}" = "MySQL" ]]; then
database_engine=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Choose Database Type" \
--nocancel \
--menu "Choose which database engine to use." 11 80 2 \
"MySQL" "" "SQLite" "" 3>&1 1>&2 2>&3)
if [[ "${database_engine}" = "MySQL" ]]; then
if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "MySQL Database Location" \
--yesno "Will the database be hosted locally on this device?" \
7 80; then
log_message "A local MySQL database server will be used"
LOCALMYSQLSERVER="true"
local_mysql_server="true"
else
log_message "A remote MySQL database server will be used"
fi
if [[ "${LOCALMYSQLSERVER}" = "false" ]]; then
if [[ "${local_mysql_server}" = "false" ]]; then
log_message "Asking for the remote MySQL server's hostname"
DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname"
while [[ -z "${DATABASEHOSTNAME}" ]]; do
DATABASEHOSTNAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEHOSTNAME_TITLE}" \
--nocancel \
--inputbox "What is the remote MySQL server's hostname?" \
10 60 3>&1 1>&2 2>&3)
DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname (REQUIRED)"
database_hostname_title="MySQL Database Server Hostname"
while [[ -z $database_hostname ]]; do
database_hostname=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_hostname_title}" \
--nocancel \
--inputbox "What is the remote MySQL server's hostname?" \
10 60 3>&1 1>&2 2>&3)
database_hostname_title="MySQL Database Server Hostname (REQUIRED)"
done
log_message "Asking for the database already exists remotly"
if whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
@ -123,152 +123,152 @@ else
--yesno "Has the database already been created?" \
7 80; then
log_message "The database exists on the remote server"
DATABASEEXISTS="true"
database_exists="true"
else
log_message "The database does not exist on the remote server"
DATABASEEXISTS="false"
database_exists="false"
fi
fi
if [[ "${LOCALMYSQLSERVER}" = "true" || "${DATABASEEXISTS}" = "false" ]]; then
if [[ "${local_mysql_server}" = "true" || "${database_exists}" = "false" ]]; then
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Create Remote MySQL Database" \
--msgbox "This script can attempt to create the MySQL database for you.\nYou will now be asked for the credentials for a MySQL user who has the ability to create a database on the MySQL server." \
9 78
log_message "Asking for the MySQL administrator username"
DATABASEADMINUSER_TITLE="MySQL Administrator Username"
while [[ -z "${DATABASEADMINUSER}" ]]; do
DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINUSER_TITLE}" \
database_admin_user_title="MySQL Administrator Username"
while [[ -z $database_admin_user ]]; do
database_admin_user=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_user_title}" \
--nocancel \
--inputbox "Enter the MySQL adminitrator username." \
8 78 \
"root" 3>&1 1>&2 2>&3)
DATABASEADMINUSER_TITLE="MySQL Administrator User (REQUIRED)"
database_admin_user_title="MySQL Administrator User (REQUIRED)"
done
log_message "Asking for the MySQL administrator password"
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password"
while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do
DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD1_TITLE}" \
database_admin_password1_title="MySQL Administrator Password"
while [[ -z $database_admin_password1 ]]; do
database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password1_title}" \
--nocancel \
--passwordbox "Enter the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)"
database_admin_password1_title="MySQL Administrator Password (REQUIRED)"
done
log_message "Asking the user to confirm the MySQL administrator password"
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password"
while [[ -z "${DATABASEADMINPASSWORD2}" ]]; do
DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD2_TITLE}" \
--nocancel \
--passwordbox "Confirm the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)"
database_admin_password2_title="Confirm The MySQL Administrator Password"
while [[ -z $database_admin_password2 ]]; do
database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password2_title}" \
--nocancel \
--passwordbox "Confirm the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)"
done
while [[ ! "${DATABASEADMINPASSWORD1}" = "${DATABASEADMINPASSWORD2}" ]]; do
while [[ ! "${database_admin_password1}" = "${database_admin_password2}" ]]; do
log_message "The supplied MySQL administrator passwords did not match"
DATABASEADMINPASSWORD1=""
DATABASEADMINPASSWORD2=""
database_admin_password1=""
database_admin_password2=""
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Passwords Did Not Match" \
--msgbox "Passwords did not match.\nPlease enter the MySQL administrator password again." \
9 78
log_message "Asking for the MySQL administrator password"
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password"
while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do
DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD1_TITLE}" \
database_admin_password1_title="MySQL Administrator Password"
while [[ -z $database_admin_password1 ]]; do
database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password1_title}" \
--nocancel \
--passwordbox "DATABASEADMINPASSWORD1_MESSAGE" \
--passwordbox "Enter the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)"
database_admin_password1_title="MySQL Administrator Password (REQUIRED)"
done
log_message "Asking the user to confirm the MySQL administrator password"
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password"
while [[ -z "${DATABASEADMINPASSWORD2}" ]]; do
DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD2_TITLE}" \
--nocancel \
--passwordbox "DATABASEADMINPASSWORD2_MESSAGE" \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)"
database_admin_password2_title="Confirm The MySQL Administrator Password"
while [[ -z $database_admin_password2 ]]; do
database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password2_title}" \
--nocancel \
--passwordbox "Confirm the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)"
done
done
fi
log_message "Asking for the name of the ADS-B Portal database"
DATABASENAME_TITLE="The ADS-B Portal Database Name"
while [[ -z "${DATABASENAME}" ]]; do
DATABASENAME=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASENAME_TITLE}" \
--nocancel \
--inputbox "Enter your ADS-B Receiver Portal database name." \
8 78 3>&1 1>&2 2>&3)
DATABASENAME_TITLE="The ADS-B Portal Database Name (REQUIRED)"
database_name_title="The ADS-B Portal Database Name"
while [[ -z $database_name ]]; do
database_name=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_name_title}" \
--nocancel \
--inputbox "Enter your ADS-B Receiver Portal database name." \
8 78 3>&1 1>&2 2>&3)
database_name_title="The ADS-B Portal Database Name (REQUIRED)"
done
log_message "Asking for the ADS-B Portal database username"
DATABASEUSER_TITLE="The ADS-B Portal Database User"
while [[ -z "${DATABASEUSER}" ]]; do
DATABASEUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEUSER_TITLE}" \
--nocancel \
--inputbox "Enter the user for the ADS-B Receiver Portal database." \
8 78 3>&1 1>&2 2>&3)
DATABASEUSER_TITLE="The ADS-B Portal Database User (REQUIRED)"
database_user_title="The ADS-B Portal Database User"
while [[ -z $database_user ]]; do
database_user=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_user_title}" \
--nocancel \
--inputbox "Enter the user for the ADS-B Receiver Portal database." \
8 78 3>&1 1>&2 2>&3)
database_user_title="The ADS-B Portal Database User (REQUIRED)"
done
log_message "Asking for the ADS-B Portal database password"
DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password"
while [[ -z "${DATABASEPASSWORD1}" ]]; do
DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEPASSWORD1_TITLE}" \
--nocancel \
--passwordbox "Enter the ADS-B Portal database password." \
8 78 3>&1 1>&2 2>&3)
DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password (REQUIRED)"
database_password1_title="The ADS-B Portal Database Password"
while [[ -z $database_password1 ]]; do
database_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_password1_title}" \
--nocancel \
--passwordbox "Enter the ADS-B Portal database password." \
8 78 3>&1 1>&2 2>&3)
database_password1_title="The ADS-B Portal Database Password (REQUIRED)"
done
log_message "Asking the user to confirm the ADS-B Portal database password"
DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password"
while [[ -z "${DATABASEPASSWORD2}" ]]; do
DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEPASSWORD2_TITLE}" \
--nocancel \
--passwordbox "Confirm the ADS-B Portal database password." \
8 78 3>&1 1>&2 2>&3)
DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password (REQUIRED)"
database_password2_title="Confirm The ADS-B Portal Database Password"
while [[ -z database_password2 ]]; do
database_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_password2_title}" \
--nocancel \
--passwordbox "Confirm the ADS-B Portal database password." \
8 78 3>&1 1>&2 2>&3)
database_password2_title="Confirm The ADS-B Portal Database Password (REQUIRED)"
done
while [[ ! "${DATABASEPASSWORD1}" = "${DATABASEPASSWORD2}" ]]; do
while [[ ! "${database_password1}" = "${database_password2}" ]]; do
log_message "The supplied ADS-B Portal database passwords did not match"
DATABASEPASSWORD1=""
DATABASEPASSWORD2=""
database_password1=""
database_password2=""
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Passwords Did Not Match" \
--msgbox "Passwords did not match.\nPlease enter the ADS-B Portal password again." \
9 78
log_message "Asking for the ADS-B Portal database password"
DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password"
while [[ -z "${DATABASEPASSWORD1}" ]]; do
DATABASEPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEPASSWORD1_TITLE}" \
--nocancel \
--passwordbox "${DATABASEPASSWORD1_MESSAGE}" \
8 78 3>&1 1>&2 2>&3)
DATABASEPASSWORD1_TITLE="The ADS-B Portal Database Password (REQUIRED)"
database_password1_title="The ADS-B Portal Database Password"
while [[ -z $database_password1 ]]; do
database_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_password1_title}" \
--nocancel \
--passwordbox "Enter the ADS-B Portal database password." \
8 78 3>&1 1>&2 2>&3)
database_password1_title="The ADS-B Portal Database Password (REQUIRED)"
done
log_message "Asking the user to confirm the ADS-B Portal database password"
DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password"
while [[ -z "${DATABASEPASSWORD2}" ]]; do
DATABASEPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEPASSWORD2_TITLE}" \
--nocancel \
--passwordbox "${DATABASEPASSWORD2_MESSAGE}" \
8 78 3>&1 1>&2 2>&3)
DATABASEPASSWORD2_TITLE="Confirm The ADS-B Portal Database Password (REQUIRED)"
database_password2_title="Confirm The ADS-B Portal Database Password"
while [[ -z $database_password2 ]]; do
database_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_password2_title}" \
--nocancel \
--passwordbox "Confirm the ADS-B Portal database password." \
8 78 3>&1 1>&2 2>&3)
database_password2_title="Confirm The ADS-B Portal Database Password (REQUIRED)"
done
done
fi
@ -278,9 +278,9 @@ fi
## INSTALL PREREQUISITE PACAKGES
if [[ "${LOCALMYSQLSERVER}" = "true" ]]; then
DATABASEEXISTS="false"
DATABASEHOSTNAME="localhost"
if [[ "${local_mysql_server}" = "true" ]]; then
database_exists="false"
database_hostname="localhost"
check_package mariadb-server
log_message "Executing the mysql_secure_installation script"
@ -297,34 +297,34 @@ fi
case $RECEIVER_OS_DISTRIBUTION in
ubuntu)
DISTRO_PHP_VERSION=""
php_version=""
;;
debian)
if [[ "${RECEIVER_OS_CODE_NAME}" == "bookworm" ]]; then DISTRO_PHP_VERSION="8.2"; fi
if [[ "${RECEIVER_OS_CODE_NAME}" == "bullseye" ]]; then DISTRO_PHP_VERSION="7.4"; fi
if [[ "${RECEIVER_OS_CODE_NAME}" == "bookworm" ]]; then php_version="8.2"; fi
if [[ "${RECEIVER_OS_CODE_NAME}" == "bullseye" ]]; then php_version="7.4"; fi
;;
esac
check_package php${DISTRO_PHP_VERSION}-cgi
if [[ ! "${DISTRO_PHP_VERSION}" == "" && "${DISTRO_PHP_VERSION}" < "8" ]]; then
check_package php${DISTRO_PHP_VERSION}-json
check_package php${php_version}-cgi
if [[ ! "${php_version}" == "" && "${php_version}" < "8" ]]; then
check_package php${php_version}-json
fi
if [[ "${ADVANCED}" = "true" ]]; then
if [[ "${advanced_installation}" = "true" ]]; then
check_package python3-pyinotify
check_package python3-apt
case "${DATABASEENGINE}" in
case "${database_engine}" in
"MySQL")
check_package mariadb-client
check_package python3-mysqldb
check_package php${DISTRO_PHP_VERSION}-mysql
check_package php${php_version}-mysql
;;
"SQLite")
check_package sqlite3
check_package php${DISTRO_PHP_VERSION}-sqlite3
check_package php${php_version}-sqlite3
;;
esac
else
check_package php${DISTRO_PHP_VERSION}-xml
check_package php${php_version}-xml
fi
log_message "Reloading the Lighttpd server"
@ -336,62 +336,62 @@ echo ""
log_heading "Begining ADS-B Portal setup"
if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then
log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/administrators.xml $LIGHTTPD_DOCUMENT_ROOT/data/administrators.backup.xml
log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.xml $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.backup.xml
log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.xml $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.backup.xml
log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/settings.xml $LIGHTTPD_DOCUMENT_ROOT/data/settings.backup.xml
log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/links.xml $LIGHTTPD_DOCUMENT_ROOT/data/links.backup.xml
log_message "Backing up the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/notifications.xml $LIGHTTPD_DOCUMENT_ROOT/data/notifications.backup.xml
if [[ "${portal_installed}" = "true" && "${advanced_installation}" = "false" ]]; then
log_message "Backing up the file ${lighttpd_document_root}/data/administrators.xml"
sudo mv $lighttpd_document_root/data/administrators.xml $lighttpd_document_root/data/administrators.backup.xml
log_message "Backing up the file ${lighttpd_document_root}/data/blogPosts.xml"
sudo mv $lighttpd_document_root/data/blogPosts.xml $lighttpd_document_root/data/blogPosts.backup.xml
log_message "Backing up the file ${lighttpd_document_root}/data/flightNotifications.xml"
sudo mv $lighttpd_document_root/data/flightNotifications.xml $lighttpd_document_root/data/flightNotifications.backup.xml
log_message "Backing up the file ${lighttpd_document_root}/data/settings.xml"
sudo mv $lighttpd_document_root/data/settings.xml $lighttpd_document_root/data/settings.backup.xml
log_message "Backing up the file ${lighttpd_document_root}/data/links.xml"
sudo mv $lighttpd_document_root/data/links.xml $lighttpd_document_root/data/links.backup.xml
log_message "Backing up the file ${lighttpd_document_root}/data/notifications.xml"
sudo mv $lighttpd_document_root/data/notifications.xml $lighttpd_document_root/data/notifications.backup.xml
fi
if [ -f $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html ]; then
if [ -f $lighttpd_document_root/index.lighttpd.html ]; then
log_message "Removing default Lighttpd index file from document root"
sudo rm $LIGHTTPD_DOCUMENT_ROOT/index.lighttpd.html
sudo rm $lighttpd_document_root/index.lighttpd.html
fi
log_message "Placing portal files in Lighttpd's root directory"
sudo cp -R $RECEIVER_BUILD_DIRECTORY/portal//html/* $LIGHTTPD_DOCUMENT_ROOT
sudo cp -R $RECEIVER_BUILD_DIRECTORY/portal//html/* $lighttpd_document_root
if [[ "${RECEIVER_PORTAL_INSTALLED}" = "true" && "${ADVANCED}" = "false" ]]; then
log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/administrators.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/administrators.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/administrators.xml
log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/blogPosts.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/blogPosts.xml
log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/flightNotifications.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/flightNotifications.xml
log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/settings.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/settings.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/settings.xml
log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/links.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/links.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/links.xml
log_message "Restoring the backup copy of the file ${LIGHTTPD_DOCUMENT_ROOT}/data/notifications.xml"
sudo mv $LIGHTTPD_DOCUMENT_ROOT/data/notifications.backup.xml $LIGHTTPD_DOCUMENT_ROOT/data/notifications.xml
if [[ "${portal_installed}" = "true" && "${advanced_installation}" = "false" ]]; then
log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/administrators.xml"
sudo mv $lighttpd_document_root/data/administrators.backup.xml $lighttpd_document_root/data/administrators.xml
log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/blogPosts.xml"
sudo mv $lighttpd_document_root/data/blogPosts.backup.xml $lighttpd_document_root/data/blogPosts.xml
log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/flightNotifications.xml"
sudo mv $lighttpd_document_root/data/flightNotifications.backup.xml $lighttpd_document_root/data/flightNotifications.xml
log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/settings.xml"
sudo mv $lighttpd_document_root/data/settings.backup.xml $lighttpd_document_root/data/settings.xml
log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/links.xml"
sudo mv $lighttpd_document_root/data/links.backup.xml $lighttpd_document_root/data/links.xml
log_message "Restoring the backup copy of the file ${lighttpd_document_root}/data/notifications.xml"
sudo mv $lighttpd_document_root/data/notifications.backup.xml $lighttpd_document_root/data/notifications.xml
fi
log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/graphs/ writable"
sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/graphs/
log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/classes/ writable"
sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/classes/
log_message "Making the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable"
sudo chmod 777 $LIGHTTPD_DOCUMENT_ROOT/data/
log_message "Making the files contained within the directory ${LIGHTTPD_DOCUMENT_ROOT}/data/ writable"
sudo chmod 666 $LIGHTTPD_DOCUMENT_ROOT/data/*
log_message "Making the directory ${lighttpd_document_root}/graphs/ writable"
sudo chmod 777 $lighttpd_document_root/graphs/
log_message "Making the directory ${lighttpd_document_root}/classes/ writable"
sudo chmod 777 $lighttpd_document_root/classes/
log_message "Making the directory ${lighttpd_document_root}/data/ writable"
sudo chmod 777 $lighttpd_document_root/data/
log_message "Making the files contained within the directory ${lighttpd_document_root}/data/ writable"
sudo chmod 666 $lighttpd_document_root/data/*
if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then
log_message "Checking for the file upintheair.json in the dump1090 HTML folder"
if [[ -f "/usr/share/dump1090-mutability/html/upintheair.json" || -f "/usr/share/dump1090-fa/html/upintheair.json" ]]; then
log_message "Copying the file upintheair.json from the dump1090 HTML folder to the dump978 HTML folder"
if [[ $(dpkg-query -W -f='${STATUS}' dump1090-mutability 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then
sudo cp /usr/share/dump1090-mutability/html/upintheair.json ${LIGHTTPD_DOCUMENT_ROOT}/dump978/
sudo cp /usr/share/dump1090-mutability/html/upintheair.json $lighttpd_document_root/dump978/
fi
if [[ $(dpkg-query -W -f='${STATUS}' dump1090-fa 2>/dev/null | grep -c "ok installed") -eq 1 ]]; then
sudo cp /usr/share/dump1090-fa/html/upintheair.json ${LIGHTTPD_DOCUMENT_ROOT}/dump978/
sudo cp /usr/share/dump1090-fa/html/upintheair.json $lighttpd_document_root/dump978/
fi
fi
fi
@ -425,7 +425,7 @@ if [[ ! -L "/etc/lighttpd/conf-enabled/87-adsb-portal.conf" ]] ; then
sudo ln -s /etc/lighttpd/conf-available/87-adsb-portal.conf /etc/lighttpd/conf-enabled/87-adsb-portal.conf
fi
if [[ "${RECEIVER_PORTAL_INSTALLED}" = "false" ]] ; then
if [[ "${portal_installed}" = "false" ]] ; then
log_message "Enabling the Lighttpd fastcgi-php module"
echo ""
sudo lighty-enable-mod fastcgi-php
@ -443,103 +443,101 @@ fi
## SETUP THE ADS-B PORTAL MYSQL DATABASE
if [[ "${RECEIVER_PORTAL_INSTALLED}" = "false" && "${ADVANCED}" = "true" && "${DATABASEENGINE}" = "MySQL" && "${DATABASEEXISTS}" = "false" ]]; then
if [[ "${portal_installed}" = "false" && "${advanced_installation}" = "true" && "${database_engine}" = "MySQL" && "${database_exists}" = "false" ]]; then
if [[ $(dpkg-query -W -f='${STATUS}' mariadb-server-10.1 2>/dev/null | grep -c "ok installed") -eq 1 ]] ; then
log_message "Switching the default MySQL plugin from unix_socket to mysql_native_password"
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';"
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE user = 'root' AND plugin = 'unix_socket';"
log_message "Flushing privileges on the MySQL (MariaDB) server"
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "FLUSH PRIVILEGES;"
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "FLUSH PRIVILEGES;"
log_message "Reloading MySQL (MariaDB)"
sudo service mysql force-reload
fi
log_message "Attempting to log into the MySQL server using the supplied administrator credentials"
while ! sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e ";"; do
while ! sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e ";"; do
log_message "Unable to log into the MySQL server using the supplied administrator credentials"
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Create MySQL Database" \
--msgbox "The script was not able to log into the MySQL server using the administrator credentials you supplied. You will now be asked to reenter the MySQL server administrator credentials." \
9 78
DATABASEADMINPASSWORD1=""
DATABASEADMINPASSWORD2=""
database_admin_password1=""
database_admin_password2=""
log_message "Asking for the MySQL administrator username"
DATABASEADMINUSER_TITLE="MySQL Administrator User"
while [[ -z "${DATABASEADMINUSER}" ]]; do
DATABASEADMINUSER=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINUSER_TITLE}" \
--nocancel \
--inputbox "Enter the MySQL administrator user." \
8 78 \
"${DATABASEADMINUSER}" 3>&1 1>&2 2>&3)
DATABASEADMINUSER_TITLE="MySQL Administrator User (REQUIRED)"
database_admin_user_title="MySQL Administrator User"
while [[ -z $database_admin_user ]]; do
database_admin_user=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_user_title}" \
--nocancel \
--inputbox "Enter the MySQL administrator user." \
8 78 \
"${database_admin_user}" 3>&1 1>&2 2>&3)
database_admin_user_title="MySQL Administrator User (REQUIRED)"
done
log_message "Asking for the MySQL administrator password"
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password"
DATABASEADMINPASSWORD1_MESSAGE="Enter the password for the MySQL adminitrator user."
while [[ -z "${DATABASEADMINPASSWORD1}" ]]; do
DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD1_TITLE}" \
--nocancel \
--passwordbox "${DATABASEADMINPASSWORD1_MESSAGE}" \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)"
database_admin_password1_title="MySQL Administrator Password"
while [[ -z $database_admin_password1 ]]; do
database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password1_title}" \
--nocancel \
--passwordbox "Enter the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
database_admin_password1_title="MySQL Administrator Password (REQUIRED)"
done
log_message "Asking to confirm the MySQL administrator password"
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password"
DATABASEADMINPASSWORD2_MESSAGE="\nConfirm the password for the MySQL adminitrator user."
while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do
DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD2_TITLE}" \
--nocancel \
--passwordbox "${DATABASEADMINPASSWORD2_MESSAGE}" \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)"
database_admin_password2_title="Confirm The MySQL Administrator Password"
while [[ -z $database_admin_password2 ]] ; do
database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password2_title}" \
--nocancel \
--passwordbox "Confirm the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)"
done
while [[ ! "${DATABASEADMINPASSWORD1}" == "${DATABASEADMINPASSWORD2}" ]]; do
while [[ ! "${database_admin_password1}" == "${database_admin_password2}" ]]; do
log_message "Failed to log into MySQL using the supplied credentials"
DATABASEADMINPASSWORD1=""
DATABASEADMINPASSWORD2=""
database_admin_password1=""
database_admin_password2=""
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "Passwords Did Not Match" \
--msgbox "Passwords did not match.\nPlease enter your password again." \
9 78
log_message "Asking for the MySQL administrator password"
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password"
while [[ -z "${DATABASEADMINPASSWORD1}" ]] ; do
DATABASEADMINPASSWORD1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD1_TITLE}" \
database_admin_password1_title="MySQL Administrator Password"
while [[ -z $database_admin_password1 ]] ; do
database_admin_password1=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password1_title}" \
--nocancel \
--passwordbox "DATABASEADMINPASSWORD1_MESSAGE" \
--passwordbox "Enter the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD1_TITLE="MySQL Administrator Password (REQUIRED)"
database_admin_password1_title="MySQL Administrator Password (REQUIRED)"
done
log_message "Asking to confirm the MySQL administrator password"
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password"
while [[ -z "${DATABASEADMINPASSWORD2}" ]] ; do
DATABASEADMINPASSWORD2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${DATABASEADMINPASSWORD2_TITLE}" \
--nocancel \
--passwordbox "DATABASEADMINPASSWORD2_MESSAGE" \
8 78 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD2_TITLE="Confirm The MySQL Administrator Password (REQUIRED)"
database_admin_password2_title="Confirm The MySQL Administrator Password"
while [[ -z $database_admin_password2 ]] ; do
database_admin_password2=$(whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "${database_admin_password2_title}" \
--nocancel \
--passwordbox "Confirm the password for the MySQL adminitrator user." \
8 78 3>&1 1>&2 2>&3)
database_admin_password2_title="Confirm The MySQL Administrator Password (REQUIRED)"
done
done
log_message "Attempting to log into the MySQL server using the new administrator credentials"
done
log_message "Successfully logged into the MySQL server using the new administrator credentials"
log_message "Creating the MySQL database ${DATABASENAME}"
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE DATABASE ${DATABASENAME};"
log_message "Creating the MySQL user ${DATABASEUSER}"
if [[ "${LOCALMYSQLSERVER}" = "false" ]] ; then
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE USER '${DATABASEUSER}'@'%' IDENTIFIED BY \"${DATABASEPASSWORD1}\";"
log_message "Creating the MySQL database ${database_name}"
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "CREATE DATABASE ${database_name};"
log_message "Creating the MySQL user ${database_user}"
if [[ "${local_mysql_server}" = "false" ]] ; then
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "CREATE USER '${database_user}'@'%' IDENTIFIED BY \"${database_password1}\";"
else
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "CREATE USER '${DATABASEUSER}'@'localhost' IDENTIFIED BY \"${DATABASEPASSWORD1}\";"
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "CREATE USER '${database_user}'@'localhost' IDENTIFIED BY \"${database_password1}\";"
fi
log_message "Granting priviledges on the MySQL database ${DATABASENAME} to the user ${DATABASEUSER}"
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "GRANT ALL PRIVILEGES ON ${DATABASENAME}.* TO '${DATABASEUSER}'@'localhost';"
log_message "Granting priviledges on the MySQL database ${database_name} to the user ${database_user}"
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "GRANT ALL PRIVILEGES ON ${database_name}.* TO '${database_user}'@'localhost';"
log_message "Flushing priviledges on the MySQL database server"
sudo mysql -u${DATABASEADMINUSER} -p${DATABASEADMINPASSWORD1} -h ${DATABASEHOSTNAME} -e "FLUSH PRIVILEGES;"
sudo mysql -u${database_admin_user} -p${database_admin_password1} -h ${database_hostname} -e "FLUSH PRIVILEGES;"
fi
@ -557,33 +555,33 @@ fi
## SETUP COMMON PORTAL FEATURES
if [ "${DATABASEENGINE}" = "MySQL" ]; then
export ADSB_DATABASEENGINE=${DATABASEENGINE}
export ADSB_DATABASEHOSTNAME=${DATABASEHOSTNAME}
export ADSB_DATABASEUSER=${DATABASEUSER}
export ADSB_DATABASEPASSWORD1=${DATABASEPASSWORD1}
export ADSB_DATABASENAME=${DATABASENAME}
elif [ "${DATABASEENGINE}" = "SQLite" ]; then
if [ -z "${DATABASENAME}" ] ; then
if [ ! -f ${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite ]; then
if [ "${database_engine}" = "MySQL" ]; then
export ADSB_PORTAL_DATABASE_ENGINE=$database_engine
export ADSB_PORTAL_DATABASE_HOSTNAME=$database_hostname
export ADSB_PORTAL_DATABASE_USER=$database_user
export ADSB_PORTAL_DATABASE_PASSWORD1=$database_password1
export ADSB_PORTAL_DATABASE_NAME=$database_name
elif [ "${database_engine}" = "SQLite" ]; then
if [ -z $database_name ] ; then
if [ ! -f $lighttpd_document_root/data/portal.sqlite ]; then
echo -e "\e[94m Creating an empty SQLite database file...\e[97m"
sudo touch ${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite
sudo touch $lighttpd_document_root/data/portal.sqlite
echo -e "\e[94m Setting write permissions on the empty SQLite database file...\e[97m"
sudo chmod 666 ${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite
sudo chmod 666 $lighttpd_document_root/data/portal.sqlite
fi
DATABASENAME="${LIGHTTPD_DOCUMENT_ROOT}/data/portal.sqlite"
database_name="${lighttpd_document_root}/data/portal.sqlite"
fi
export ADSB_DATABASEENGINE=${DATABASEENGINE}
export ADSB_DATABASEHOSTNAME=""
export ADSB_DATABASEUSER=""
export ADSB_DATABASEPASSWORD1=""
export ADSB_DATABASENAME=${DATABASENAME}
export ADSB_PORTAL_DATABASE_ENGINE=$database_engine
export ADSB_PORTAL_DATABASE_HOSTNAME=""
export ADSB_PORTAL_DATABASE_USER=""
export ADSB_PORTAL_DATABASE_PASSWORD1=""
export ADSB_PORTAL_DATABASE_NAME=$database_name
else
export ADSB_DATABASEENGINE="xml"
export ADSB_DATABASEHOSTNAME=""
export ADSB_DATABASEUSER=""
export ADSB_DATABASEPASSWORD1=""
export ADSB_DATABASENAME=""
export ADSB_PORTAL_DATABASE_ENGINE="xml"
export ADSB_PORTAL_DATABASE_HOSTNAME=""
export ADSB_PORTAL_DATABASE_USER=""
export ADSB_PORTAL_DATABASE_PASSWORD1=""
export ADSB_PORTAL_DATABASE_NAME=""
fi
chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/core.sh
@ -598,7 +596,7 @@ fi
## SETUP ADVANCED PORTAL FEATURES
if [ "${ADVANCED}" = "true" ] ; then
if [ "${advanced_installation}" = "true" ] ; then
chmod +x ${RECEIVER_BASH_DIRECTORY}/portal/logging.sh
${RECEIVER_BASH_DIRECTORY}/portal/logging.sh
if [[ $? -ne 0 ]] ; then
@ -612,17 +610,17 @@ fi
## POST INSTALLATION OPERATIONS
unset ADSB_DATABASEENGINE
unset ADSB_DATABASEHOSTNAME
unset ADSB_DATABASEUSER
unset ADSB_DATABASEPASSWORD1
unset ADSB_DATABASENAME
unset ADSB_PORTAL_DATABASE_ENGINE
unset ADSB_PORTAL_DATABASE_HOSTNAME
unset ADSB_PORTAL_DATABASE_USER
unset ADSB_PORTAL_DATABASE_PASSWORD1
unset ADSB_PORTAL_DATABASE_NAME
IPADDRESS=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'`
pi_address=`ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'`
whiptail --backtitle "${RECEIVER_PROJECT_TITLE}" \
--title "ADS-B Receiver Project Portal Setup" \
--msgbox "NOTE THAT PORTAL SETUP IS NOT YET COMPLETE!\n\nIn order to complete the portal setup process visit the following URL in your favorite web browser.\n\nhttp://${IPADDRESS}/install/\n\nFollow the instructions and enter the requested information to complete the ADS-B Receiver Project Portal setup." \
--msgbox "NOTE THAT PORTAL SETUP IS NOT YET COMPLETE!\n\nIn order to complete the portal setup process visit the following URL in your favorite web browser.\n\nhttp://${ip_address}/install/\n\nFollow the instructions and enter the requested information to complete the ADS-B Receiver Project Portal setup." \
12 78

Wyświetl plik

@ -4,14 +4,13 @@
python_path=`which python3`
## SETUP FLIGHT LOGGING
echo -e ""
echo -e "\e[95m Setting up portal flight logging and maintenance...\e[97m"
echo -e ""
log_heading "Setting up portal flight logging and maintenance"
# Create the cron jobs responsible for logging and maintenance.
echo -e "\e[94m Creating the portal script cron file...\e[97m"
log_message "Creating the portal script cron file"
sudo tee /etc/cron.d/adsb-receiver-flight-logging > /dev/null <<EOF
* * * * * root ${python_path} ${RECEIVER_BUILD_DIRECTORY}/portal/python/flights.py
0 0 * * * root ${python_path} ${RECEIVER_BUILD_DIRECTORY}/portal/python/maintenance.py