blob: fc21deaf656c1429923d79b1c310fd169d00e4e9 [file] [log] [blame]
22301080a0334732025-05-17 21:38:32 +08001#!/bin/sh
2
3# Copyright (C) 2012 Turn, Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17EXECJAR="ttorrent-*-shaded.jar"
18
19real_path() {
20 case $1 in
21 /*)
22 SCRIPT="$1"
23 ;;
24 *)
25 PWD=`pwd`
26 SCRIPT="$PWD/$1"
27 ;;
28 esac
29 CHANGED=true
30 while [ "X$CHANGED" != "X" ] ; do
31 # Change spaces to ":" so the tokens can be parsed.
32 SAFESCRIPT=`echo $SCRIPT | sed -e 's; ;:;g'`
33 # Get the real path to this script, resolving any symbolic links
34 TOKENS=`echo $SAFESCRIPT | sed -e 's;/; ;g'`
35 REALPATH=
36 for C in $TOKENS; do
37 # Change any ":" in the token back to a space.
38 C=`echo $C | sed -e 's;:; ;g'`
39 REALPATH="$REALPATH/$C"
40 # If REALPATH is a sym link, resolve it. Loop for nested links.
41 while [ -h "$REALPATH" ] ; do
42 LS="`ls -ld "$REALPATH"`"
43 LINK="`expr "$LS" : '.*-> \(.*\)$'`"
44 if expr "$LINK" : '/.*' > /dev/null; then
45 # LINK is absolute.
46 REALPATH="$LINK"
47 else
48 # LINK is relative.
49 REALPATH="`dirname "$REALPATH"`""/$LINK"
50 fi
51 done
52 done
53 if [ "$REALPATH" = "$SCRIPT" ] ; then
54 CHANGED=""
55 else
56 SCRIPT="$REALPATH"
57 fi
58 done
59 echo "$REALPATH"
60}
61
62base=$(dirname $(real_path $0))
63CPARG=$(find ${base}/../build -name "$EXECJAR" | tail -n 1)
64if [ -z "$CPARG" ] ; then
65 echo "Unable to find $EXECJAR"
66 exit 1
67fi
68if [ -z "$MAINCLASS" ] ; then
69 CPARG="-jar $CPARG"
70else
71 CPARG="-cp $CPARG $MAINCLASS"
72fi
73exec java $CPARG "$@"