#!/bin/csh -f

# create the links needed to expose a specific catalog to the distribution server

# general locations
set wwwroot = /export/ippc11.0/www/dvodist/www-root
set catroot = /data/stsci19.2/eugene/addstar.20141016/lap.pv2.20141215

set catdir = lap.pv2.20141215
set cattgt = $wwwroot/$catdir

set nlist = (n0000 n0730 n1500 n2230 n3000 n3730 n4500 n5230 n6000 n6730 n7500 n8230)
set slist = (s0000 s0730 s1500 s2230 s3000 s3730 s4500 s5230 s6000 s6730 s7500 s8230)

# top-level files
if (0) then
  mkdir -p $cattgt
  foreach file (HostTable.dat AstroMap.fits Images.dat Photcodes.dat SkyTable.fits flatcorr.fits )
    ln -sf $catroot/$file $cattgt
  end
  
  # make DEC directories
  foreach dir ($nlist $slist)
    mkdir -p $cattgt/$dir
  end
endif

# link all files from all hostdirs into all DEC dirs
foreach hostdir (`grep -v \# $cattgt/HostTable.dat | awk '{print $3}'`)
  echo $hostdir
  foreach dir ($nlist $slist)
    echo $hostdir : $dir
    foreach ext (cpt cpm cps cpn cpx cpy cpz)
      echo $hostdir : $dir : $ext
      ln -sf $hostdir/$dir/*.$ext $cattgt/$dir
    end
  end
end
