OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

130 lines
2.8 KiB

#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: bin/sde
# Copyright (C) 2006 - 2010 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---
set -e
# stand-alone simplified minimal functions
#
echo_info() {
echo "-> $@" >&2
}
echo_abort() {
local errno="$1"; shift
echo "!> ERROR: $@" >&2
exit "$errno"
}
# Early checking of the system
#
if ! type readlink > /dev/null 2>&1; then
echo_abort 1 '`readlink` tool not found'
fi
readlink -f /bin/sh 2>&1 > /dev/null
[ $? -eq 0 ] ||
echo_abort 1 '`readlink` doesnt support -f, please update it.'
if [ "x-x" = "x${1:-}" ]; then
XTRACE=yes
PS4='+${BASH_SOURCE:+$BASH_SOURCE:}$LINENO> '
shift
set -x
else
XTRACE=
fi
# find libsde.in
#
if [ -z "$SDEROOT" ]; then
# finding the root of the tree where we are stand
#
SDEROOT=$( pwd -P )
while [ "$SDEROOT" -a ! -r "$SDEROOT/lib/libsde.in" ]; do
SDEROOT="${SDEROOT%/*}"
done
fi
# if libsde.in was not found, try a fallback
#
if [ ! -r "$SDEROOT/lib/libsde.in" ]; then
SDEROOT="$( readlink -f "$0" )"; SDEROOT="${SDEROOT%/bin/sde}"
[ -r "$SDEROOT/lib/libsde.in" ] ||
echo_abort 1 'SDEROOT not found.'
fi
# switching to the right sde wrapper (SDEROOT specific)
#
if [ "$( readlink -f "$0" )" != "$SDEROOT/bin/sde" ]; then
if [ "--loop" = "${1:-}" ]; then
echo_abort 2 'loop detected, abort.'
fi
set -- ${XTRACE:+-x }--loop "$@"
if [ -x "$SDEROOT/run.sh" ]; then
exec "$SDEROOT/run.sh" sde --run-loop "$@"
else
exec "$SDEROOT/bin/sde" "$@"
fi
elif [ -x "$SDEROOT/run.sh" ]; then
if [ "yes" = "${SDE_VIA_RUN_SH:-}" ]; then
# good
while [ $# -gt 0 ]; do
case "$1" in
--run-loop|--loop)
;;
*)
break ;;
esac
shift
done
elif [ "--run-loop" = "${1:-}" ]; then
echo_abort 2 'loop detected, abort.'
else
if [ "--loop" = "${1:-}" ]; then
shift
fi
exec "$SDEROOT/run.sh" sde ${XTRACE:+-x }--run-loop "$@"
fi
elif [ "--loop" = "${1:-}" ]; then
shift
fi
# load corresponding library for sh scripts
#
. "$SDEROOT/lib/libsde.in"
. "$SDEROOT/lib/sde-wrapper-command.in"
if [ $# -eq 0 -o "$1" = "--help" ]; then
sde_wrapper_command_help
else
command="$( sde_wrapper_command "$1" )"
if [ -z "$command" ]; then
# unknown command
echo_error "Command '$COLOR_INFO$1$COLOR_NORMAL' not understood."
sde_wrapper_command_help
else
shift;
[ -x "$SDEROOT/bin/sde-$command" ] ||
echo_abort 2 "Can't execute '$COLOR_INFO$SDEROOT/bin/sde-$command$COLOR_NORMAL', sorry."
exec "$SDEROOT/bin/sde-$command" "$@"
fi
fi
exit 1