File: tk

package info (click to toggle)
trapperkeeper-clojure 4.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 964 kB
  • sloc: sh: 189; xml: 73; makefile: 25; java: 5
file content (69 lines) | stat: -rwxr-xr-x 1,554 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash

set -ueo pipefail

usage() { echo "Usage: tk JVM_ARG ... -- TK_ARG ..."; }
misuse() { usage 1>&2; exit 2; }

jar_glob='trapperkeeper-*-SNAPSHOT-standalone.jar'

# Believe last -cp wins for java, and here, any final -cp path will be
# placed in front of the jar.

cp=''
jvm_args=()
while test $# -gt 0; do
    case "$1" in
        -h|--help)
            usage
            exit 0
            ;;
        -cp)
            shift
            test $# -gt 0 || misuse
            cp="$1"
            shift
            ;;
        --)
            shift
            break
            ;;
        *)
            shift
            jvm_args+=("$1")
            ;;
    esac
done

if test "${TRAPPERKEEPER_JAR:-}"; then
    jar="$TRAPPERKEEPER_JAR"
else
    # Find the standalone jar and make sure there's only one.
    # FIXME: minor race here between find runs
    # Use a bash array expansion to count the files so we don't have
    # to worry about strange paths (though admittedly unlikely here).
    shopt -s nullglob
    jars=(target/$jar_glob)
    shopt -u nullglob
    if test "${#jars[@]}" -gt 1; then
        echo "error: found more than one SNAPSHOT jar:" 1>&2
        find target -maxdepth 1 -name "$jar_glob" 1>&2
        exit 2
    fi
    jar="${jars[0]}"
fi

if ! test -e "$jar"; then
    printf 'Unable to find target/%s; have you run "lein uberjar"?\n' \
           "$jar" 1>&2
    exit 2
fi

set -x
if test "$cp"; then
    cp="$cp:$jar"
else
    cp="$jar"
fi

exec java -cp "$cp" clojure.main -m puppetlabs.trapperkeeper.main "$@"