Advanced portal feature fixes.

pull/571/head
jprochazka 2024-06-26 23:40:40 -04:00
rodzic eadec87a17
commit c8cca2ced4
4 zmienionych plików z 33 dodań i 16 usunięć

Wyświetl plik

@ -382,20 +382,11 @@ url.redirect += (
"^/dump1090$" => "/dump1090/"
)
# Add CORS header
server.modules += ( "mod_setenv" )
\$HTTP["url"] =~ "^/dump1090/data/.*\.json$" {
setenv.add-response-header = ( "Access-Control-Allow-Origin" => "*" )
}
EOF
fi
sudo tee -a /etc/lighttpd/conf-available/87-adsb-portal.conf > /dev/null <<EOF
# Block all access to the data directory accept for local requests.
\$HTTP["remoteip"] !~ "127.0.0.1" {
\$HTTP["url"] =~ "^/data/" {
url.access-deny = ( "" )
}
}
EOF
if [[ ! -L "/etc/lighttpd/conf-enabled/87-adsb-portal.conf" ]] ; then
echo -e "\e[94m Enabling the Lighttpd portal configuration file...\e[97m"

Wyświetl plik

@ -33,8 +33,8 @@
## VARIABLES
PORTAL_PYTHON_DIRECTORY="${RECEIVER_BUILD_DIRECTORY}/python"
PYTHON_PATH=`which python`
PORTAL_PYTHON_DIRECTORY="${RECEIVER_BUILD_DIRECTORY}/portal/python"
PYTHON_PATH=`which python3`
## SETUP FLIGHT LOGGING
@ -45,6 +45,6 @@ echo -e ""
# Create the cron jobs responsible for logging and maintenance.
echo -e "\e[94m Creating the maintenance maintenance script...\e[97m"
sudo tee /etc/cron.d/adsb-receiver-flight-logging > /dev/null <<EOF
* * * * * root ${PYTHON_PATH} ${PORTAL_PYTHON_DIRECTORY}/flights.py; sleep 30; root ${PYTHON_PATH} ${PORTAL_PYTHON_DIRECTORY}/flights.py
* * * * * root ${PYTHON_PATH} ${PORTAL_PYTHON_DIRECTORY}/flights.py
30 * * * * root ${PYTHON_PATH} ${PORTAL_PYTHON_DIRECTORY}/maintenance.py
EOF

Wyświetl plik

@ -36,15 +36,29 @@
# 3) Update the last time the flight was seen.
import datetime
import fcntl
import json
import time
import os
import time
from urllib.request import urlopen
def log(string):
#print(string) # uncomment to enable debug logging
return
# Do not allow another instance of the script to run.
lock_file = open('/tmp/flights.py.lock','w')
try:
fcntl.flock(lock_file, fcntl.LOCK_EX|fcntl.LOCK_NB)
except (IOError, OSError):
log('another instance already running')
quit()
lock_file.write('%d\n'%os.getpid())
lock_file.flush()
# Read the configuration file.
with open(os.path.dirname(os.path.realpath(__file__)) + '/config.json') as config_file:
config = json.load(config_file)
@ -125,7 +139,7 @@ class FlightsProcessor(object):
log("\tFound Aircraft ID: " + str(aircraft_id))
# Check that a flight is tied to this track.
if aircraft.has_key('flight'):
if 'flight' in aircraft:
self.processFlight(aircraft_id, aircraft)
def processFlight(self, aircraft_id, aircraft):
@ -166,7 +180,7 @@ class FlightsProcessor(object):
if row == None or row[0] != aircraft["messages"]:
# Add this position to the database.
if aircraft.has_key('squawk'):
if 'squawk' in aircraft:
params = (flight_id, self.time_now, aircraft["messages"], aircraft["squawk"],
aircraft["lat"], aircraft["lon"], aircraft["track"],
aircraft["nav_altitude"], aircraft["geom_rate"], aircraft["gs"], aircraft_id,)

Wyświetl plik

@ -28,11 +28,23 @@
# SOFTWARE. #
#================================================================================#
import datetime
import fcntl
import json
import os
import datetime
import time
# Do not allow another instance of the script to run.
lock_file = open('/tmp/flights.py.lock','w')
try:
fcntl.flock(lock_file, fcntl.LOCK_EX|fcntl.LOCK_NB)
except (IOError, OSError):
quit()
lock_file.write('%d\n'%os.getpid())
lock_file.flush()
while True:
## Read the configuration file.