mirror of
https://github.com/smittix/intercept.git
synced 2026-07-26 09:48:09 -07:00
Check common paths for dump1090 when not in PATH
Flask apps may run with a restricted PATH that doesn't include /usr/local/bin. Now explicitly checks common installation locations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+28
-3
@@ -3,6 +3,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import queue
|
import queue
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
@@ -21,6 +22,30 @@ adsb_bp = Blueprint('adsb', __name__, url_prefix='/adsb')
|
|||||||
# Track if using service
|
# Track if using service
|
||||||
adsb_using_service = False
|
adsb_using_service = False
|
||||||
|
|
||||||
|
# Common installation paths for dump1090 (when not in PATH)
|
||||||
|
DUMP1090_PATHS = [
|
||||||
|
'/usr/local/bin/dump1090',
|
||||||
|
'/usr/local/bin/dump1090-fa',
|
||||||
|
'/usr/local/bin/dump1090-mutability',
|
||||||
|
'/usr/bin/dump1090',
|
||||||
|
'/usr/bin/dump1090-fa',
|
||||||
|
'/usr/bin/dump1090-mutability',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def find_dump1090():
|
||||||
|
"""Find dump1090 binary, checking PATH and common locations."""
|
||||||
|
# First try PATH
|
||||||
|
for name in ['dump1090', 'dump1090-mutability', 'dump1090-fa']:
|
||||||
|
path = shutil.which(name)
|
||||||
|
if path:
|
||||||
|
return path
|
||||||
|
# Check common installation paths directly
|
||||||
|
for path in DUMP1090_PATHS:
|
||||||
|
if os.path.isfile(path) and os.access(path, os.X_OK):
|
||||||
|
return path
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def check_dump1090_service():
|
def check_dump1090_service():
|
||||||
"""Check if dump1090 SBS port (30003) is available."""
|
"""Check if dump1090 SBS port (30003) is available."""
|
||||||
@@ -154,7 +179,7 @@ def parse_sbs_stream(service_addr):
|
|||||||
def check_adsb_tools():
|
def check_adsb_tools():
|
||||||
"""Check for ADS-B decoding tools."""
|
"""Check for ADS-B decoding tools."""
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'dump1090': shutil.which('dump1090') is not None or shutil.which('dump1090-mutability') is not None or shutil.which('dump1090-fa') is not None,
|
'dump1090': find_dump1090() is not None,
|
||||||
'rtl_adsb': shutil.which('rtl_adsb') is not None
|
'rtl_adsb': shutil.which('rtl_adsb') is not None
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -174,10 +199,10 @@ def start_adsb():
|
|||||||
gain = data.get('gain', '40')
|
gain = data.get('gain', '40')
|
||||||
device = data.get('device', '0')
|
device = data.get('device', '0')
|
||||||
|
|
||||||
dump1090_path = shutil.which('dump1090') or shutil.which('dump1090-mutability') or shutil.which('dump1090-fa')
|
dump1090_path = find_dump1090()
|
||||||
|
|
||||||
if not dump1090_path:
|
if not dump1090_path:
|
||||||
return jsonify({'status': 'error', 'message': 'dump1090 not found.'})
|
return jsonify({'status': 'error', 'message': 'dump1090 not found. Install dump1090/dump1090-fa or ensure it is in /usr/local/bin/'})
|
||||||
|
|
||||||
cmd = [dump1090_path, '--net', '--gain', gain, '--device-index', str(device), '--quiet']
|
cmd = [dump1090_path, '--net', '--gain', gain, '--device-index', str(device), '--quiet']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user