summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/listen-handshake.sh17
-rwxr-xr-xscripts/offer_handshake.sh26
-rw-r--r--scripts/rc.setup163
3 files changed, 197 insertions, 9 deletions
diff --git a/scripts/listen-handshake.sh b/scripts/listen-handshake.sh
index bf612e9..7ce55c6 100755
--- a/scripts/listen-handshake.sh
+++ b/scripts/listen-handshake.sh
@@ -7,13 +7,20 @@ if [ -z $1 ]; then
fi
IFACE="$1"
-
-NC="netcat -c"
+NC="/opt/ivysync/bin/netcat"
# check if it is openbsd netcat
-NC_ver="`netcat -h 2>&1|head -n 1 | awk '{print $1}'`"
+NC_ver="`$NC -h 2>&1|head -n 1 | awk '{print $1}'`"
if [ "$NC_ver" = "OpenBSD" ]; then
echo "using OpenBSD version of netcat"
- NC="netcat -q 0"
+ NC="$NC -q 0"
+elif [ "$NC_ver" = "GNU" ]; then
+ echo "using GNU version of netcat"
+ NC="$NC -c"
+else
+ echo "error: your version of netcat is not compatible"
+ echo "please install an OpenBSD or GNU netcat implementation"
+ echo "found on this system: `netcat -h 2>&1|head -n1`"
+ exit 1
fi
# some more version might be around that is not supported..
@@ -21,7 +28,7 @@ fi
IP="`ifconfig $IFACE | grep 'inet addr'| awk '{print $2}'|cut -f2 -d:`"
echo "listening on $IFACE configured with address $IP ..."
-master="`echo | $NC -u -l 3332`"
+master="`echo | $NC -u -l -p 3332`"
echo "contacted by master $master"
echo "$IP" | netcat -u $master 3331
diff --git a/scripts/offer_handshake.sh b/scripts/offer_handshake.sh
index 54950c7..1564a76 100755
--- a/scripts/offer_handshake.sh
+++ b/scripts/offer_handshake.sh
@@ -1,7 +1,7 @@
#!/bin/bash
# here configure the file with the list of IP or hostnames, one per line
-LISTFILE=list
+LISTFILE=/root/list
if [ -z $1 ]; then
echo "usage: $0 network_interface"
@@ -12,6 +12,25 @@ IFACE="$1"
IP="`ifconfig $IFACE | grep 'inet addr'| awk '{print $2}'|cut -f2 -d:`"
+
+NC="/opt/ivysync/bin/netcat"
+# check if it is openbsd netcat
+NC_ver="`$NC -h 2>&1|head -n 1 | awk '{print $1}'`"
+if [ "$NC_ver" = "OpenBSD" ]; then
+ echo "using OpenBSD version of netcat"
+ NC="$NC -q 0"
+elif [ "$NC_ver" = "GNU" ]; then
+ echo "using GNU version of netcat"
+ NC="$NC -c"
+else
+ echo "error: your version of netcat is not compatible"
+ echo "please install an OpenBSD or GNU netcat implementation"
+ echo "found on this system: `netcat -h 2>&1|head -n1`"
+ exit 1
+fi
+
+
+
ready=false
for i in `cat $LISTFILE`; do
@@ -19,12 +38,12 @@ for i in `cat $LISTFILE`; do
echo -n "handshaking $i"
# background listener
- (answer=`echo | nc -q 0 -u -l 3331`;
+ (answer=`echo | $NC -u -l -p 3331`;
echo $answer > /tmp/handshake.$i.ok) &
while ! [ -r /tmp/handshake.$i.ok ]; do
sleep 1
- ../udpbroadcast $i 3332 $IP 1>&2 > /dev/null
+ udpbroadcast $i 3332 $IP 1>&2 > /dev/null
echo -n "."
done
echo -n " answer: `cat /tmp/handshake.$i.ok`"
@@ -32,4 +51,3 @@ for i in `cat $LISTFILE`; do
echo
done
-exit 0
diff --git a/scripts/rc.setup b/scripts/rc.setup
new file mode 100644
index 0000000..1cbeabc
--- /dev/null
+++ b/scripts/rc.setup
@@ -0,0 +1,163 @@
+#!/bin/zsh
+
+# this files initializes ivtv devices found
+# used inside ivysync.dyne module for initialisation
+# part of dyne:bolic GNU/Linux
+# GNU GPL v3 2006-2009 - Denis Jaromil Roio
+
+source /lib/dyne/utils.sh
+
+PATH=$PATH:/opt/$1/bin
+HOME=/root
+
+MOVIE=/opt/$1/firmware/v4l-cx2341x-init.mpg
+
+
+notice "Initializing IVTV devices"
+
+act "installing firmware"
+cp -ra /opt/$1/firmware/* /usr/lib/hotplug/firmware
+
+act "loading kernel module"
+loadmod videodev
+loadmod tveeprom
+loadmod v4l1_compat
+loadmod i2c_algo_bit
+loadmod cx2341x
+insmod /opt/$1/kernel/ivtv.ko
+
+act "detecting devices"
+
+
+#for i in 1 2 3 4; do
+# DEV="/dev/video`bc<<<$i+15`"
+# if [ -w "$DEV" ]; then
+# # kick the output devices
+# cat $MOVIE > "$DEV" & \
+# > /dev/null 2>&1
+# fi
+#done
+
+sync
+sleep 1
+sync
+
+#for pids in `ps ax|grep "$MOVIE"|awk '{print $1}'`; do
+# kill $pids > /dev/null 2>&1
+# sync
+#done
+
+# blank the screens
+ivtvfbctl /dev/fb0 --globalalpha=on --localalpha=off --alpha 0
+
+sync
+sleep 1
+sync
+
+# play test mpeg2
+for i in 1 2 3 4; do
+ DEV="/dev/video`bc<<<$i+15`"
+ if [ -w "$DEV" ]; then
+ echo " Video syncstarter device $i initialized"
+ chmod 666 "$DEV"
+# cat $MOVIE > "$DEV" &
+ fi
+done
+
+sync
+
+# setup input encoding
+### echo "Setting up video in devices 0, 1 & 2..."
+# -u 0: PAL
+# -f width=720,height=576(PAL)480(NTSC)
+# -p 0: tv-tuner input
+# -l 0: s-video and composite output
+# -c bitrate=8000000,bitrate_peak=16000000
+# -c stream_type=<#>
+# see ivtv.h IVTV_STREAM_* types (try 10 for DVD, or 0 for PS)
+
+act "setting up devices for PAL output"
+for i in 0 1 2 3; do
+ DEV="/dev/video${i}"
+ if [ -w "$DEV" ]; then
+
+ ivtvctl -d "$DEV" -p 0 -u 0 -l 0 -f width=720,height=576 \
+ -c bitrate=8000000,bitrate_peak=9000000,stream_type=10
+
+ sync
+
+ fi
+done
+
+action=`get_config ivysync`
+
+##################################
+############## run in single mode
+
+if [ "$action" = "run" ]; then
+ # setup $HOME to where we have saved the .ivysync playlists
+ HOME=/root
+ # loop indefinitely
+ while true; do
+
+ sync
+
+ ivysync-nox -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19 &
+
+ sleep 5
+
+ killall ivysync-nox
+
+ sleep 10
+
+ ivysync-nox -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19
+
+ done
+ # if loop ends then reboot
+ reboot
+fi
+
+##################################
+############## run in network mode
+if [ "`expr substr $action 1 3`" = "net" ]; then
+
+ while true; do
+
+ net="`echo $action | cut -d: -f2`"
+ if [ "`echo $action|cut -d: -f3`" = "master" ]; then
+ master=true
+ fi
+
+ # launches master
+ if [ "$master" = "true" ]; then
+ /root/offer-handshake.sh $net
+ else
+ /root/listen-handshake.sh $net
+ fi
+
+ sync
+
+ ivysync-udp -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19 &
+
+ sleep 3
+
+ if [ "$master" = "true" ]; then udpbroadcast 255.255.255.255 15500 a; fi
+
+ sleep 5
+
+ killall ivysync-udp
+
+ sleep 5
+
+ if [ "$master" = "true" ]; then
+ (sleep 5; udpbroadcast 255.255.255.255 15500 a )&
+ fi
+
+ ivysync-udp -d /dev/video16 -d /dev/video17 -d /dev/video18 -d /dev/video19
+
+ done
+ # if loop ends then reboot
+ reboot
+
+fi
+