#!/bin/sh
/bin/mount -a
cp -a /tmp_orig/* /tmp
cp -a /usr/local/etc/hdd.old /tmp/hdd
# From now on, we can use mount.rcS
grep -q "(" /proc/cmdline
if [ $? = 0 ]; then
/etc/init.d/mount.rcS
if [ $? = 1 ]; then mount /usr/local/etc; fi
else
mount /usr/local/etc
fi
# [ADF] Check mounted point
if [ "`more /etc/mtab | grep /usr/local/etc`" = "" ]; then
flash_eraseall /dev/mtd/2
usleep 500000
mount /usr/local/etc
fi
# [ADF 2010-08-02] Check yaffs... thanks to Locko, Jotabe and ... everyone
if [ ! -f /usr/local/etc/rcS ]; then
if [ -f /usr/local/bin/etc.tbz2 ]; then
# CRITICAL!!
tar -jxvf /usr/local/bin/etc.tbz2 -C /
fi
fi
BLOCK="`df | grep /usr/local/etc | cut -d ' ' -f 1 | cut -d '/' -f 4`"
if [ "Z$BLOCK" != "Z4" ] && [ "Z$BLOCK" != "Z3" ] && [ "Z$BLOCK" != "Z2" ] && [ "Z$BLOCK" != "Z1" ]; then
echo "[`date +\"%Y-%m-%d %H:%M\"`] ERROR: No device mounted" > /usr/local/etc/.recovered
else
ERASED="`more /proc/yaffs | grep Erased | tail -n 1 | cut -d ' ' -f 2`"
if [ -f /usr/local/etc/.format ]; then
rm -rf /usr/local/etc/.format
ERASED=0
fi
if [ $ERASED -le 100 ]; then
rm -rf /tmp/yaffs
mkdir /tmp/yaffs
rm -rf /usr/local/etc/dvdplayer/data/Software/
rm -rf /usr/local/etc/dvdplayer/data/Banners/
rm -rf /usr/local/etc/.format
cp -rpd /usr/local/etc/* /tmp/yaffs/
rm -rf /tmp/yaffs/lost+found
umount /usr/local/etc
flash_eraseall /dev/mtd/2
mount /dev/mtdblock/2 /usr/local/etc
cp -rpd /tmp/yaffs/* /usr/local/etc/
echo "[`date +\"%Y-%m-%d %H:%M\"`] OK: Recovered" > /usr/local/etc/.recovered
sync
umount /usr/local/etc
/sbin/reboot
fi
fi
grep -q SYSLOGDISK /sys/realtek_boards/system_parameters
if [ $? = 0 ]; then
/etc/init.d/syslog.rcS&
fi
#echo "Use Flash as root."&
#/bin/mkdir -p /var/lib/hotplug
#/bin/mkdir -p /var/log&
#ln -s /usr/local/firmware /var/lib/hotplug/&
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start&
;;
esac
done
# We need to direct standard output to /dev/console or the output of script rcS will disappear.
/usr/local/etc/rcS>/dev/console&
/bin/hostname -F /etc/hostname&
/sbin/ifconfig lo 127.0.0.1 up&
/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo&
#/bin/mkdir -p /tmp/usbmounts
#/bin/mkdir -p /var/lock/hotplug/convert_tmp
#/bin/mkdir -p /var/lock/hotplug/rename_tmp
#/bin/mkdir -p /var/lock/hotplug/mount_tmp
#mkdir -p /tmp/ramfs/volumes
#mkdir -p /tmp/ramfs/labels
#touch /var/lock/hotplug/volume_lock
#cp /etc/init.d/config /var/lock/hotplug/
#/bin/rm -rf /tmp/usbmounts/*&
#/bin/rm -rf /tmp/usbmounts/.*&
#/sbin/modprobe venus1394&
#/sbin/modprobe ehci-hcd
#/sbin/modprobe ohci-hcd
#/bin/touch /var/log/messages
# I donot know why syslog cannot work well with below parameters. Kernel problem or uClibc problem?
#/sbin/syslogd -p /tmp/.log -n -m 0&
#/sbin/klogd -n&
#/sbin/syslogd&
#/sbin/klogd&