From cba2827e140ad1bcf48adfc57a9e647fbd141b52 Mon Sep 17 00:00:00 2001 From: Rajan Patel Date: Tue, 2 Apr 2024 04:16:55 +0000 Subject: [PATCH] add internal rtl_tcp --- Dockerfile | 10 +++++++--- README.md | 15 ++++++++++----- rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/run | 8 ++++++++ rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/type | 1 + rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/run | 4 ++++ rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/type | 1 + .../s6-overlay/s6-rc.d/user/contents.d/rtl_tcp | 0 .../s6-overlay/s6-rc.d/user/contents.d/rtlmuxer | 0 rootfs/etc/services.d/rtlmuxer/run | 4 ---- 9 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/run create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/type create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/run create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/type create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/rtl_tcp create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/rtlmuxer delete mode 100644 rootfs/etc/services.d/rtlmuxer/run diff --git a/Dockerfile b/Dockerfile index bd1da83..2de7eec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base +FROM ghcr.io/sdr-enthusiasts/docker-baseimage:rtlsdr SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -28,8 +28,12 @@ RUN set -x && \ COPY rootfs/ / -ENV SRC_ADDR="" \ +ENV SRC_ADDR="127.0.0.1" \ SRC_PORT="1234" \ SINK_ADDR="0.0.0.0" \ RW_SINK_PORT="7373" \ - RO_SINK_PORT="7374" \ No newline at end of file + RO_SINK_PORT="7374" \ + GAIN="0" \ + FREQ="1545600550" \ + RATE="1536000" \ + SERIAL="00001542" diff --git a/README.md b/README.md index 32364e4..8a30fd1 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,13 @@ This container is a thin wrapper around [rpatel3001/rtlmuxer](https://github.com | Variable | Description | Default | |----------|-------------|---------| -| `SRC_ADDR` | Address of the rtl_tcp source we are proxying. | Unset | -| `SRC_PORT` | Port of the rtl_tcp source we are proxying. | 1234 | -| `SINK_ADDR` | Address to bind for the proxied connections. | 0.0.0.0 | -| `RW_SINK_PORT` | Port to bind for the read/write proxy connection. | 7373 | -| `RO_SINK_PORT` | Port to bind for the read-only proxy connection. | 7374 | \ No newline at end of file +| `SRC_ADDR` | Address of the rtl_tcp source we are proxying. | 127.0.0.1 | +| `SRC_PORT` | Port of the rtl_tcp source we are proxying. | 1234 | +| `SINK_ADDR` | Address to bind for the proxied connections. | 0.0.0.0 | +| `RW_SINK_PORT` | Port to bind for the read/write proxy connection. | 7373 | +| `RO_SINK_PORT` | Port to bind for the read-only proxy connection. | 7374 | +| `RTL_TCP` | Set to any value to run RTL_TCP inside the container. | Unset | +| `GAIN` | Initial gain when using RTL_TCP. | 0 | +| `FREQ` | Initial frequency when using RTL_TCP. | 1545600550 | +| `RATE` | Initial sample rate when using RTL_TCP. | 1536000 | +| `SERIAL` | Serial or device index for RTL_TCP. | 00001542 | diff --git a/rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/run b/rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/run new file mode 100644 index 0000000..57d6faa --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/run @@ -0,0 +1,8 @@ +#!/command/with-contenv bash +#shellcheck shell=bash + +if [[ -n "${RTL_TCP}" ]]; then + exec rtl_tcp -a 0.0.0.0 -p $SRC_PORT -f $FREQ -g $GAIN -s $RATE -d $SERIAL 2>&1 | stdbuf -o0 awk '{print "[rtlmuxer] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}' +else + exec sleep 86400 +fi diff --git a/rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/type b/rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/rtl_tcp/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/run b/rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/run new file mode 100644 index 0000000..fa028f9 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/run @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +#shellcheck shell=bash + +exec rtlmuxer --src-address=$SRC_ADDR --src-port=$SRC_PORT --sink-bind-address=$SINK_ADDR --sink-bind-port-a=$RW_SINK_PORT --sink-bind-port-b=$RO_SINK_PORT 2>&1 | stdbuf -o0 awk '{print "[rtlmuxer] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}' diff --git a/rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/type b/rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/rtlmuxer/type @@ -0,0 +1 @@ +longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/rtl_tcp b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/rtl_tcp new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/rtlmuxer b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/rtlmuxer new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/services.d/rtlmuxer/run b/rootfs/etc/services.d/rtlmuxer/run deleted file mode 100644 index fedc294..0000000 --- a/rootfs/etc/services.d/rtlmuxer/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/with-contenv bash -#shellcheck shell=bash - -rtlmuxer --src-address=$SRC_ADDR --src-port=$SRC_PORT --sink-bind-address=$SINK_ADDR --sink-bind-port-a=$RW_SINK_PORT --sink-bind-port-b=$RO_SINK_PORT 2>&1 | stdbuf -o0 awk '{print "[rtlmuxer] " strftime("%Y/%m/%d %H:%M:%S", systime()) " " $0}'