#!/bin/sh
# 
if [ "$1" = "prereqs" ]; then
  exit 0
fi

quiet=n


. /scripts/functions
# if break=sqmount STOP here
maybe_break hdd


. /conf/tcos.conf
. /conf/tcos-run-functions




# check if we are booting from HD / USB
_INITRD=$(read_cmdline_var "initrd" "")
if [ "$_INITRD" = "initrd.gz" ]; then
   # booting from hdd, use usr.squashfs from HDD if exists
   mkdir -p /mnt/tmp

   for part in $(grep -e ext3 -e vfat /etc/fstab| awk '{print $1":"$3}'); do
     device=$(echo $part | awk -F":" '{print $1}')
     fs=$(echo $part | awk -F":" '{print $2}')
     mount -t${fs} ${device} /mnt/tmp

     if [ -f /mnt/tmp/usr.squashfs ]; then
       USR_SQUASH=/mnt/tmp/usr.squashfs
       _log "SQMOUNT found usr.squashfs in $device "
       break
     elif [ -f /mnt/tmp/usr-$(uname -r).squashfs ]; then
       USR_SQUASH=/mnt/tmp/usr-$(uname -r).squashfs
       _log "SQMOUNT found usr-$(uname -r).squashfs in $device "
       break
     else
       umount /mnt/tmp
     fi
   done
fi





##############################################


exit 0

