whiptail --title "ADS-B Receiver Portal Selection" --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?"1478
RESPONSE=$?
case$RESPONSE in
0)ADVANCED=TRUE;;
1)ADVANCED=FALSE;;
esac
if[$ADVANCED=1];then
# Ask which type of database to use.
DATABASEENGINE=$(whiptail --title "Choose Database Type" --nocancel --menu "Choose which type of database to use."11802"MySQL""""SQLite""" 3>&1 1>&2 2>&3)
if[$DATABASEENGINE=="MySQL"];then
# Ask if the database server will be installed locally.
whiptail --title "MySQL Database Location" --yesno "Will the database be hosted locally on this device?"780
RESPONSE=$?
case$RESPONSE in
0)LOCALMYSQLSERVER=TRUE;;
1)LOCALMYSQLSERVER=FALSE;;
esac
if[$LOCALDATABASE= FALSE ];then
# Ask for the remote MySQL servers hostname.
DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname"
while[[ -z $DATABASEHOSTNAME]];do
DATABASEHOSTNAME=$(whiptail --title "$DATABASEHOSTNAME_TITLE" --nocancel --inputbox "\nWhat is the remote MySQL server's hostname?"1060 3>&1 1>&2 2>&3)
DATABASEHOSTNAME_TITLE="MySQL Database Server Hostname (REQUIRED)"
# Ask if the remote MySQL database already exists.
whiptail --title "Does MySQL Database Exist" --yesno "Has the database already been created?"780
RESPONSE=$?
case$RESPONSE in
0)DATABASEEXISTS=TRUE;;
1)DATABASEEXISTS=FALSE;;
esac
# If the remote MySQL database does not exist ask for the MySQL administrator credentials.
if[$DATABASEEXISTS= FALSE ];then
whiptail --title "Create Remote MySQL Database" --msgbox "This script can attempt to create the MySQL database for you.\n\nYou will now be asked for the credentials for a MySQL user who has the ability to create a database on the remote MySQL server."978
DATABASEADMINUSER_TITLE="Remote MySQL Administrator User"
while[[ -z $DATABASEADMINUSER]];do
DATABASEADMINUSER=$(whiptail --title "$DATABASEADMINUSER_TITLE" --nocancel --inputbox "\nEnter the remote MySQL administrator user."878"root" 3>&1 1>&2 2>&3)
DATABASEADMINUSER_TITLE="Remote MySQL Administrator User (REQUIRED)"
done
DATABASEADMINPASSWORD1_TITLE="Remote MySQL Administrator Password"
while[[ -z $DATABASEADMINPASSWORD1]];do
DATABASEADMINPASSWORD1=$(whiptail --title "$DATABASEADMINPASSWORD1_TITLE" --nocancel --passwordbox "\nEnter the password for the remote MySQL adminitrator user."878 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD1_TITLE="Remote MySQL Administrator Password (REQUIRED)"
done
DATABASEADMINPASSWORD2_TITLE="Confirm The Remote MySQL Administrator Password"
while[[ -z $DATABASEADMINPASSWORD2]];do
DATABASEADMINPASSWORD2=$(whiptail --title "$DATABASEADMINPASSWORD2_TITLE" --nocancel --passwordbox "\nConfirm the password for the remote MySQL adminitrator user."878 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD2_TITLE="Confirm The Remote MySQL Administrator Password (REQUIRED)"
whiptail --title "" --msgbox "Passwords did not match.\nPlease enter your password again."978
DATABASEADMINPASSWORD1_TITLE="Remote MySQL Administrator Password"
while[[ -z $DATABASEADMINPASSWORD1]];do
DATABASEADMINPASSWORD1=$(whiptail --title "$DATABASEADMINPASSWORD1_TITLE" --nocancel --passwordbox "\nEnter the password for the remote MySQL adminitrator user.."878 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD1_TITLE="Remote MySQL Administrator Password (REQUIRED)"
done
DATABASEADMINPASSWORD2_TITLE="Confirm The Remote MySQL Administrator Password"
while[[ -z $DATABASEADMINPASSWORD2]];do
DATABASEADMINPASSWORD2=$(whiptail --title "$DATABASEADMINPASSWORD2_TITLE" --nocancel --passwordbox "\nConfirm the password for the remote MySQL adminitrator user.."878 3>&1 1>&2 2>&3)
DATABASEADMINPASSWORD2_TITLE="Confirm The Remote MySQL Administrator Password (REQUIRED)"
echo -e "\e[94m Creating the MySQL database \"$DATABASENAME\"...\e[97m"
mysql -u$DATABASEADMINUSER -p$DATABASEADMINPASSWORD -h $DATABASEHOSTNAME -e "CREATE DATABASE $DATABASENAME;"
echo -e "\e[94m Creating the MySQL user \"$DATABASEUSER\"...\e[97m"
mysql -u$DATABASEADMINUSER -p$DATABASEADMINPASSWORD -h $DATABASEHOSTNAME -e "CREATE USER '$DATABASEUSER'@'localhost' IDENTIFIED BY \"$DATABASEPASSWORD1\";"
echo -e "\e[94m Granting priviledges on the MySQL database \"DATABASENAME\" to the user \"$DATABASEUSER\"...\e[97m"
mysql -u$DATABASEADMINUSER -p$DATABASEADMINPASSWORD -h $DATABASEHOSTNAME -e "GRANT ALL PRIVILEGES ON $DATABASENAME.* TO '$DATABASEUSER'@'localhost';"
echo -e "\e[94m Flushing priviledges on the MySQL database server...\e[97m"
mysql -u$DATABASEADMINUSER -p$DATABASEADMINPASSWORD -h $DATABASEHOSTNAME -e "FLUSH PRIVILEGES;"