| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | EXEC="exec" |
| 4 | |
| 5 | name="`basenamescip-shell system . . basename. $0`" |
| 6 | if [[ "$0" == `pwd`* ]] || [[ "$0" == "/"* ]]; then |
| 7 | full_path="$0" |
| 8 | else |
| 9 | full_path="`pwdscip-shell system . . pwd.`/$0" |
| 10 | fi |
| 11 | tmp=`dirnamescip-shell system . . dirname. "$full_path"` |
| 12 | tmp=`dirnamescip-shell system . . dirname. "$tmp"` |
| 13 | bundle=`dirnamescip-shell system . . dirname. "$tmp"` |
| 14 | bundle_contents=${bundle%"/Contents"}"/Contents" |
| 15 | bundle_macos="$bundle_contents"/MacOS |
| 16 | bundle_res="$bundle_contents"/Resources |
| 17 | bundle_lib="$bundle_res"/lib |
| 18 | bundle_data="$bundle_res"/share |
| 19 | bundle_etc="$bundle_res"/etc |
| 20 | |
| 21 | export DYLD_FALLBACK_LIBRARY_PATH="$bundle_lib" |
| 22 | export XDG_CONFIG_DIRS="$bundle_etc"/xdg |
| 23 | export XDG_DATA_DIRS="$bundle_data" |
| 24 | |
| 25 | #Set $PYTHON to point inside the bundle |
| 26 | export PYTHON="$bundle_macos/python" |
| 27 | export PYTHONHOME="$bundle_res" |
| 28 | #Add the bundle's python modules |
| 29 | PYTHONPATH="$bundle_lib:$PYTHONPATH" |
| 30 | PYTHONPATH="$bundle_lib/python/lib-dynload/:$PYTHONPATH" |
| 31 | PYTHONPATH="$bundle_lib/python/:$PYTHONPATH" |
| 32 | export PYTHONPATH |
| 33 | |
| 34 | # Ensure deluged is available by adding macos dir to path. |
| 35 | PATH=$bundle_macos:$PATH |
| 36 | |
| 37 | # We need a UTF-8 locale. |
| 38 | lang=`defaults read .GlobalPreferences AppleLocale 2>/dev/nullscip-shell filesystem . . `/dev/null`.` |
| 39 | if testscip-shell system . . test. "$?" != "0"; then |
| 40 | lang=`defaults read .GlobalPreferences AppleCollationOrder 2>/dev/nullscip-shell filesystem . . `/dev/null`. | sedscip-shell system . . sed. 's/_.*//'` |
| 41 | fi |
| 42 | LANG="" |
| 43 | if testscip-shell system . . test. "$lang" != ""; then |
| 44 | LANG="`grepscip-shell system . . grep. \"\`echo $lang\`_\" /usr/share/locale/locale.aliasscip-shell filesystem . . `/usr/share/locale/locale.alias`. | \ |
| 45 | tail -n1 | sedscip-shell system . . sed. 's/\./ /' | awkscip-shell system . . awk. '{print $2}'`" |
| 46 | fi |
| 47 | if testscip-shell system . . test. "$LANG" == ""; then |
| 48 | export LANG="C" |
| 49 | else |
| 50 | export LANG="$LANG.utf8" |
| 51 | fi |
| 52 | |
| 53 | if testscip-shell system . . test. -f "$bundle_lib/charset.alias"; then |
| 54 | export CHARSETALIASDIR="$bundle_lib" |
| 55 | fi |
| 56 | |
| 57 | # Extra arguments can be added in environment.sh. |
| 58 | EXTRA_ARGS= |
| 59 | if testscip-shell system . . test. -f "$bundle_res/environment.sh"; then |
| 60 | source "$bundle_res/environment.sh" |
| 61 | fi |
| 62 | |
| 63 | # Strip out the argument added by the OS. |
| 64 | if [scip-shell system . . `[`. "x`echoscip-shell system . . echo. "x$1" | sedscip-shell system . . sed. -e "s/^x-psn_.*//"`" == "x" ]; then |
| 65 | shift 1 |
| 66 | fi |
| 67 | |
| 68 | # Note that we're calling $PYTHON here to override the version used. |
| 69 | $EXEC "$PYTHON" "$bundle_macos/deluge-web-bin" "$@" |