Skip to content
Snippets Groups Projects
ost.in 2.50 KiB
#!/bin/bash
#------------------------------------------------------------------------------
# This file is part of the OpenStructure project <www.openstructure.org>
#
# Copyright (C) 2008-2010 by the OpenStructure authors
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3.0 of the License, or (at your option)
# any later version.
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#------------------------------------------------------------------------------

#
# convenience wrapper for non-gui openstructure interface 'ost'
#
# Self detect important directories
if [ -h "$0" ] ; then
  SCRIPT_NAME=`readlink "$0"`
else
  SCRIPT_NAME="$0"
fi
BIN_DIR=`dirname "$SCRIPT_NAME"`
export DNG_ROOT=`cd "$BIN_DIR/..";pwd`
export PATH="$DNG_ROOT/bin:$PATH"
export DYLD_FRAMEWORK_PATH="$BIN_DIR/../@LIBDIR@:${DYLD_FRAMEWORK_PATH}"
export DYLD_LIBRARY_PATH="$BIN_DIR/../@LIBDIR@:${DYLD_LIBRARY_PATH}"

export LD_LIBRARY_PATH="$DNG_ROOT/@LIBDIR@:$LD_LIBRARY_PATH"
# set QT_PLUGIN_PATH and pythonpath for bundle (commented except in linux bundles)
#export QT_PLUGIN_PATH="$BIN_DIR/plugins"
#export PYTHONPATH="$DNG_ROOT/@LIBDIR@/python2.6"

# retrieve absolute path to python executable
pyexec=""
if [ -z "$DNG_ATTACH_VALGRIND" ]; then
  pyexec="@PYTHON_BINARY@"
else
  pyexec="valgrind --leak-check=full @PYTHON_BINARY@"
fi

if [ ! -f "$pyexec" ]; then 
  echo "Error: Python executable '$pyexec' not found!"
  exit
fi

set -o noglob

# decide whether to start interactively or not
# interactive mode can be forced by setting -i as a ost_cl option
interactive=""
if [ $# == 0 ];then
  interactive="-i"
else
  opts=""
  for argument in "$@";do 
    if [ -n "$opts" ]; then
      opts=$opts"#""$argument"
    else  
      opts="$argument"
    fi  
  done
  if [ $1 == "-i" ] ;then
    interactive="-i"
  fi
  if [ $1 == "-v" ] ;then
    interactive="-i"
  fi
fi
# finally pass control to python instance
IFS="#"
exec $pyexec $interactive "$DNG_ROOT/@LIBDIR@/openstructure/init_cl.py" $opts
IFS=$' \t\n'