-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
03-rtl_airband
executable file
·82 lines (64 loc) · 3.7 KB
/
03-rtl_airband
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/command/with-contenv bash
# shellcheck shell=bash
if [ -z "$RTLSDRAIRBAND_CUSTOMCONFIG" ]; then
sed -i "s/type = \"[^<]*\"; # device 1 radio/type = \"$RTLSDRAIRBAND_RADIO_TYPE\"; # device 1 radio/g" /usr/local/etc/rtl_airband.conf
sed -i "s/gain = [^<]*; # device 1/gain = $RTLSDRAIRBAND_GAIN; # device 1/g" /usr/local/etc/rtl_airband.conf
if [ -n "${ENABLE_PROMETHEUS}" ]; then
grep -qv "stats_filepath = \"/tmp/rtl_airband_stats.txt\";" /usr/local/etc/rtl_airband.conf && \
sed -i "1istats_filepath = \"/tmp/rtl_airband_stats.txt\";" /usr/local/etc/rtl_airband.conf
fi
if [ -n "${RTLSDRAIRBAND_CORRECTION}" ]; then
sed -i "s/#correction = [^<]*; # device 1/correction = $RTLSDRAIRBAND_CORRECTION; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
if [ -n "${RTLSDRAIRBAND_LABELS}" ]; then
sed -i "s/#labels = ([^<]*); # device 1/labels = ( $RTLSDRAIRBAND_LABELS ); # device 1/g" /usr/local/etc/rtl_airband.conf
fi
if [ -n "${RTLSDRAIRBAND_SHOWMETADATA}" ]; then
sed -i "s/send_scan_freq_tags = true; # device 1/#send_scan_freq_tags = true; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
sed -i "s/mode = \"[^<]*\"; # device 1/mode = \"$RTLSDRAIRBAND_MODE\"; # device 1/g" /usr/local/etc/rtl_airband.conf
sed -i "s/port = [^<]*; # device 1/port = $PORT; # device 1/g" /usr/local/etc/rtl_airband.conf
# rtl_airband.conf for some reason has different config names for multichannel and scan modes
# fix to get that working
if [ -z "${RTLSDRAIRBAND_FREQS}" ]; then
echo "Error! Frequency not set. Please set RTLSDRAIRBAND_FREQS. See https://github.com/fredclausen/docker-rtlsdrairband#rtlsdr-airband for details. Aborting!"
exit 1
fi
if [ "$RTLSDRAIRBAND_MODE" = "scan" ]; then
sed -i "s/#freqs = ([^<]*); # device 1/freqs = ( $RTLSDRAIRBAND_FREQS ); # device 1/g" /usr/local/etc/rtl_airband.conf
else
sed -i "s/#freq = [^<]*; # device 1/freq = $RTLSDRAIRBAND_FREQS; # device 1/g" /usr/local/etc/rtl_airband.conf
sed -i "s/centerfreq = [^<]*; # device 1/centerfreq = $RTLSDRAIRBAND_FREQS; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
sed -i "s/mountpoint = \"[^<]*\"; # device 1/mountpoint = \"$RTLSDRAIRBAND_MOUNTPOINT\"; # device 1/g" /usr/local/etc/rtl_airband.conf
sed -i "s/name = \"[^<]*\"; # device 1 name/name = \"$RTLSDRAIRBAND_NAME\"; # device 1 name/g" /usr/local/etc/rtl_airband.conf
sed -i "s/\\genre = \"[^<]*\"; # device 1/\\genre = \"$RTLSDRAIRBAND_GENRE\"; # device 1/g" /usr/local/etc/rtl_airband.conf
sed -i "s/description = \"[^<]*\"; # device 1/description = \"$RTLSDRAIRBAND_DESCRIPTION\"; # device 1/g" /usr/local/etc/rtl_airband.conf
# If serial not set, set the index to 0
if [ -z "${RTLSDRAIRBAND_SERIAL}" ]; then
sed -i "s/#index = \"[^<]*\"; # device 1/index = 0; # device 1/g" /usr/local/etc/rtl_airband.conf
else
sed -i "s/#serial = \"[^<]*\"; # device 1/serial = \"$RTLSDRAIRBAND_SERIAL\"; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
# squelch for testing
if [ -n "${SQUELCH}" ]; then
sed -i "s/#squelch = 0; # device 1/squelch = 0; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
if [ -n "${LOG_SCANNED_ACTIVITY}" ]; then
sed -i "s/scan_activity = false; # device 1/scan_activity = true; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
if [ -n "${FFT_SIZE}" ]; then
sed -i "s/fft_size = 2048;/fft_size = $FFT_SIZE;/g" /usr/local/etc/rtl_airband.conf
fi
if [ -n "${SAMPLE_RATE}" ]; then
sed -i "s/sample_rate = 2.56; # device 1/sample_rate = $SAMPLE_RATE; # device 1/g" /usr/local/etc/rtl_airband.conf
fi
else
if [ -f "/run/rtlsdr-airband/rtl_airband.conf" ]; then
echo "rtlsdr-airband custom config provided. Ignoring RTLSDRBAND config options"
else
echo "rtlsdr-airband custom config option set but file not found. Aborting."
exit 1
fi
fi
exit 0