mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-26 19:06:11 +01:00
e2239d36c9
* Auto discover internal WebRTC candidate for add-on * Write logs to stderr * Fix port number * Integrate with newest changes * Update docs * Use local variable more * Use Python to write file, fix JSON->YAML * Store into variable * Update docs/docs/configuration/live.md Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> * Update docs/docs/configuration/live.md Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com> * Update docs/docs/configuration/live.md * Update docs/docs/configuration/live.md * Refator s6 scripts to the new format * Remove unneeded workaround * Update docker/rootfs/usr/local/go2rtc/create_config.py * Migrate logging to new s6 format * Remove more unnecessary s6 variables * Fix prepare-log and when go2rtc is not present in config * Restart the whole container if either Frigate or go2rtc fails * D * Fix service name in finish * Fix nginx finish comment * Restart improvements * Fix devcontainer * Fix format * Update Dockerfile Co-authored-by: Felipe Santos <felipecassiors@gmail.com> * Improve scripts logging Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
61 lines
1.9 KiB
Plaintext
Executable File
61 lines
1.9 KiB
Plaintext
Executable File
#!/command/with-contenv bash
|
|
# shellcheck shell=bash
|
|
# Start the go2rtc service
|
|
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
# Tell S6-Overlay not to restart this service
|
|
s6-svc -O .
|
|
|
|
function get_ip_and_port_from_supervisor() {
|
|
local ip_address
|
|
# Example: 192.168.1.10/24
|
|
local 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 "[INFO] Got IP address from supervisor: ${ip_address}" >&2
|
|
else
|
|
echo "[WARN] Failed to get IP address from supervisor" >&2
|
|
return 0
|
|
fi
|
|
|
|
local webrtc_port
|
|
local 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 "[INFO] Got WebRTC port from supervisor: ${ip_address}" >&2
|
|
else
|
|
echo "[WARN] Failed to get WebRTC port from supervisor" >&2
|
|
return 0
|
|
fi
|
|
|
|
export FRIGATE_GO2RTC_WEBRTC_CANDIDATE_INTERNAL="${ip_address}:${webrtc_port}"
|
|
}
|
|
|
|
echo "[INFO] Preparing go2rtc config..." >&2
|
|
|
|
if [[ -n "${SUPERVISOR_TOKEN:-}" ]]; then
|
|
# Running as a Home Assistant add-on, infer the IP address and port
|
|
get_ip_and_port_from_supervisor
|
|
fi
|
|
|
|
raw_config=$(python3 /usr/local/go2rtc/create_config.py)
|
|
|
|
echo "[INFO] Starting go2rtc..." >&2
|
|
|
|
# Replace the bash process with the go2rtc process, redirecting stderr to stdout
|
|
exec 2>&1
|
|
exec go2rtc -config="${raw_config}"
|