Aus ReelBox Maniacs
#!/bin/sh
/sbin/memsettings
mount -t proc proc /proc
IMAGEDIR="/etc/reel/images"
IMAGEPREFIX="Flash"
EMERGENCY=false
AVR_VERSION="-c 110"
# Clear key buffer
a=`reelfpctl1 -getkeystate`
if ! $EMERGENCY ; then
echo "asking if or not restore files"
/sbin/reelfpctl1 -showpnm $IMAGEDIR/emergency.pnm -setled 7 &
#clear buffer again
reelfpctl1 -getkeystate
while true; do
a=`reelfpctl1 -getkeystate`
case "$a" in
"04 00 "*)
#blue key=no
echo "Emergency canceled"
break
;;
"00 02 "*)
#red key=yes
EMERGENCY=true
echo "doing Emergency"
break
;;
"00 00 ")
#this is the code for "no key pressed"
usleep 100000;
;;
*)
# wrong key; do nothing
test -z "$a" || echo "$a pressed. ignoring"
usleep 100000;
;;
esac
done
fi
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}01.pnm -setled 1 &
if ! $EMERGENCY ; then
echo
echo "==> loading tffsa driver and mounting old /etc..."
insmod /lib/modules/`uname -r`/kernel/misc/tffs.ko
MP=/mnt/tffsa2
mount -t ramfs /dev/ram /mnt/ramfs
mount -t minix /dev/tffsa2 $MP
# >/dev/null 2>&1
mount -t ext2 /dev/tffsa2 $MP
# >/dev/null 2>&1
echo "==> Saving config files..."
for i in $MP/sysconfig $MP/video/setup.conf $MP/video/timers.conf $MP/video/diseqc.conf $MP/video/svdrphosts.conf \
$MP/video/plugins/prefermenu.conf $MP/video/plugins/epgsearch.conf "$MP/video/channels*" ; do
cp -a $i /mnt/ramfs
done
umount $MP
rmmod tffs
sleep 1
fi
echo
echo "==> Formating DOC..."
/sbin/dformat -win:CA000 -y -nodos -s:/doc622.exb /first
sleep 3
insmod /lib/modules/`uname -r`/kernel/misc/tffs.ko
echo
echo "==> Partitioning Disk-on-Chip..."
(printf "n\np\n1\n\n+2M\nn\np\n2\n\n+5M\nn\np\n3\n\n\nw\n" | fdisk /dev/tffsa) >/dev/null 2>&1
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}02.pnm -setled 2
echo
echo "==> Installing MBR..."
#install-mbr /dev/tffsa
# stupid lilo wants to backup mbr :( . We save it to /dev/null :-D
/sbin/lilo -M /dev/tffsa -s /dev/null
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}03.pnm -setled 4 &
echo
echo "==> Copying Image to Disk-on-Chip..."
mount -t iso9660 /dev/hda /mnt/hda >/dev/null 2>&1
dd if=/mnt/hda/docimage of=/dev/tffsa3
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}04.pnm -setled 2 &
echo
echo "==> Preparing /boot partition..."
mkfs.minix -v /dev/tffsa1 >/dev/null 2>&1
mount -t minix /dev/tffsa1 /mnt/tffsa1 >/dev/null 2>&1
cp -a /mnt/hda/boot/* /mnt/tffsa1 >/dev/null 2>&1
umount /dev/tffsa1
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}05.pnm -setled 1 &
echo
echo "==> Preparing /etc partition..."
mkfs.minix -v /dev/tffsa2
mount -t minix /dev/tffsa2 /mnt/tffsa2 >/dev/null 2>&1
#mount -t cramfs /dev/tffsa3 /mnt/tffsa3 >/dev/null 2>&1
cp -a /mnt/hda/etc/* /mnt/tffsa2
#>/dev/null 2>&1
if ! $EMERGENCY ; then
MP=/mnt/ramfs
cp -a $MP/sysconfig /mnt/tffsa2
cp -a $MP/prefermenu.conf /mnt/tffsa2/video/plugins/
cp -a $MP/epgsearch.conf /mnt/tffsa2/video/plugins/
for i in $MP/setup.conf $MP/timers.conf $MP/diseqc.conf $MP/svdrphosts.conf "$MP/channels*" ; do
cp -a $i /mnt/tffsa2/video
done
fi
chmod -R u+w /mnt/tffsa2 2>/dev/null
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}06.pnm -setled 2 &
echo
echo "==> Installing LILO..."
mount /dev/tffsa1 /boot
lilo
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}07.pnm -setled 4
echo
echo "==> Flashing Frontpanel..."
cd /
if $EMERGENCY ; then AVR_VERSION="" ; fi
MP=/mnt/ramfs
cp -a $MP/sysconfig /mnt/tffsa2
cp -a $MP/prefermenu.conf /mnt/tffsa2/video/plugins/
cp -a $MP/epgsearch.conf /mnt/tffsa2/video/plugins/
for i in $MP/setup.conf $MP/timers.conf $MP/diseqc.conf $MP/svdrphosts.conf "$MP/channels*" ; do
cp -a $i /mnt/tffsa2/video
done
fi
chmod -R u+w /mnt/tffsa2 2>/dev/null
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}06.pnm -setled 2 &
echo
echo "==> Installing LILO..."
mount /dev/tffsa1 /boot
lilo
/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}07.pnm -setled 4
echo
echo "==> Flashing Frontpanel..."
cd /
if $EMERGENCY ; then AVR_VERSION="" ; fi
/sbin/avr_flasher $AVR_VERSION -w /main.flash
sync
umount /dev/hda
#/sbin/reelfpctl1 -clearled 7 -showpnm $IMAGEDIR/${IMAGEPREFIX}08.pnm -setled 2
#
#echo
#echo "==> Flashing Realtek 8139"
#cd /sbin
#rtl_prog -c -M 8139c.hex
/sbin/reelfpctl1 -showpnm $IMAGEDIR/${IMAGEPREFIX}09.pnm -setled 7 &
echo
echo "==> Done, rebooting..."
echo "press <CTRL>+C within 2 sec. to cancel reboot"
eject -p /dev/hda
/sbin/reelfpctl1 -clearled 7
sleep 3
sync
umount -a
reboot