#!/bin/sh
#calc free space in which to create/save files.

SIZEFREE=0
PUPMODE=2
[ -f /etc/rc.d/PUPMODE ] && PUPMODE=`cat /etc/rc.d/PUPMODE`

case $PUPMODE in
 3|7|13) #home partition/file mntd on pup_ro1, tmpfs on pup_rw
  SIZEFREE=`df -k | grep ' /initrd/pup_ro1$' | tr -s ' ' | cut -f 4 -d ' '`
  SIZETMP=`df -k | grep ' /initrd/pup_rw$' | tr -s ' ' | cut -f 4 -d ' '`
  [ $SIZETMP -lt $SIZEFREE ] && SIZEFREE=$SIZETMP
  ;;
 6|12) #home partition/file mntd on pup_rw (no tmpfs)
  SIZEFREE=`df -k | grep ' /initrd/pup_rw$' | tr -s ' ' | cut -f 4 -d ' '`
  ;;
 *)
  SIZEFREE=`df -k | grep ' /$' | tr -s ' ' | cut -f 4 -d ' '`
  ;;
esac

#exit $SIZEFREE
echo "$SIZEFREE"
###end###
