#!/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-gui-*.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/CCS-Console; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/TSGui; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/TSConfigurableSubsystemGUI; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/TSMonitorGui; rm -f $APP; ln -sf $BS $APP
APP=$DST/bin/KeithleyDeviceGui; rm -f $APP; ln -sf $BS $APP
