Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (83 sloc) 2.5 KB
#!/bin/bash
set -e
me=`basename "$0"`
mydir=`dirname "$0"`
# Either:
# abs_srcdir and abs_builddir are set: we're running in a dev tree
# or pkgdatadir is set: we've been installed, we respect that.
abs_srcdir='@abs_srcdir@'
abs_builddir='@abs_builddir@'
pkgdatadir='@pkgdatadir@'
# Either we've been installed and pkgdatadir exists, or we haven't been
# installed and abs_srcdir / abs_builddir aren't empty.
test -d "$pkgdatadir" || test -n "$abs_srcdir$abs_builddir" || {
echo >&2 "$me: Uh-oh, \`$pkgdatadir' doesn't exist, is OpenTSDB properly installed?"
exit 1
}
if test -n "$pkgdatadir"; then
localdir="$pkgdatadir"
for jar in "$pkgdatadir"/*.jar; do
CLASSPATH="$CLASSPATH:$jar"
done
# Add pkgdatadir itself so we can find logback.xml
CLASSPATH="$CLASSPATH:$pkgdatadir"
else
localdir="$abs_builddir"
# If we're running out of the build tree, it's especially important that we
# know exactly what jars we need to build the CLASSPATH. Otherwise people
# cannot easily pick up new dependencies as we might mix multiple versions
# of the same dependencies on the CLASSPATH, which is bad. Looking for a
# specific version of each jar prevents this problem.
# TODO(tsuna): Once we jarjar all the dependencies together, this will no
# longer be an issue. See issue #23.
for jar in `make -C "$abs_builddir" printdeps | sed '/third_party.*jar/!d'`; do
for dir in "$abs_builddir" "$abs_srcdir"; do
test -f "$dir/$jar" && CLASSPATH="$CLASSPATH:$dir/$jar" && continue 2
done
echo >&2 "$me: error: Couldn't find \`$jar' either under \`$abs_builddir' or \`$abs_srcdir'."
exit 2
done
# Add the src dir so we can find logback.xml
CLASSPATH="$CLASSPATH:$abs_srcdir/src"
fi
# Remove any leading colon.
CLASSPATH="${CLASSPATH#:}"
usage() {
echo >&2 "usage: $me <command> [args]"
echo 'Valid commands: fsck, import, mkmetric, query, tsd, scan, uid'
exit 1
}
case $1 in
(fsck)
MAINCLASS=Fsck
;;
(import)
MAINCLASS=TextImporter
;;
(mkmetric)
shift
set uid assign metrics "$@"
MAINCLASS=UidManager
;;
(query)
MAINCLASS=CliQuery
;;
(tsd)
MAINCLASS=TSDMain
;;
(scan)
MAINCLASS=DumpSeries
;;
(uid)
MAINCLASS=UidManager
;;
(*)
echo >&2 "$me: error: unknown command '$1'"
usage
;;
esac
shift
JAVA=${JAVA-'java'}
JVMARGS=${JVMARGS-'-enableassertions -enablesystemassertions'}
test -r "$localdir/tsdb.local" && . "$localdir/tsdb.local"
exec $JAVA $JVMARGS -classpath "$CLASSPATH" net.opentsdb.tools.$MAINCLASS "$@"
Jump to Line
Something went wrong with that request. Please try again.