#!/system/bin/sh

busybox tcpsvd -vE 0 21 busybox ftpd -w / &


dataPath=/data/

while [ ! -d "$dataPath" ]
do
    sleep 1
done

if [ ! -f "$dataPath/copyIpDone" ]; then
    cp /system/etc/myip.conf /data/myip.conf
    chmod 777 /data/myip.conf
    touch $dataPath/copyIpDone
fi

bstPath=/mnt/runtime/default/emulated/0/

while [ ! -d "$bstPath" ]
do
    sleep 1
done

if [ ! -f "$bstPath/com_shbst_fujitec/copyDone" ]; then
    cp -r /system/voice $bstPath/com_shbst_fujitec
    touch $bstPath/com_shbst_fujitec/copyDone
fi

mount -o rw,remount /system
chmod 777 /system/bin/rtcSync
rtcSync &
mount -o ro,remount /system

while true
do
        if [ -f "/data/uptscript/upgrade.sh" ]; then
                echo "run upgrade.sh"
                chmod 777 /data/uptscript/upgrade.sh
                /data/uptscript/upgrade.sh

                sleep 1
                echo "remove upgrade.sh"
                rm /data/uptscript/upgrade.sh
        fi
        sleep 10
done
