setchannel.sh

Script per il Submit della singola stazione - Andrea Belloni, 12/03/2014 05:16 PM

Download (974 Bytes)

 
1
#!/bin/sh
2

    
3
decode(){
4
echo $QUERY_STRING |\
5
   sed 's/+/ /g'| sed 's/\%0[dD]//g' |\
6
   awk '/%/{while(match($0,/\%[0-9a-fA-F][0-9a-fA-F]/))\
7
     {$0=substr($0,1,RSTART-1)sprintf("%c",0+("0x"substr(\
8
      $0,RSTART+1,2)))substr($0,RSTART+3);}}{print}'
9
}
10

    
11
TMP1=$( decode )
12
TMP=${TMP1%&name*}
13
CHAN=${TMP%=http*}
14
CHANLEN1=`expr length $CHAN + 1`
15
URL=${TMP:$CHANLEN1}
16
NAMEKV=`expr "$TMP1" : '.*\(name.*\)'`
17
NAMEK=${NAMEKV%=*}
18
NAMEKLEN1=`expr length $NAMEK + 1`
19
NAMEV=${NAMEKV:$NAMEKLEN1}
20

    
21
uci set radio.@radio[0].$CHAN=$URL
22
uci set radio.@radio[0].$NAMEK=$NAMEV
23

    
24
CHN=${NAMEK:4}
25
curl -u root:arduino http://localhost/arduino/chname/$NAMEV/$CHN
26

    
27
echo 'Content-type: text/html'
28
echo
29

    
30
echo '<head>'
31
echo '<meta http-equiv="Refresh" content="0;url=http://arduino.local/cgi-bin/radio.cgi" />'
32
echo '</head>'
33
echo '<html><body>'
34
#echo "$SER"
35
#echo '<br>'
36
#echo "Setting Channel $CHAN to station $URL"
37
#echo '<br>'
38
#echo "Setting Channel $NAMEK to station $NAMEV"
39
echo '</body></html>'