-
Notifications
You must be signed in to change notification settings - Fork 290
/
querydb-install.sh
executable file
·55 lines (49 loc) · 1.43 KB
/
querydb-install.sh
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
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
set -eu
if [ "$(uname)" = 'Darwin' ]; then
# get script location
# https://unix.stackexchange.com/a/96238
if [ "${BASH_SOURCE:-x}" != 'x' ]; then
this_script=$BASH_SOURCE
elif [ "${ZSH_VERSION:-x}" != 'x' ]; then
setopt function_argzero
this_script=$0
elif eval '[[ -n ${.sh.file} ]]' 2>/dev/null; then
eval 'this_script=${.sh.file}'
else
echo 1>&2 "Unsupported shell. Please use bash, ksh93 or zsh."
exit 2
fi
relative_directory=$(dirname "$this_script")
SCRIPT_ABS_DIR=$(cd "$relative_directory" && pwd)
else
SCRIPT_ABS_PATH=$(readlink -f "$0")
SCRIPT_ABS_DIR=$(dirname "$SCRIPT_ABS_PATH")
fi
# Check required tools are installed.
check_installed() {
if ! type "$1" > /dev/null; then
echo "Please ensure you have $1 installed."
exit 1
fi
}
# https://stackoverflow.com/a/28085062
: ${DEFAULT_JOERN_INSTALL_DIR:=$PWD/joern-cli/target/universal/stage}
echo "where is the joern distribution installed?
note: you can e.g. create one locally using 'sbt stage'
[$DEFAULT_JOERN_INSTALL_DIR]:"
read JOERN_INSTALL_DIR
if [ -z "$JOERN_INSTALL_DIR" ]; then
JOERN_INSTALL_DIR=$DEFAULT_JOERN_INSTALL_DIR
fi
echo "building the plugin"
sbt querydb/createDistribution
readonly QUERYDB_ZIP=$PWD/querydb/target/querydb.zip
echo "Installing plugin"
pushd $JOERN_INSTALL_DIR
./joern --remove-plugin querydb
./joern --add-plugin $QUERYDB_ZIP
popd