#!/bin/sh

# CheckApp=true
CheckApp=false

# If booting, wait until rcS script finishes
tries=0
pidof rcS > /dev/null
while [ $? = 0 -a $tries -lt 60 ] ; do
    sleep 1
    tries=`expr $tries + 1`
    pidof rcS > /dev/null
done

uname -r | grep mipsisa32r2el > /dev/null 2>&1
if [ $? = 0 ] ; then
    PROD=qvpro
else
    exit 1
fi

REBOOT=false
FILE=/sbin/clean
if [ -f $FILE ] ; then
	cd /tmp
	sh $FILE > /dev/console 2>&1
	REBOOT=true
fi

[ $CheckApp = false ] && mv $0 $0.SysClean.sh

if [ $REBOOT = true ] ; then
    echo "Rebooting..." > /dev/console
    reboot
fi