#!/bin/sh

if [ `uname` == Linux ]; then FP=`readlink -fn $0`
else FP=`perl -e "use Cwd 'abs_path'; print abs_path('$0')"`; fi
BD=`dirname $FP`
if [ x$1 != x ]; then
    DST=$1
    ZIP=`ls $BD/../../org-lsst-ccs-subsystem-teststand-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/run-ts7-slac; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/ts; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/ts8-bench; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/tsSim; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/KeithleyDevice; rm -f $APP; ln -sf $BS $APP
