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
Bookmarks