#!/bin/sh
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/lib:/usr/local/lib:/mnt/hdd0/media/tools/lib
export PATH=$PATH:/app/lib:/app/app
mount -t ramfs ramfs /mnt
mkdir /mnt/cramfs
mount -t ramfs ramfs /mnt/cramfs
cp -a /etc/* /mnt/cramfs/
mount -t ramfs ramfs /etc
cp -a /mnt/cramfs/* /etc/
umount /mnt/cramfs
mkdir /mnt/export
mount -t sysfs none /sys
mkdir /dev/raw
mknod /dev/raw/rawctl c 162 0
mknod /dev/raw/raw1 c 162 1
mknod /dev/raw/raw2 c 162 2
mknod /dev/recbuffer c 151 0
insmod /app/modules/sata_stm.ko
echo "start Barry Allen"
mkdir /tmp/badevice
mount /dev/sda5 /tmp/badevice
/tmp/badevice/baroot/ba/bainit > /tmp/ba.log
umount /tmp/badevice
rmdir /tmp/badevice
echo "end Barry Allen"
/usr/sbin/telnetd -l /bin/sh
echo `date "+%Y-%m-%d %H:%M:%S"` "Starting oscam tools" >> /tmp/oscam.log
( sleep 20;
echo `date "+%Y-%m-%d %H:%M:%S"` "Waiting for oscam tools to be mounted" >> /tmp/oscam.log;
while [ ! -f /mnt/hdd0/media/tools/start.sh ]; do
echo `date "+%Y-%m-%d %H:%M:%S"` "/mnt/hdd0/media/tools/start.sh MISSING" >> /tmp/oscam.log
sleep 1
done
echo `date "+%Y-%m-%d %H:%M:%S"` "/mnt/hdd0/media/tools/start.sh exists" >> /tmp/oscam.log
/mnt/hdd0/media/tools/start.sh > /tmp/media-tools-start.log 2>&1
echo `date "+%Y-%m-%d %H:%M:%S"` "Done with running the start script" >> /tmp/oscam.log
) &
echo `date "+%Y-%m-%d %H:%M:%S"` "Done with starting oscam tools" >> /tmp/oscam.log
/app/app/Launcher &
cp -a /app/app/Standby /tmp
/tmp/Standby