kopia lustrzana https://github.com/jprochazka/adsb-receiver
Moved shared advanced setup commands into advanced.sh
rodzic
dcd9b419cc
commit
c78b78f637
|
|
@ -0,0 +1,93 @@
|
|||
#!/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-2016 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
|
||||
|
||||
PROJECTROOTDIRECTORY="$PWD"
|
||||
BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build"
|
||||
PORTALBUILDDIRECTORY="$BUILDDIRECTORY/portal"
|
||||
PORTALPYTHONDIRECTORY="$PORTALBUILDDIRECTORY/python"
|
||||
|
||||
DATABASEENGINE=$ADSB_DATABASEENGINE
|
||||
DATABASEHOSTNAME=$ADSB_DATABASEHOSTNAME
|
||||
DATABASEUSER=$ADSB_DATABASEUSER
|
||||
DATABASEPASSWORD1=$ADSB_DATABASEPASSWORD1
|
||||
DATABASENAME=$ADSB_DATABASENAME
|
||||
|
||||
PYTHONPATH=`which python`
|
||||
|
||||
## SETUP FLIGHT LOGGING
|
||||
|
||||
echo ""
|
||||
echo -e "\e[95m Setting up core advanced portal features...\e[97m"
|
||||
echo ""
|
||||
|
||||
case $DATABASEENGINE in
|
||||
"MySQL")
|
||||
echo -e "\e[94m Creating the flight Python configuration file for MySQL...\e[97m"
|
||||
tee $PORTALPYTHONDIRECTORY/config.json > /dev/null <<EOF
|
||||
{
|
||||
"database":{"type":"mysql",
|
||||
"host":"$DATABASEHOSTNAME",
|
||||
"user":"$DATABASEUSER",
|
||||
"passwd":"$DATABASEPASSWORD1",
|
||||
"db":"$DATABASENAME"}
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
"SQLite")
|
||||
echo -e "\e[94m Creating the Python configuration file for SQLite...\e[97m"
|
||||
tee $PORTALPYTHONDIRECTORY/config.json > /dev/null <<EOF
|
||||
{
|
||||
"database":{"type":"sqlite",
|
||||
"host":"$DATABASEHOSTNAME",
|
||||
"user":"$DATABASEUSER",
|
||||
"passwd":"$DATABASEPASSWORD1",
|
||||
"db":"$DATABASENAME"}
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
|
||||
echo -e " SETUP HAS BEEN TERMINATED!"
|
||||
echo ""
|
||||
echo -e "\e[93mInvalid \"DATABASEENGINE\" supplied.\e[39m"
|
||||
echo ""
|
||||
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
|
||||
echo -e "\e[92m ADS-B Receiver Project Portal halted.\e[39m"
|
||||
echo ""
|
||||
read -p "Press enter to continue..." CONTINUE
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -463,7 +463,7 @@ if [ $? -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
## SETUP FLIGHT LOGGING USING THE SCRIPT LOGGING.SH
|
||||
## SETUP ADVANCED PORTAL FEATURES
|
||||
|
||||
if [ $ADVANCED = TRUE ]; then
|
||||
# If SQLite is being used and the path is not already set to the variable $DATABASENAME set it to the default path.
|
||||
|
|
@ -478,6 +478,15 @@ if [ $ADVANCED = TRUE ]; then
|
|||
export ADSB_DATABASEPASSWORD1=$DATABASEPASSWORD1
|
||||
export ADSB_DATABASENAME=$DATABASENAME
|
||||
|
||||
chmod +x $BASHDIRECTORY/portal/advanced.sh
|
||||
$BASHDIRECTORY/portal/advanced.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo -e "\e[91m THE SCRIPT ADVANCED.SH ENCOUNTERED AND ERROR"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x $BASHDIRECTORY/portal/logging.sh
|
||||
$BASHDIRECTORY/portal/logging.sh
|
||||
if [ $? -ne 0 ]; then
|
||||
|
|
@ -486,6 +495,14 @@ if [ $ADVANCED = TRUE ]; then
|
|||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove exported variables that are no longer needed.
|
||||
unset ADSB_DATABASEENGINE
|
||||
unset ADSB_DATABASEHOSTNAME
|
||||
unset ADSB_DATABASEUSER
|
||||
unset ADSB_DATABASEPASSWORD1
|
||||
unset ADSB_DATABASENAME
|
||||
|
||||
fi
|
||||
|
||||
## ADS-B RECEIVER PROJECT PORTAL SETUP COMPLETE
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
PROJECTROOTDIRECTORY="$PWD"
|
||||
BUILDDIRECTORY="$PROJECTROOTDIRECTORY/build"
|
||||
PORTALBUILDDIRECTORY="$BUILDDIRECTORY/portal"
|
||||
PORTALPYTHONDIRECTORY="$PORTALBUILDDIRECTORY/python"
|
||||
|
||||
# Assign the Lighthttpd document root directory to a variable.
|
||||
RAWDOCUMENTROOT=`/usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -p | grep server.document-root`
|
||||
|
|
@ -47,12 +48,6 @@ DATABASEUSER=$ADSB_DATABASEUSER
|
|||
DATABASEPASSWORD1=$ADSB_DATABASEPASSWORD1
|
||||
DATABASENAME=$ADSB_DATABASENAME
|
||||
|
||||
unset ADSB_DATABASEENGINE
|
||||
unset ADSB_DATABASEHOSTNAME
|
||||
unset ADSB_DATABASEUSER
|
||||
unset ADSB_DATABASEPASSWORD1
|
||||
unset ADSB_DATABASENAME
|
||||
|
||||
PYTHONPATH=`which python`
|
||||
|
||||
## SETUP FLIGHT LOGGING
|
||||
|
|
@ -61,89 +56,51 @@ echo ""
|
|||
echo -e "\e[95m Setting up flight logging...\e[97m"
|
||||
echo ""
|
||||
|
||||
case $DATABASEENGINE in
|
||||
"MySQL")
|
||||
echo -e "\e[94m Creating the flight logging configuration file for MySQL...\e[97m"
|
||||
tee $PORTALBUILDDIRECTORY/python/config.json > /dev/null <<EOF
|
||||
{
|
||||
"database":{"type":"mysql",
|
||||
"host":"$DATABASEHOSTNAME",
|
||||
"user":"$DATABASEUSER",
|
||||
"passwd":"$DATABASEPASSWORD1",
|
||||
"db":"$DATABASENAME"}
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
"SQLite")
|
||||
echo -e "\e[94m Creating the flight logging configuration file for SQLite...\e[97m"
|
||||
tee $PORTALBUILDDIRECTORY/python/config.json > /dev/null <<EOF
|
||||
{
|
||||
"database":{"type":"sqlite",
|
||||
"host":"$DATABASEHOSTNAME",
|
||||
"user":"$DATABASEUSER",
|
||||
"passwd":"$DATABASEPASSWORD1",
|
||||
"db":"$DATABASENAME"}
|
||||
}
|
||||
EOF
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
echo -e "\e[91m \e[5mINSTALLATION HALTED!\e[25m"
|
||||
echo -e " SETUP HAS BEEN TERMINATED!"
|
||||
echo ""
|
||||
echo -e "\e[93mInvalid \"DATABASEENGINE\" supplied.\e[39m"
|
||||
echo ""
|
||||
echo -e "\e[93m----------------------------------------------------------------------------------------------------"
|
||||
echo -e "\e[92m ADS-B Receiver Project Portal (Advanced) setup.\e[39m"
|
||||
echo ""
|
||||
read -p "Press enter to continue..." CONTINUE
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create and set permissions on the flight logging and maintenance maintenance scripts.
|
||||
echo -e "\e[94m Creating the flight logging maintenance script...\e[97m"
|
||||
tee $PORTALBUILDDIRECTORY/python/flights-maint.sh > /dev/null <<EOF
|
||||
tee $PORTALPYTHONDIRECTORY/flights-maint.sh > /dev/null <<EOF
|
||||
#!/bin/sh
|
||||
while true
|
||||
do
|
||||
sleep 30
|
||||
$PYTHONPATH $PORTALBUILDDIRECTORY/python/flights.py
|
||||
$PYTHONPATH $PORTALPYTHONDIRECTORY/flights.py
|
||||
done
|
||||
EOF
|
||||
|
||||
echo -e "\e[94m Creating the maintenance maintenance script...\e[97m"
|
||||
tee $PORTALBUILDDIRECTORY/python/maintenance-maint.sh > /dev/null <<EOF
|
||||
tee $PORTALPYTHONDIRECTORY/maintenance-maint.sh > /dev/null <<EOF
|
||||
#!/bin/sh
|
||||
while true
|
||||
do
|
||||
sleep 30
|
||||
$PYTHONPATH $PORTALBUILDDIRECTORY/portal/python/maintenance.py
|
||||
$PYTHONPATH $PORTALPYTHONDIRECTORY/maintenance.py
|
||||
done
|
||||
EOF
|
||||
|
||||
echo -e "\e[94m Making the flight logging maintenance script executable...\e[97m"
|
||||
chmod +x $PORTALBUILDDIRECTORY/python/flights-maint.sh
|
||||
chmod +x $PORTALPYTHONDIRECTORY/flights-maint.sh
|
||||
echo -e "\e[94m Making the maintenance maintenance script executable...\e[97m"
|
||||
chmod +x $PORTALBUILDDIRECTORY/python/maintenance-maint.sh
|
||||
chmod +x $PORTALPYTHONDIRECTORY/maintenance-maint.sh
|
||||
|
||||
#Remove old flights-maint.sh start up line from /etc/rc.local.
|
||||
sed -i '/build\/portal\/logging\/flights-maint.sh/d' /etc/rc.local
|
||||
|
||||
# Add flight logging maintenance script to rc.local.
|
||||
if ! grep -Fxq "$PORTALBUILDDIRECTORY/python/flights-maint.sh &" /etc/rc.local; then
|
||||
if ! grep -Fxq "$PORTALPYTHONDIRECTORY/flights-maint.sh &" /etc/rc.local; then
|
||||
echo -e "\e[94m Adding the flight logging maintenance script startup line to /etc/rc.local...\e[97m"
|
||||
LINENUMBER=($(sed -n '/exit 0/=' /etc/rc.local))
|
||||
((LINENUMBER>0)) && sudo sed -i "${LINENUMBER[$((${#LINENUMBER[@]}-1))]}i $PORTALBUILDDIRECTORY/python/flights-maint.sh &\n" /etc/rc.local
|
||||
((LINENUMBER>0)) && sudo sed -i "${LINENUMBER[$((${#LINENUMBER[@]}-1))]}i $PORTALPYTHONDIRECTORY/flights-maint.sh &\n" /etc/rc.local
|
||||
else
|
||||
fi
|
||||
|
||||
#Remove old maintenance-maint.sh start up line from /etc/rc.local.
|
||||
sed -i '/build\/portal\/logging\/maintenance-maint.sh/d' /etc/rc.local
|
||||
|
||||
# Add maintenance maintenance script to rc.local.
|
||||
if ! grep -Fxq "$PORTALBUILDDIRECTORY/python/maintenance-maint.sh &" /etc/rc.local; then
|
||||
if ! grep -Fxq "$PORTALPYTHONDIRECTORY/maintenance-maint.sh &" /etc/rc.local; then
|
||||
echo -e "\e[94m Adding the maintenance maintenance script startup line to /etc/rc.local...\e[97m"
|
||||
LINENUMBER=($(sed -n '/exit 0/=' /etc/rc.local))
|
||||
((LINENUMBER>0)) && sudo sed -i "${LINENUMBER[$((${#LINENUMBER[@]}-1))]}i $PORTALBUILDDIRECTORY/python/maintenance-maint.sh &\n" /etc/rc.local
|
||||
((LINENUMBER>0)) && sudo sed -i "${LINENUMBER[$((${#LINENUMBER[@]}-1))]}i $PORTALPYTHONDIRECTORY/maintenance-maint.sh &\n" /etc/rc.local
|
||||
fi
|
||||
|
||||
# Kill any previously running maintenance scripts.
|
||||
|
|
@ -163,10 +120,10 @@ fi
|
|||
|
||||
# Start flight logging.
|
||||
echo -e "\e[94m Executing the flight logging maintenance script...\e[97m"
|
||||
nohup $PORTALBUILDDIRECTORY/python/flights-maint.sh > /dev/null 2>&1 &
|
||||
nohup $PORTALPYTHONDIRECTORY/flights-maint.sh > /dev/null 2>&1 &
|
||||
|
||||
# Start maintenance.
|
||||
echo -e "\e[94m Executing the maintenance maintenance script...\e[97m"
|
||||
nohup $PORTALBUILDDIRECTORY/python/maintenance-maint.sh > /dev/null 2>&1 &
|
||||
nohup $PORTALPYTHONDIRECTORY/maintenance-maint.sh > /dev/null 2>&1 &
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue