#!/bin/bash

appname=ugenecld

# Check if '-ui' parameter is present. 
# If it does exclude it from the list of parameters
# and use ugeneui instead of ugenecl

params=()

while [[ $# -gt 0 ]];
do
    if [ "$1" = "-ui" ]; then
        appname=ugeneuid
    else
        params+=("$1")
    fi
    shift
done

dirname=$(dirname `readlink -f $0`)

tmp="${dirname#?}"

if [ "${dirname%$tmp}" != "/" ]; then
    dirname=$PWD/$dirname
fi

LD_LIBRARY_PATH=$dirname
export LD_LIBRARY_PATH

$dirname/$appname "${params[@]}"
