#!/bin/csh
#
#
echo '-----------------'
echo 'Checking Licenses'
echo '-----------------'
#
#
#
echo
#
echo "prepare proxies zone using standard p files"
#
#
# Just in case ... and YES it has happened ...
unalias cp
#
# First copy in *all* the *unlicensed* proxy images.
# Then, look for licenses. Wherever there is a valid license copy in
# the appropriate *licensed* proxy images on top.
cp -f /usr/local/SpeedSix/dl/proxies/b*-unlicensed/*.p /usr/discreet/sparks/SpeedSix_V5.0_64/. >& /dev/null

#
echo "-----"
echo "ready"
echo "-----"
echo
#
#
set product=(1to20 1to15 1to10 1to5 6to10 11to15 16to20 6to20 6to15 11to20)
@ s1 = 1
@ e1 = 10
echo "+++++++++++++++++++++"
echo " Checking All Bundles"
echo "+++++++++++++++++++++"
while ($s1 <= $e1 )
  /usr/local/SpeedSix/dl/bin/proxie-distribution-bundles_64.sh bundle$product[$s1] 5.0 discreet,inferno,flame,fire,smoke12,smoke8,flint12,flint8
  @ s1++
end
#
# now for the boxes
@ s1 = 1
@ e1 = 22
echo "+++++++++++++++++++"
echo " Checking All Boxes"
echo "+++++++++++++++++++"
while ($s1 <= $e1 )
  /usr/local/SpeedSix/dl/bin/checklicense box$s1 5.0 discreet,inferno,flame,fire,smoke12,smoke8,flint12,flint8 full
  if ( $status ) then
    cp -f /usr/local/SpeedSix/dl/proxies/b$s1-licensed/*.p /usr/discreet/sparks/SpeedSix_V5.0_64/. 
    echo "You have a license for box"$s1 
  else
    echo "No license for box"$s1 
  endif
  @ s1++
end
#
# check box 99 on its own
#
/usr/local/SpeedSix/dl/bin/checklicense box99 5.0 discreet,inferno,flame,fire,smoke12,smoke8,flint12,flint8 full
if ( $status ) then
  cp -f /usr/local/SpeedSix/dl/proxies/b99-licensed/*.p /usr/discreet/sparks/SpeedSix_V5.0_64/. 
    echo "You have a license for box99" 
else
  echo "No license for box99"
endif

# rename to be suitable for 64 bit
pushd /usr/discreet/sparks/SpeedSix_V5.0_64
foreach fred (*.spark.p)
  mv $fred `basename $fred \.p`_x86_64.p
end
popd
