Multiple vdr peers on same machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have two vdr instances running on the same machine, one for recording and 
other for viewing. Then I wanted them to use the new vdr peer system to be 
able to edit timers from the viewing side.

Running two vdr's didn't work because they both want to bind the 6419 port, so 
I made a work-around with network namespaces like this:

First, a helper script to create a network namespace if not already created 
and run a command there:

/usr/local/sbin/Nsenter_vdr2
----------------------------------------
#!/bin/bash

mp=/home/vdr/vdr2/netns
addr=192.168.8.2/24
gw=192.168.8.1

if ! mountpoint -q $mp ; then
        unshare --net=$mp true || exit 1
        ip link add vdr2eth type veth peer name eth0 netns $mp
        nsenter --net=$mp sh -c "ip link set eth0 up \
        && ip a add $addr dev eth0 \
        && ip link set lo up \
        && ip -4 route add default via $gw"
fi

if test -n "$SUDO_USER" -a "$SUDO_USER" != root ; then
        exec nsenter --net=$mp sudo -u "$SUDO_USER" "$@"
else
        exec nsenter --net=$mp "$@"
fi
----------------------------------------

The name space mount point is a reqular file (empty) and not a directory.
Nsenter script creates a veth pair named vdr2eth on the outside and eth0 
inside.

I used /etc/network/interfaces to set vdr2eth address, but it coud be done in 
the Nsenter script too. 

allow-hotplug vdr2eth
iface vdr2eth inet static
        address 192.168.8.1
        netmask 255.255.255.0

Then I run the recording instance of vdr normally on the outside and add 
permissions for 192.168.8.2 in svdrphosts and streamdevhosts.

Viewing vdr is run in the network namespace something like this:

#!/bin/bash

if test "$1" = "nsentered" ; then
 shift
 exec vdr -D- "-Psofthddevice -f" -i 1 -Pstreamdev-client "$@"
 exit 1
fi

while true ; do
 sudo Nsenter_vdr2 "$0" nsentered "$@"
done


I don't need to peer the viewing vdr to other computers in the local network. 
If that were the case, then the outside end of the veth pair would need to be 
bridged with the physical network card of the machine.


_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
https://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr




[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux