PDA

View Full Version : I think HDD has died



wbeasley
18-09-2007, 02:51 PM
Well, has been freezing daily lately with pixels on screen, used to happen every few months.
Last night It gave an error message on reboot about possible corrupt HDD when starting to populate cache...so figured ahhh lets reimage

Reimged over old possible corrupt hard drive and got different error message when trying to detect cachecard...possible similar

Brought new 320GB HD today , imaged (aug TWP latest image), now on bootup is just says "please wait for TIVO....message"
(Edit This was because drive was cable select...)

I did notice when I copied image to HDD that some errors came up, possible corrupt image?? Next step will be to reimage after Dinner but any thoughts would be appreciated

cheers

wbeasley
18-09-2007, 05:34 PM
Is it normal to get some crc errors when coping image at the start? I guess not but ijhave a brand new 320GB Hitachi HD, seems a coincidence both old drive and new drive get the same errors?

when I boot tivo the cachecard drivers do not load, is there something different in this image? May try the earlier image instead

wbeasley
18-09-2007, 07:03 PM
Well, decided to keep persevering and the cachecard driver does not load however network is working and guide data has downloaded, i'm going to let tivo do it's thing and see if it's stable or not.

I remember the same driver issue on an old image and when i reimaged last year the cachecard worked for the first time ever

Darren King
18-09-2007, 07:27 PM
Download the CD bootable version of Seatools from www.seagate.com and run a full scan on the suspect hard disk. This program will work even if the hard disk is not a Seagate brand.

All the symptoms you have mentioned are caused by a dying hard disk. The average lifespan of a TiVo hard disk is around 30 months or so and given the hard disk is always in use (even when you are not recording or watching anything) this is a good lifespan.

Sorry can't help with the cachecard issue.

petestrash
18-09-2007, 11:46 PM
I suggest you run the seatools program Darren suggested on your new drive also. CRC errors are not normal.

I don't use the NZ image, but I recall a similiar issue in an OzTiVo version a while ago. Post a copy of your rc.sysinit file and I'll take a look.

Peter.

NZMarke
20-09-2007, 01:51 PM
I had very similar symptoms to this (also with a Seagate). I used the Seagate utility to check it, and it reported no problems. So I replaced the disk again. Same issues showed up. I then replaced the disk completely with a brand new (and larger) model, and it's worked flawlessly since. As has the old "faulty" disk - which I put into an old desktop for my wife (grin) as a secondary drive - so go figure.

My theory - for what it's worth - is that for the price of a new disk, it's not worth hassling about with checking the old one, finding no errors and replacing/reimaging only to find the same old problems reoccur when it's reinstalled on the TiVo. Better off to just bite the bullet and put a new disk in. The advantage is that you can put a bigger one in!! ;-)

Cheers

Mark

NZMarke
20-09-2007, 01:53 PM
And realised you have two discs - one old, one new. So have you tried just running the newer one - in case errors on one are causing the problem on both?

wbeasley
20-09-2007, 06:16 PM
Thanks for the replies

The new disk has been stable since I got it working, unsure what the crc errors were when I was copying the image accross...

The cachecard driver is still not working, doesn't load, some buffer type errors (sorry going from memory) also populates message something like not being able to access the kernel. Had these same errors on the origional image i used a few years back.

Thanks petestrash, I Will post rc.sysinit when i get a chance over the weekend

petestrash
20-09-2007, 09:02 PM
Chances are the previous image you used was an OzTiVo one, as I believe this is the first NZ image release.

Peter.

wbeasley
03-10-2007, 02:37 PM
#!/bin/bash
# Copyright (c) 2001, 2002 TiVo Inc.
#
# /etc/rc.d/rc.sysinit - run once at boot time
#

#
# Useful functions
#

function nthword () {
n=0
for foo in $* ; do
if [ $n -eq $1 ]
then
echo $foo
fi
n=$(($n+1))
done
}

function runme () {
echo "Scanning for $1 repair scripts"
for foo in /var/persist/*.$1 ; do
if [ -f $foo ]
then
echo "Running repair program $foo"
rm -f $foo.old
mv $foo $foo.old
chmod 555 $foo.old
if /tvbin/crypto -vfs $foo.sig $foo.old /tvlib/misc/service-v3-s.pub ; then
$foo.old || echo "$foo failed."
else
echo "$foo failed signature check."
fi
rm -f $foo.old $foo.sig
fi
done
}

function fixmodem
{
typeset MAXTRIES=3

typeset MODEMTYPE=/tvlib/modem/utils/modemtype.expect

if test ! -r $MODEMTYPE ; then
echo "fixmodem: no modem id program: $MODEMTYPE"
return
fi

typeset modem_name=$(/bin/expect $MODEMTYPE)

if test -z "$modem_name" ; then
echo "fixmodem: no modem name"
return
fi

typeset PATCHER=/tvlib/modem/patches/$modem_name/ram/expect_script

if test ! -r $PATCHER ; then
echo "fixmodem: no patcher: $PATCHER"
return
fi

#
# There is a patcher.
# Let's see how many times we have tried to use it.
# The file is supposed to consist of a single line; the number
# of characters on that line is the number of tries so far.
#
typeset FLAGFILE=/var/persist/modem_patch_tries

#
# The FLAGFILE must be a regular file, and it must be readable and writable.
# Otherwise, the file is created from scratch.
#
test -f $FLAGFILE -a -r $FLAGFILE -a -w $FLAGFILE ||
{
rm -rf $FLAGFILE
echo 'X' > $FLAGFILE
}

echo "Attempting to fix modem using: $PATCHER"

/bin/expect $PATCHER

typeset result=$?

if test $result -ne 0 ; then
typeset line tries

read line < $FLAGFILE
tries=${#line}

if test $tries -lt $MAXTRIES ; then
echo "Failed to fix modem; this was try #$tries"
line="${line}X"
echo $line > $FLAGFILE

#
# Verify that the file size has actually changed
#
typeset new_line

read new_line < $FLAGFILE
if test "$new_line" = "$line" ; then
sync
sync
sync
echo "Rebooting system to attempt another modem patch"
reboot
fi
echo "Failed to increase try count (file system full ?)"
else
echo "Too many unsuccessful tries to patch modem: $tries (giving up)"
fi
fi

#
# Eliminate the FLAGFILE, so that next time we reboot, we start
# the whole patch process again.
#
rm -f $FLAGFILE
}

# Pull in arch-specific bits
source /etc/rc.d/rc.arch

# Set the path
PATH=/devbin:/bin:/sbin:/tvbin:/hack/bin
export PATH

# Read in our testing configuration, if there is one.
[ ! -f /test.conf ] || source /test.conf

# Some tcl scripts expect TIVO_ROOT to be set. It would be cleaner to
# just use the path, but that's not the way it is right now. The
# contents of TIVO_ROOT is prepended to paths, so the empty string is
# just fine.
TIVO_ROOT=
export TIVO_ROOT

if [ "$sysgen" = true ]; then
echo
echo
echo Starting shared library installation environment
echo You may Telnet in. The telnet connection
echo will run bash as the login shell.
echo

configEtherSysinit

echo Starting Telnet Listner ... >& /dev/console
/sbin/tnlited 23 /bin/bash >& /dev/console

echo Starting /proc Listener ... >& /dev/console
mount -n /proc /proc -t proc >& /dev/console
procd >& /dev/console

exit
fi

echo "Starting rc.sysinit"

# Release the old initrd
echo "Releasing /initrd and clearing ramdisk, if they exist"
umount -n /initrd
freeramdisk /dev/ram

# Start up swapping.
echo "Activating swap partitions"
swapon -a

echo "Loading i2c driver"
insmod /lib/modules/i2c.o

echo "Loading core system drivers"
loadCoreAndSetTV_STD

loadIRDriver

# This should be read from /etc/fstab... or a config file somewhere.
export varpartition=/dev/hda9
if pdisk -l /dev/hda |grep "Bootstrap 1" |grep 128.0M ; then
echo "Partition 2 is 128MB. It must be the hack partition"
export hackpartition=/dev/hda2
else
echo "Partition 2 is not 128MB. The hack partition must be 4 or 7"
echo "Checking for root partition"
if [ "$root" == "/dev/hda4" ] ; then
echo "Hack is on partition 7"
export hackpartition=/dev/hda7
else
echo "Hack is on partition 4"
export hackpartition=/dev/hda4
fi
fi

# Check for panic signal
echo "Checking for Kickstart panic signal"

checkpanic

panic=$?
export EMERGENCY_REINSTALL=0
do_mfs_assert=0
do_mfs_cleanup=0

if [ $panic -ne 0 ] ; then
case $panic in
169)
echo "Kickstart code 5 2 - emergency reinstall"
export EMERGENCY_REINSTALL=1
;;
173)
echo "Kickstart code 5 6 - software install"
export swupgrade=true
;;
174)
echo "Kickstart code 5 7 - force MFS check"
do_mfs_assert=1
;;
175)
echo "Kickstart code 5 8 - perform MFS cleanup"
do_mfs_cleanup=1
;;
*)
kickstart $panic
reboot
;;
esac
fi

echo "Loading input section drivers"
loadInput

echo "Cleanup $varpartition pass 1"
if e2fsck -p $varpartition ; then
echo "$varpartition is clean"
else
echo "Cleanup $varpartition pass 2"
if e2fsck -p $varpartition ; then
echo "$varpartition is clean after pass 2"
else
echo "Can't clean $varpartition - rebuilding"
mke2fs -c $varpartition
echo "Mounting /var to rebuild it"
mount -t ext2 -n $varpartition /var
mkdir /var/log /var/tmp /var/run /var/packages /var/dev /var/bin /var/utils /var/persist
touch /var/timestamp
ln -s /hack /var/hack
umount -n /var
fi
fi

echo "Cleanup $hackpartition pass 1"
if e2fsck -p $hackpartition ; then
echo "$hackpartition is clean"
else
echo "Cleanup $hackpartition pass 2"
if e2fsck -p $hackpartition ; then
echo "$hackpartition is clean after pass 2"
else
echo "Can't clean $hackpartition - Pull the drive and run e2fsck manually."
fi
fi

# If this is an NFS root, we may want to allow for /var to stay in root
mount -v -n /var

### DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU ARE DOING.
mount -t ext2 $hackpartition /hack

echo "Cleaning up /var/mtab..."
cp /dev/null /var/mtab

# Set the TIVO_SVR_ADDR up.
if [ ! "$xTIVO_SVR_ADDR" = "" ]; then
echo "Changing SVR ADDR to $xTIVO_SVR_ADDR"
export TIVO_SVR_ADDR=$xTIVO_SVR_ADDR
else
echo "Using default TIVO_SVR_ADDR"
export TIVO_SVR_ADDR=192.168.50.1:80
fi

wbeasley
03-10-2007, 02:37 PM
echo "Mounting initial environment..."
mount -f /
mount -f /var
mount /proc /proc -t proc

echo "Cleaning up temporary files in /var/tmp"
rm -rf /var/tmp
mkdir /var/tmp

for dir in /var/log /var/run /var/packages /var/utils /var/persist /var/dev ; do
if [ ! -d $dir ] ; then
rm -rf $dir
mkdir $dir
fi
done

echo "Cleaning up old slices and bundles in /var/packages..."

rm -f /var/packages/*slice
rm -f /var/packages/*bnd
rm -f /var/packages/*jpm
rm -f /var/packages/*cpio
rm -f /var/packages/*gz

echo "Checking space in /var"

dfspace=$(df -P /var)

purge=0

if [ ! -z "$dfspace" ]; then
spacepct=$(nthword 12 $dfspace)
if [ ! -z "$spacepct" ]; then
spaceused=${spacepct%'%'}
if [ ! -z "$spaceused" ]; then
if [ $spaceused -gt 40 ]; then
purge=1
fi
fi
fi
fi


old_log_cleanup=0
too_big_logs=""
if [ $purge -ne 0 ]; then
echo "/var partition is rather full..."
du -s /var
echo "Removing old logs..."
rm -f /var/log/O*
old_log_cleanup=1
for foo in /var/log/* ; do
filesize=$(du -s "$foo")
if [ ! -z "$filesize" ]; then
kbytes=$(nthword 1 $filesize)
if [ ! -z "$kbytes" ]; then
if [ $kbytes -gt 10000 ]; then
echo "$foo is too big, removing it"
too_big_logs="$too_big_logs $foo"
rm -f "$foo"
fi
fi
fi
done
echo "Performed an emergency /var cleanup" >> /var/log/messages
fi

fixmodem

# Run the Phase 1 (/var is mounted and has some free space) scripts
runme phase1

echo "Initializing TiVo extension..."
# TODO: tivosetup ??? what does this do in tivosh?

echo "Set up environment vars for hardware configuration..."

# Need a way to override these...
# Should just source /etc/tivoconfig/hardware... It should set these up...
if [ "$TIVO_REMOTE" = "" ]; then export TIVO_REMOTE=TIVO; fi
echo "Remote control is " $TIVO_REMOTE

if [ "$MFS_DEVICE" = "" ]; then export MFS_DEVICE=/dev/hda10; fi
echo "MFS partition on " $MFS_DEVICE

echo "Loading media drivers..."

if [ "$runideturbo" = false ]; then
echo "Running without ideturbo mode ..."
else
echo "Loading ideturbo ..."
insmod /lib/modules/ideturbo.o
fi

if [ "$LOG5505TOSERIAL" = true ]; then
echo "installing oslink.o"
insmod /lib/modules/oslink.o

echo "Waiting for response on DSS serial port"
/bin/expect /etc/boot.expect > /dev/ttyDSS < /dev/ttyDSS

if [ ! $? = 0 ]; then
jeiboot=true
else
echo "Booting from oslink..." > /dev/ttyDSS
fi
fi

asicversion=`/bin/asicVersion`
if [[ "$oslink" = false || "$jeiboot" = true ]]; then
echo "Not going to boot over oslink ..."
case $asicversion in
0|1)
irmicrofile='/sbin/irmicro.hex'
;;
2|3|4|5)
irmicrofile='/sbin/irbmicro.hex'
;;
esac
else
echo "Auto-detecting oslink module (asic $asicversion)."
getTunerConfig

case $asicversion in
0|1)
echo "Not Installing oslink module."
irmicrofile='/sbin/irmicro.hex'
;;
2|3)
echo "Installing oslink module (tuner $tuner1)"
irmicrofile='/sbin/irbmicro.hex'
insmod /lib/modules/oslink.o
cat $tunerboot1 > /dev/oslink
;;
4)
echo "Installing both oslink (tuners $tuner1:$tuner2)"
irmicrofile='/sbin/irbmicro.hex'
insmod /lib/modules/oslink.o
cat $tunerboot1 > /dev/oslink
cat $tunerboot2 > /dev/oslink2
;;
5)
echo "Not Installing oslink module."
irmicrofile='/sbin/irbmicro.hex'
;;
esac
fi

echo "Loading fan ..."
insmod /lib/modules/fan.o

echo "Loading therm ..."
insmod /lib/modules/therm.o

echo "Loading output section drivers ..."
loadAllOutput

echo "Splash the screen..."
osdwriter /tvbin/PromScreen2Version7.$TV_STD.png

if [ -f /etc/cachecard ] ; then
insmod -f /lib/modules/cachecard.o
cachectl -t
osdwriter /tvbin/PromScreen2Version7.$TV_STD.png
fi

echo "Update IR microcode using $irmicrofile"
irprog -f $irmicrofile

# Figure out the system serial number. (On combo box,
# this is called the TiVo Service ID.)
SysSerial=`crypto -gsn`
if [ $? -ne 0 ]; then SysSerial=""; fi
if [ -z $SysSerial ]; then SysSerial=`driveid /dev/hda`; fi
if [ -z $SysSerial ]; then SysSerial=000000000000000; fi
export SerialNumber=$SysSerial
export HDA_ID=`/bin/driveid /dev/hda`
export HDB_ID=`/bin/driveid /dev/hdb`
export OzTiVoVersion=`cat /etc/oztivo_version`


# On combo box, determine the IRD Serial Number (which is
# dependent on the exported SerialNumber environment variable).
IrdSerial=`irdSerialNumber`
export IrdSerialNumber=$IrdSerial

#
# Export the prom version information
#
export PROMVERSION=`getprom -version`

if [ -f /sbin/update ] ; then
# ??? Does this really add value?
echo "Starting update ..."
/sbin/update
fi

echo "Look for debug board ..."
export DEBUG_BOARD=false

if checkEther ; then
PATH=/bin:/sbin:/tvbin:/devbin
export PATH
echo "Starting network ..."
configGateway

export TMK_DEBUGGER=sleep
export DEBUG_BOARD=true
echo "Starting Telnet Listener..."
if [ -x /bin/bash ] ; then
tnlited 23 -r 9911 /bin/bash -login &
else
export TIVOSH_POOLSIZE=800000
tnlited 23 -r 9911 /tvbin/tivosh -login &
fi

echo "Starting /proc Listener..."
procd
fi

echo "Enabling local route..."
ifconfig lo 127.0.0.1 up

echo "Setting TCP keepalive parameters..."

if [ -e /proc/sys/net/ipv4/tcp_keepalive_time ]; then
echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time
fi

if [ -e /proc/sys/net/ipv4/tcp_keepalive_probes ]; then
echo 3 > /proc/sys/net/ipv4/tcp_keepalive_probes
fi

if [ "$runsyslog" = false ]; then
echo "No logging daemons started..."
else
echo "Starting logging daemons..."
rm -f /var/run/syslogd.pid /var/run/klogd.pid
syslogd -p /var/dev/log -m 10000
klogd
fi

echo "Check for PROM update ..."
if [ "$updateprom" = true ]; then
if [ -e /prom/TiVoProm.bin ]; then
osdwriter /tvbin/InstallingSoftware.$TV_STD.png
getprom -Update /prom/TiVoProm.bin
echo "Sleep...waiting for reboot"
osdwriter /tvbin/PromScreen2Version7.$TV_STD.png
sleep 1000000
restart
fi
echo "Can't find PROM image"
fi


echo "Updating system clock UID=$UID"
settime -rtc

# If the clock is set to before 1970, ntpdate won't work. So we will
# bump it up closer. The factory default seems to be 1910.
year=`date +%Y`

if [ $year -lt 1998 ] ; then
settime 199811241010
settime -rtc
fi

#
# Log into the moderated log any emergency cleanup deletions we
# did. We need the TCD_ID, TIME and CALL_ID for this
#
if [ -e /var/persist/lastCallId ] ; then
lastCallId=`cat /var/persist/lastCallId`
else
lastCallId="UNKNOWN"
fi
now=`date '+%s'`

if [ $old_log_cleanup -ne 0 ]; then
echo "emergency_cleanup TCD_ID=$SerialNumber TIME=$now CALL_ID=$lastCallId FILE=/var/log/O" >> /var/log/svclog
fi

for logf in $too_big_logs ; do
echo "emergency_cleanup TCD_ID=$SerialNumber TIME=$now CALL_ID=$lastCallId FILE=$logf" >> /var/log/svclog
done

unset DYNAMIC_NET_DEV
if [ -f /etc/rc.d/rc.net ]
then
echo "Configuring network..."
source /etc/rc.d/rc.net
fi
### Start oztivo networking hacks #####

setpri fifo 1 $PPID
setpri fifo 1 $$

. /etc/oztivo.conf

if [ "$pppondss" == "true" ] || [ "$pppondss" == "1" ]
then
echo "Starting PPP over serial"
/etc/rc.d/rc.ppp &
export DYNAMIC_NET_DEV=ppp0
else
echo "Starting BASH on serial port"
shondss.sh &
fi


## We don't do this anymore, since networking is setup via installer iso
##if [ -f /etc/rc.d/rc.net.${netcard} ]
##then
## echo "Configuring network...for ${netcard}"
## source /etc/rc.d/rc.net.${netcard}
##fi

wbeasley
03-10-2007, 02:38 PM
## via boot params or /etc/oztivo.conf
## If TiVo doesn't find eth0, then it tries to find a ppp server
#if `cat /proc/net/dev |grep eth0` ; then
# NETCARDIP=`ifconfig eth0|grep "inet addr" |cut -d: -f2|cut -d' ' -f1`
# if [ $NETCARDIP == "0.0.0.0" ]
# then
# echo "$netcard driver loaded but no DHCP server found"
# kill -9 `cat /var/run/dhclient.pid`
# ifconfig eth0 down
# unset DYNAMIC_NET_DEV
# else
# echo IP for $netcard is $NETCARDIP
# fi
#else
#echo "No Network Card Present"
#fi
## If TiVo doesn't find eth0, then it tries to find a ppp server
#if [ "$DYNAMIC_NET_DEV" == "" ]
#then
# echo "Trying PPP over serial"
# /etc/rc.d/rc.ppp &
# export DYNAMIC_NET_DEV=ppp0
#fi


#Start the telnet server listener
tnlited.sh &

### End oztivo networking hacks #####
# Add second disk if there and uninitialized. No, we didn't take this out...
echo "Checking for additional disk..."
mfsadd

if [ $do_mfs_cleanup -eq 1 ] ; then
echo "Initiating MFS cleanup"
/tvbin/fsfix -nokill -splash -uncollide -rehash -salvage -reboot
fi

# Start the EventSwitcher and MfsDaemon
echo "Starting EventSwitcher..."
/tvbin/switcherstart -m

if [ $do_mfs_assert -eq 1 ] ; then
echo "Rebooting to perform MFS and database check"
/tvbin/mfsassert -please
/tvbin/reboot
fi

# Start the fan control process.
echo "Start fan control..."
fancontrol &

# Let him get started ??
sleep 1

# Run the Phase 2 (MFS is up) scripts
runme phase2


# Check for Diagnostics.
dodiag=false
case $asicversion in
2|3|4)
# this is ppc combo :

# The authserial program detects the presence of a diagnostics test fixture.
if [ ! -x /tvbin/genkey ] ; then
echo "Essential diagnostic file missing"
/tvbin/reboot
fi

/tvbin/genkey 128 1 > /var/tmp/challenge.dat

if [ "$runfactorydiag" = true ] ; then
if [ ! -x /diag/tvbin/authserial -o \
! -r /diag/tvlib/misc/diagkey.pub ] ; then
echo "Essential diagnostic file missing"
/tvbin/reboot
fi
dodiag=true
# the "runfactorydiag" bootparam indicates that we are in the factory
# with a brand new disk. Don't quit until we've established link
# with diag station
while ! /diag/tvbin/authserial -authslave /diag/tvlib/misc/diagkey.pub /var/tmp/challenge.dat ; do
echo Diagnostics station not found, trying again
sleep 1
done
else
if [ ! -x /diag/tvbin/authserial -o \
! -r /diag/tvlib/misc/diagkey.pub ] ; then
echo "Can not check for Test Master"
else
# Check whether we should enter diagnostics
# The authserial program detects the presence of a diagnostics test fixture.
if /diag/tvbin/authserial -authslave /diag/tvlib/misc/diagkey.pub /var/tmp/challenge.dat ; then
echo Diagnostics station present and authenticated
dodiag=true
fi
fi
fi

rm -f /var/tmp/challenge.dat
;;

0|1|5)
# this is ppc or mips standalone.
if [ "$runfactorydiag" = true ] ; then
dodiag=true
# we will just enter diagnostics
echo "Standalone diagnostics"
fi
;;
esac


# Run factory diagnostics?
if [ "$dodiag" = true ] ; then
if [ ! -x /diag/tvbin/factorydiag ] ; then
echo "No factorydiag TCL script!"
else
echo Entering diagnostics...
if /diag/tvbin/factorydiag ; then
echo "Diagnostics passed"
else
echo "Error running factory diagnostics"
reboot
fi
fi
fi

# Run the final test?
if [ "$runfinaltest" = true ] ; then
if [ -x /var/diag/finaltest ] ; then
if /tvbin/crypto -vfs /var/diag/finaltest.sig /var/diag/finaltest /tvlib/misc/service-v3-s.pub ; then
/var/diag/finaltest
else
echo "/var/diag/finaltest failed signature check."
reboot
fi
elif [ -x /diag/finaltest ] ; then
/diag/finaltest
else
echo "Final test not found!"
fi
fi

# see if we need to check the battery
if [ -f /var/log/battery-check-needed ] ; then
if [ -x /var/diag/batterycheck ] ; then
if /tvbin/crypto -vfs /var/diag/batterycheck.sig /var/diag/batterycheck /tvlib/misc/service-v3-s.pub ; then
/var/diag/batterycheck
else
echo "/var/diag/batterycheck failed signature check."
reboot
fi
elif [ -x /diag/batterycheck ] ; then
/diag/batterycheck
else
echo "Battery check not found!"
fi
fi

# combo diagnostics testmaster starts here
if [ "$testmaster" = true ]; then
if [ -f /etc/rc.d/rc.sysinit.diag ]; then
echo "Starting Diagnostic Test Master"
source /etc/rc.d/rc.sysinit.diag
else
echo "rc.sysinit.diag not found"
fi
fi

# Check for software upgrade
if [ "$swupgrade" = true ]; then
/tvlib/tcl/updateSoftware.tcl
fi

if [ "$runwriteback" = true ]; then
/diag/writeback /dev/hda11 256 -a2 &
/diag/writeback /dev/hdb3 256 -a2 &
while true; do sleep 1000; done
fi

if [ "$rundriverstress" = true ]; then
if [ -x /diag/SimpleStress ]; then
echo "Running SimpleStress"
/diag/SimpleStress
echo "SimpleStress exited"
reboot
fi
fi

if [ "$testmodemDSS" = true ]; then
echo "Connecting modem to DSS serial port, 115K baud"
/tvbin/modemtest -forward /dev/ttyDSS
handcraft=true
fi

# System Statistics to "messages" log file.
syslog -t Stats "== System startup resource statistics =="
syslog -t Stats "++ System build version numbers ++"
syslog -t Stats -f /etc/build-version
getprom -version | syslog -t Stats
echo `getprom -checksum` | syslog -t Stats
IRvers=`irtest -t /dev/ttyS0 -V`
syslog -t Stats "IR version $IRvers"
syslog -t Stats "System Serial Number: $SysSerial"
syslog -t Stats -f /proc/version
syslog -t Stats "++ Memory usage ++"
syslog -t Stats -f /proc/meminfo
syslog -t Stats "++ CPU info ++"
syslog -t Stats -f /proc/cpuinfo
syslog -t Stats "++ Module info ++"
syslog -t Stats -f /proc/modules
syslog -t Stats "++ Device info ++"
syslog -t Stats -f /proc/devices
syslog -t Stats "++ Network device info ++"
syslog -t Stats -f /proc/net/dev

# Database conversions must happen before myworld, mcp, etc. are started.
if [ "$handcraft" != true ]; then
echo "Checking for database conversions..."
convert-db
fi

if [ "$upgradesoftware" = false ]; then
echo "Not upgrading software"
else
# TODO... Find another way to do this...
tivosh /etc/rc.d/finishInstall.tcl
export -n EMERGENCY_REINSTALL
fi

# Run the Phase 3 (MyWorld is starting) scripts
runme phase3

cd /var/tmp

# Launch MyWorld and other services (apg, mcp, tcphonehome, dbgc) by telling
# the eventswitcher to launch it (via "switcherstart -l").

if [ "$handcraft" = true ]; then
echo "Running without services."
else
echo "Starting Services."
switcherstart -l
fi

if [ "$audiostress" = true ]; then
echo "Starting audio stress"
if [ -x /devbin/audiostress ]; then
audiostress &
else
echo "Could not find audio stress prog"
fi
fi

if [ "$maintuner" = "1" ]; then
echo "Starting camtest for dual verifier mode"
camtest &
else
maintuner=0
fi

# Run the Phase 4 (background tasks have been started) scripts
runme phase4

if [ ! "$NDS" = "" ]; then
echo "Sleeping before enabling NDS sniffer output"
sleep 120
echo "Enabling NDS sniffer output"
/tvbin/send5505 "sniff 1"
fi

if [ ! "$BERR" = "" ]; then
echo "Sleeping before enabling Tuner BERR Test"
sleep 60
echo "Enabling Tuner BERR Test"
/tvbin/send5505 "wr299 28 40"
/tvbin/send5505 -i1 "wr299 28 40"
fi

if [ ! "$vmstat" = "" ]; then
echo "Starting memory statistic gathering"
vmstat 10 &
fi


# Set a few useful things up to use Service Emulator instead of TiVo mothership
# Set the DialConfig to use our mothership emulator
#DialConfig127.tcl
dbsetx /State/PhoneConfig DialConfig 127

# This will make TiVo try a daily call over the network or modem depending on
# the setting in /etc/oztivo.conf.
if [ "$modem" = "1" ] ; then
dbrm /State/PhoneConfig DialPrefix
# This will make the modem behave better in Oz
dbsetx /State/PhoneConfig DialToneCheck 0
#dbsetx /State/PhoneConfig CallWaitingPrefix *44 # #87 for Optus and *11*3# for faxtream duet
#dbsetx /State/PhoneConfig TollFreeNum 99990000
#dbsetx /State/PhoneConfig DialInNum 99990000
else
dbsetx /State/PhoneConfig DialPrefix ',#401'
fi

# We tell TiVo we are in UTC
dbsetx /State/LocationConfig TimeZoneOld 7

# Tivo cannot handle all Daylight Savings Policies, especially those
# of the Southern Hemishphere. See /etc/postcodezones for for info on keeping time
dbsetx /State/LocationConfig DaylightSavingsPolicy 0

GSSTATE=`dbget /State/GeneralConfig Complete`
BOOTARGS=`bootpage -p /dev/hda`
NEWBOOTARGS=`echo $BOOTARGS |sed 's/GS=1/GS=0/g'`
#echo $NEWBOOTARGS
# Get rid of Guided Setup Hack on next reboot if is complete,
# or it will cause the "jitters"
if [ "$GSSTATE" = "7" ] || [ "$GSSTATE" = "6" ] || [ "$GSSTATE" = "3" ] ; then
echo "Guided Setup at sufficient State. Clearing GS flag"
bootpage -P "$NEWBOOTARGS" /dev/hda
fi
# Check to see if this is UK tivo, and if so, enable scart
if [ $videoconfig = 7 ]; then
echo "UK box, enable SCART"
scartctl.tcl &
fi

# Enable both remotes
# OzTivos images should support both remotes out of the box.
# This should be done on the master image, but its here in case somebody
# starts from scratch and wants to do it this way instead.
# If you want your TiVo to obey only one...
# run /hack/bin/selectremote.tcl from a telnet or bash on serial session
#
# setbothremotes.tcl

[ ! -f /etc/rc.d/rc.sysinit.author ] || /etc/rc.d/rc.sysinit.author

echo "rc.sysinit is complete"