#! /bin/sh

if [ -f "/userfs/bin/tcapi" ];then
APPS_MOUNTED_PATH=`/userfs/bin/tcapi get Apps_Entry apps_mounted_path`
APPS_INSTALL_FOLDER=`/userfs/bin/tcapi get Apps_Entry apps_install_folder`
APPS_INSTALL_PATH=$APPS_MOUNTED_PATH/$APPS_INSTALL_FOLDER
else
APPS_MOUNTED_PATH=`nvram get apps_mounted_path`
APPS_INSTALL_FOLDER=`nvram get apps_install_folder`
APPS_INSTALL_PATH=$APPS_MOUNTED_PATH/$APPS_INSTALL_FOLDER
fi

mv -f /opt/tmp/bin/* $APPS_INSTALL_PATH/bin/
chmod -R 777 $APPS_INSTALL_PATH/bin
chmod -R 777 $APPS_INSTALL_PATH/lib

chmod -R 777 $APPS_INSTALL_PATH
rm -rf $APPS_INSTALL_PATH/etc/dm2_general*
chmod 777 $APPS_INSTALL_PATH/etc/init.d/S50downloadmaster
rm -rf $APPS_MOUNTED_PATH/Download2/config/settings.json
sync
echo 3 > /proc/sys/vm/drop_caches
