Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ RUN mkdir -p /usr/lib/pkgconfig && \
echo "prefix=/usr\nexec_prefix=\${prefix}\nlibdir=$LIB_DIR\nincludedir=\${prefix}/include\n\nName: mbedx509\nDescription: MbedTLS X509 Library\nVersion: 2.28.0\nLibs: -L\${libdir} -lmbedx509\nCflags: -I\${includedir}" > /usr/lib/pkgconfig/mbedx509.pc && \
chmod 644 /usr/lib/pkgconfig/mbedtls.pc /usr/lib/pkgconfig/mbedcrypto.pc /usr/lib/pkgconfig/mbedx509.pc

# Download and install go2rtc
RUN ARCH=$(uname -m) && \
case $ARCH in \
x86_64) GO2RTC_ARCH="amd64" ;; \
aarch64) GO2RTC_ARCH="arm64" ;; \
armv7l) GO2RTC_ARCH="arm" ;; \
*) echo "Unsupported architecture: $ARCH"; exit 1 ;; \
esac && \
# Build go2rtc from opensensor fork (includes memory leak fixes)
# Install Go for building go2rtc
RUN curl -L https://go.dev/dl/go1.23.4.linux-$(dpkg --print-architecture).tar.gz | tar -C /usr/local -xzf - && \
export PATH=$PATH:/usr/local/go/bin && \
mkdir -p /bin /etc/lightnvr/go2rtc && \
RELEASE_URL=$(curl -s https://api.github.com/repos/AlexxIT/go2rtc/releases/latest | grep "browser_download_url.*linux_$GO2RTC_ARCH" | cut -d '"' -f 4) && \
curl -L -o /bin/go2rtc $RELEASE_URL && \
# Clone and build go2rtc from opensensor fork
cd /tmp && \
git clone --depth 1 --branch fix/memory-leaks https://github.com/opensensor/go2rtc.git && \
cd go2rtc && \
CGO_ENABLED=0 /usr/local/go/bin/go build -ldflags "-s -w" -trimpath -o /bin/go2rtc . && \
cd / && rm -rf /tmp/go2rtc /usr/local/go && \
chmod +x /bin/go2rtc && \
# Create basic configuration file
echo "# go2rtc configuration file" > /etc/lightnvr/go2rtc/go2rtc.yaml && \
Expand Down
22 changes: 15 additions & 7 deletions scripts/install_go2rtc.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
# Script to download and install go2rtc for WebRTC streaming
# Uses opensensor/go2rtc fork with memory leak fixes

set -e

Expand All @@ -8,6 +9,8 @@ INSTALL_DIR="/usr/local/bin"
CONFIG_DIR="/etc/lightnvr/go2rtc"
VERSION="latest"
ARCH=$(uname -m)
# Use opensensor fork by default (includes memory leak fixes)
REPO="opensensor/go2rtc"

# Display usage information
usage() {
Expand Down Expand Up @@ -80,15 +83,20 @@ mkdir -p "$CONFIG_DIR"

# Determine download URL
if [ "$VERSION" = "latest" ]; then
# Get latest release URL
RELEASE_URL=$(curl -s https://api.github.com/repos/AlexxIT/go2rtc/releases/latest | grep "browser_download_url.*linux_$GO2RTC_ARCH" | cut -d '"' -f 4)
# Get latest release URL from opensensor fork
RELEASE_URL=$(curl -s https://api.github.com/repos/$REPO/releases/latest | grep "browser_download_url.*linux_$GO2RTC_ARCH" | cut -d '"' -f 4)
if [ -z "$RELEASE_URL" ]; then
echo "Failed to determine latest release URL. Please specify a version."
exit 1
echo "Failed to determine latest release URL from $REPO."
echo "Falling back to upstream AlexxIT/go2rtc..."
RELEASE_URL=$(curl -s https://api.github.com/repos/AlexxIT/go2rtc/releases/latest | grep "browser_download_url.*linux_$GO2RTC_ARCH" | cut -d '"' -f 4)
if [ -z "$RELEASE_URL" ]; then
echo "Failed to determine latest release URL. Please specify a version."
exit 1
fi
fi
else
# Construct URL for specific version
RELEASE_URL="https://github.com/AlexxIT/go2rtc/releases/download/$VERSION/go2rtc_linux_$GO2RTC_ARCH"
# Construct URL for specific version from opensensor fork
RELEASE_URL="https://github.com/$REPO/releases/download/$VERSION/go2rtc_linux_$GO2RTC_ARCH"
fi

echo "Downloading from: $RELEASE_URL"
Expand All @@ -103,7 +111,7 @@ chmod +x "$INSTALL_DIR/go2rtc"
if [ ! -f "$CONFIG_DIR/go2rtc.yaml" ]; then
cat > "$CONFIG_DIR/go2rtc.yaml" << EOF
# go2rtc configuration file
# See https://github.com/AlexxIT/go2rtc for documentation
# See https://github.com/opensensor/go2rtc for documentation (fork with memory fixes)

api:
listen: :1984
Expand Down
Loading