#!/bin/sh

name=`readlink -fn $0`
BD=`dirname $name`
if [ x$1 != x ]; then
    DST=$1
    ZIP=`ls $BD/../../org-lsst-ccs-subsystem-refrig-main-*.zip`
    REL=`basename $ZIP -dist.zip`
    rm -rf $DST/$REL
    unzip -d $DST $ZIP
else
    DST=$BD/../..
    REL=`basename \`dirname $BD\``
fi
mkdir -p $DST/etc
mkdir -p $DST/bin
BS=../$REL/bin/CCSbootstrap.sh
APP=$DST/bin/thermal; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/thermal-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/refrig; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/refrig-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/refrig1; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/refrig1-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/refrig2; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/refrig2-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/hex; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/hex-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/pathfinder-refrig; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/pathfinder-refrig-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/chiller; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/chiller1; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/chiller1-nocamera; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/chiller2; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/chiller2-nocamera; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/chiller-sim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/prototype-cold-plate; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/prototype-cold-plate-sim; rm -f $APP; ln -sf $BS $APP
