[c18e03]: scripts / S99oggstreamer  Maximize  Restore  History

Download this file

99 lines (81 with data), 3.1 kB

#!/bin/sh
cd /mnt/flash/root/bin

WEBROOT=/mnt/flash/www
FILECMP=/mnt/flash/root/bin/filecmp
TEMP_DIR=/tmp
PLAYLIST=playlist.m3u
INDEXFILE=index.html
INDEXFILEPRE=index.html.pre

#ipaddr=$(/sbin/ifconfig | grep 'inet addr:' | ./get_ipaddr)

ipaddr=127.0.0.1
usedhcp=$(/mnt/flash/root/bin/checkconfig -b ipconfig.usedhcp)


if [ "$usedhcp" == "TRUE" ]; then
   ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr:' | ./get_ipaddr)
   if [ "$ipaddr" == "" ]; then
      sleep 10
      echo "waited 10s" > /tmp/dhcp.log
      ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr:' | ./get_ipaddr)
      if [ "$ipaddr" == "" ]; then
         sleep 20
         echo "waited 20s" >> /tmp/dhcp.log
         ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr:' | ./get_ipaddr)
         if [ "$ipaddr" == "" ]; then
            sleep 40
            echo "waited 40s" >> /tmp/dhcp.log
            ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr:' | ./get_ipaddr)
            if [ "$ipaddr" == "" ]; then
              #dhcp timout
              echo "dhcp timeout" >> /tmp/dhcp.log
              ipaddr=127.0.0.1
            fi
         fi
      fi
   fi       
else 
   ipaddr=$(/sbin/ifconfig eth0 | grep 'inet addr:' | ./get_ipaddr)
fi

usesighttpd=$(/mnt/flash/root/bin/checkconfig -b internalserver.enabled)
encoder=$(/mnt/flash/root/bin/checkconfig -s quality.encoder)

#run updateconffiles if we are on a pristine device
if [ ! -f /etc/sighttpd.conf ]; then
    /mnt/flash/root/bin/updateconffiles
fi

# generate Playlist
./busybox sed "s/IPADDR/$ipaddr/g" $WEBROOT/playlist.m3u.template > $TEMP_DIR/$PLAYLIST

# ... and copy if it differs from the previous version
cmpresult=$($FILECMP $TEMP_DIR/$PLAYLIST $WEBROOT/$PLAYLIST)

if [ "$cmpresult" != "1" ]; then
	cp $TEMP_DIR/$PLAYLIST $WEBROOT/$PLAYLIST
fi

# generate index.html
# Currently we only display the streaming symbol if we oggvorbis is selected - cause sighttpd has issues with mp3s (on our platform at least)
if [ "$usesighttpd" == "TRUE" ]; then
      if [ "$encoder" == "oggvorbis" ]; then
	./busybox sed "s/IPADDR/$ipaddr/g" $WEBROOT/index_sighttpd.template > $TEMP_DIR/$INDEXFILEPRE
      else
	./busybox sed "s/IPADDR/$ipaddr/g" $WEBROOT/index.template > $TEMP_DIR/$INDEXFILEPRE 
      fi
else 
	./busybox sed "s/IPADDR/$ipaddr/g" $WEBROOT/index.template > $TEMP_DIR/$INDEXFILEPRE
fi
if [ "$encoder" == "mp3" ]; then
	
	./busybox sed "s/stream.ogg/stream.mp3/g" $TEMP_DIR/$INDEXFILEPRE > $TEMP_DIR/$INDEXFILE
else
	cp $TEMP_DIR/$INDEXFILEPRE $TEMP_DIR/$INDEXFILE

fi

# ... and copy if it differs from the previous version
cmpresult=$($FILECMP $TEMP_DIR/$INDEXFILE $WEBROOT/$INDEXFILE)

if [ "$cmpresult" != "1" ]; then
	cp $TEMP_DIR/$INDEXFILE $WEBROOT/$INDEXFILE
fi


# Currently we only start sighttpd if we oggvorbis is selected - cause sighttpd has issues with mp3s (on our platform at least)
if [ "$usesighttpd" == "TRUE" ]; then
       if [ "$encoder" == "oggvorbis" ]; then
	./oggs_app | ./sighttpd -f /etc/sighttpd.conf 2> /var/log/sighttpd.log & 
       else 
	./oggs_app > /dev/null &
       fi
else 
	./oggs_app > /dev/null &
fi
echo 0 > /tmp/userleds