-
Notifications
You must be signed in to change notification settings - Fork 595
/
install_tsk_from_src.sh
77 lines (70 loc) · 1.93 KB
/
install_tsk_from_src.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# Clones sleuthkit repo from github (if necessary) and installs
# this script does require sudo privileges
# called like: install_tsk_from_src.sh -p <repo path to be created or existing> -b <tsk branch to checkout> -r <non-standard remote repo (optional)>
usage() {
echo "Usage: install_tsk_from_src.sh [-p repo_path (should end with '/sleuthkit')] [-b tsk_branch] [-r sleuthkit_repo]" 1>&2
}
# default repo path
REPO="https://github.com/sleuthkit/sleuthkit.git"
TSK_BRANCH="develop"
while getopts "p:r:b:" o; do
case "${o}" in
p)
SLEUTHKIT_SRC_DIR=${OPTARG}
;;
b)
TSK_BRANCH=${OPTARG}
;;
r)
REPO=${OPTARG}
;;
*)
usage
exit 1
;;
esac
done
if [[ -z "${SLEUTHKIT_SRC_DIR}" ]]; then
usage
exit 1
fi
if [[ ! -d $SLEUTHKIT_SRC_DIR/.git ]]; then
TSK_REPO_PATH=$(dirname "$SLEUTHKIT_SRC_DIR")
echo "Cloning Sleuthkit to $TSK_REPO_PATH..."
mkdir -p $TSK_REPO_PATH &&
pushd $TSK_REPO_PATH &&
git clone --depth 1 -b $TSK_BRANCH $REPO &&
popd
if [[ ! -d $SLEUTHKIT_SRC_DIR ]]; then
echo "Unable to successfully clone Sleuthkit" >>/dev/stderr
exit 1
fi
else
echo "Getting latest of Sleuthkit branch: $TSK_BRANCH..."
pushd $SLEUTHKIT_SRC_DIR &&
git remote set-branches origin '*' &&
git fetch -v &&
git reset --hard &&
git checkout $TSK_BRANCH &&
git pull &&
popd
if [[ $? -ne 0 ]]; then
echo "Unable to reset Sleuthkit repo and pull latest on $TSK_BRANCH" >>/dev/stderr
exit 1
fi
fi
echo "Installing Sleuthkit..."
pushd $SLEUTHKIT_SRC_DIR &&
./bootstrap &&
./configure &&
make &&
sudo make install &&
popd
if [[ $? -ne 0 ]]; then
echo "Unable to build Sleuthkit." >>/dev/stderr
exit 1
fi
JAVA_INSTALLS=/usr/local/share/java
echo "Sleuthkit in $JAVA_INSTALLS:"
ls $JAVA_INSTALLS | grep sleuthkit