[initramfs] Enhanced output format to run `ldconfig` if etc/ld.so.conf is present
[opensde-nopast.git] / bin / sde
blobf13c5b762f728f088c8124f6ebda86d04442af93
1 #!/bin/sh
2 # --- SDE-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
5 # Filename: bin/sde
6 # Copyright (C) 2006 - 2008 The OpenSDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- SDE-COPYRIGHT-NOTE-END ---
16 set -e
18 # stand-alone simplified minimal functions
20 echo_info() {
21 echo "-> $@" >&2
24 echo_abort() {
25 local errno="$1"; shift
26 echo -e "!> ERROR: $@" >&2
27 exit "$errno"
30 # Early checking of the system
32 [ -n "$( type -p readlink )" ] ||
33 echo_abort 1 '`readlink` tool not found'
35 readlink -f /bin/sh 2>&1 > /dev/null
36 [ $? -eq 0 ] ||
37 echo_abort 1 '`readlink` doesnt support -f, please update it.'
39 # find libsde.in
41 if [ -z "$SDEROOT" ]; then
42 # finding the root of the tree where we are stand
44 SDEROOT=$( pwd -P )
45 while [ "$SDEROOT" -a ! -r "$SDEROOT/lib/libsde.in" ]; do
46 SDEROOT="${SDEROOT%/*}"
47 done
50 # if libsde.in was not found, try a fallback
52 if [ ! -r "$SDEROOT/lib/libsde.in" ]; then
53 SDEROOT="$( readlink -f "$0" )"; SDEROOT="${SDEROOT%/bin/sde}"
55 [ -r "$SDEROOT/lib/libsde.in" ] ||
56 echo_abort 1 'SDEROOT not found.'
59 # switching to the right sde wrapper (SDEROOT specific)
61 if [ "$( readlink -f "$0" )" != "$SDEROOT/bin/sde" ]; then
62 if [ "$1" = "--loop" ]; then
63 echo_abort 2 'loop detected, abort.'
64 else
65 exec "$SDEROOT/bin/sde" --loop "$@"
67 elif [ "$1" = "--loop" ]; then
68 shift
71 # load corresponding library for sh scripts
73 . "$SDEROOT/lib/libsde.in"
74 . "$SDEROOT/lib/sde-wrapper-command.in"
76 if [ $# -eq 0 -o "$1" = "--help" ]; then
77 sde_wrapper_command_help
78 else
79 command="$( sde_wrapper_command "$1" )"
80 if [ -z "$command" ]; then
81 # unknown command
82 echo_error "Command '$COLOR_INFO$1$COLOR_NORMAL' not understood."
83 sde_wrapper_command_help
84 else
85 shift;
87 [ -x "$SDEROOT/bin/sde-$command" ] ||
88 echo_abort 2 "Can't execute '$COLOR_INFO$SDEROOT/bin/sde-$command$COLOR_NORMAL', sorry."
90 exec "$SDEROOT/bin/sde-$command" "$@"
93 exit 1