#!/bin/sh

### This file download EMU in tuner ####
#  creating iscan_adm for E2 ipbox900  #
#       http://ipbox900.com.ua         #
########################################

echo "WAIT" > /dev/dbox/fp0

siteurl=http://ipbox900.com.ua

server_folder=/var/server
config_box=/var/tuxbox
server_config=/var/tuxbox/config
newcs_bin=http://ipbox900.com.ua/setup/server/newcs
phoenix_xml=http://ipbox900.com.ua/setup/server/phoenix.xml
cam1_xml=http://ipbox900.com.ua/setup/server/cam1.xml
cam2_xml=http://ipbox900.com.ua/setup/server/cam2.xml
example=http://ipbox900.com.ua/setup/server/newcs.xml.example

if [ ! -e $server_folder ]; then
echo "creating folder /var/server"
echo "CREAT SERVER" > /dev/dbox/fp0
mkdir $server_folder
fi

if [ ! -e $config_box ]; then
echo "creating folder /var/tuxbox"
echo "CREAT TUXBOX" > /dev/dbox/fp0
mkdir $config_box
fi

if [ ! -e $server_config ]; then
echo "creating folder /var/tuxbox/config"
echo "CREAT CONFIG" > /dev/dbox/fp0
mkdir $server_config
fi

echo "UpGrade NewCs" > /dev/dbox/fp0
echo "BackUp Old" > /dev/dbox/fp0
cp -f $server_folder/newcs $server_folder/newcs-old
rm -f $server_folder/newcs

cd $server_folder
wget $newcs_bin
cd $server_config
wget $phoenix_xml
wget $cam1_xml
wget $cam2_xml
wget $example
chmod 777 $server_folder/newcs

echo "NEWCS UPDATED"
echo "Edit Setting in /var/tuxbox/config"
echo "NEWCS UPDATED" > /dev/dbox/fp0
