mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 09:45:22 +03:00
Auto discover internal WebRTC candidate for add-on
This commit is contained in:
parent
e0b3b27b8a
commit
1f4be6e964
@ -10,7 +10,9 @@ apt-get -qq install --no-install-recommends -y \
|
||||
wget \
|
||||
procps vainfo \
|
||||
unzip locales tzdata libxml2 xz-utils \
|
||||
python3-pip
|
||||
python3-pip \
|
||||
curl \
|
||||
jq
|
||||
|
||||
mkdir -p -m 600 /root/.gnupg
|
||||
|
||||
|
||||
47
docker/rootfs/etc/cont-init.d/prepare-go2rtc.sh
Executable file
47
docker/rootfs/etc/cont-init.d/prepare-go2rtc.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/command/with-contenv bash
|
||||
# shellcheck shell=bash
|
||||
# Prepare the go2rtc config
|
||||
|
||||
set -o errexit -o nounset -o pipefail
|
||||
|
||||
if [[ -z "${SUPERVISOR_TOKEN:-}" ]]; then
|
||||
# Not running as a Home Assistant add-on, don't do anything
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Example: 192.168.1.10/24
|
||||
ip_regex='^([0-9]{1,3}\.{3}[0-9]{1,3})/[0-9]{1,2}$'
|
||||
if ip_address=$(
|
||||
curl -fsSL \
|
||||
-H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
http://supervisor/network/interface/default/info |
|
||||
jq --exit-status --raw-output '.data.ipv4.address[0]'
|
||||
) && [[ "${ip_address}" =~ ${ip_regex} ]]; then
|
||||
ip_address="${BASH_REMATCH[1]}"
|
||||
echo "Got IP address from supervisor: ${ip_address}"
|
||||
else
|
||||
echo "Failed to get IP address from supervisor"
|
||||
# Exit with success so that the container can still start
|
||||
exit 0
|
||||
fi
|
||||
|
||||
port_regex='^([0-9]{1,5})$'
|
||||
if webrtc_port=$(
|
||||
curl -fsSL \
|
||||
-H "Authorization: Bearer ${SUPERVISOR_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
http://supervisor/addons/self/info |
|
||||
jq --exit-status --raw-output '.data.network["22/tcp"]'
|
||||
) && [[ "${webrtc_port}" =~ ${port_regex} ]]; then
|
||||
webrtc_port="${BASH_REMATCH[1]}"
|
||||
echo "Got WebRTC port from supervisor: ${ip_address}"
|
||||
else
|
||||
echo "Failed to get WebRTC port from supervisor"
|
||||
# Exit with success so that the container can still start
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Replace the IP address in the config
|
||||
candidate="${ip_address}:${webrtc_port}"
|
||||
sed --in-place "s/# - %%CANDIDATE%%/- ${candidate}/" /usr/local/go2rtc/go2rtc.yaml
|
||||
@ -4,4 +4,5 @@ log:
|
||||
webrtc:
|
||||
listen: ":8555"
|
||||
candidates:
|
||||
# - %%CANDIDATE%%
|
||||
- stun:8555
|
||||
|
||||
Loading…
Reference in New Issue
Block a user