root/sucast/sucast.sh

Revision 1199, 1.6 kB (checked in by alpt, 1 year ago)

--

  • Property svn:executable set to
Line 
1 #!/bin/bash
2 # Fri Sep 28 13:31:04 CEST 2007
3 # by (alpt | efphe | eriol | mancausoft)@freaknet.org
4 # thanks to crash for the projector
5 #
6
7 #### CONFIGURE HERE ####
8 #HOSTNAME="10.0.0.x"
9 PORT=8080
10 INCOMING=~/pkg/mov
11 PLAYER_CMD="mplayer -nosound"
12 #### CONFIGURE HERE ####
13
14 cd $INCOMING
15
16 while [ 0 ]; do
17         rm -f $FIFO1 $FIFO2
18         if [ ! -z "$tfile" ]; then rm $tfile; fi
19         tfile=$(tempfile)
20 cat <<FOE | nc -n -v -l -p $PORT -q 1 2>> $tfile >> $tfile
21 <html>
22         <head> <title>Sucast v1</title> </head>
23         <body>
24         <h1>Sucast <a href="http://freaknet.org/alpt/src/misc/sucast/">v1</a></h1>
25         <p>Clicca su uno dei link seguenti oppure <br/>
26         vai su http://$HOSTNAME:$PORT/http://hostname/path/to/your/streaming.ogg
27         <br/>
28         Usa ftp su $HOSTNAME per uploadare un file.<br/>
29         --
30         <br/>
31         Click on one of the following links or go to <br/>
32         http://$HOSTNAME:$PORT/http://hostname/path/to/your/streaming.ogg<br/>
33         Use ftp on $HOSTNAME to upload a file.<br/>
34         </p>
35 $(find ./ | sed -e 's#^.##' | awk '{print $0"__DIVISOR__" $0}'  | sed -e 's/^/<a href="/' -e 's/__DIVISOR__/">/' -e 's#$#</a><br>#')
36         </body>
37 </html>
38 FOE
39         addr=$(cat $tfile | grep 'connect to' | cut -d ' ' -f 6 | sed -e 's/\[//' -e 's/\]//' -e 's/\.//g')
40         url=$(cat $tfile | grep GET | cut -d ' ' -f 2 | sed -e 's#^/##' -e 's/%20/ /g')
41         if [ -z "$url" ]; then continue; fi
42
43         if [ ! -f "$url" ] && echo $url | grep -vq '://'; then continue; fi
44
45         echo --
46         echo addr: $addr url: $url
47         echo --
48
49         varpid="PID$addr"
50         if [ ! -z "${!varpid}" ]
51         then
52                 kill -9 ${!varpid}
53         fi
54
55         $PLAYER_CMD "$url" &> /dev/null &
56         sleep 0.1
57         eval "$varpid=`pidof mplayer | cut -d ' ' -f 1`"
58 done
Note: See TracBrowser for help on using the browser.