##!/usr/bin/env bash
set -euf -o pipefail

sudo apt update



# install common tools
sudo apt-get install -y git python3 python3-pip tar wget

#install dependencies to build sleuthkit
sudo apt-get install -y libtool build-essential automake autoconf libssl-dev

#install dependencies to build pytsk
sudo apt-get install -y python3-dev python3-setuptools

#install dependencies for fbekeyfind
sudo apt-get install -y aeskeyfind


# create directory to build modules
mkdir one_key
cd one_key

# clone projects
git clone https://faui1-gitlab.cs.fau.de/tobias.gross/pytsk3.git
git clone https://faui1-gitlab.cs.fau.de/tobias.gross/dfvfs.git
git clone https://faui1-gitlab.cs.fau.de/tobias.gross/plaso.git

# build pytsk and sleuthkit
cd pytsk3
python3 setup.py update --use-head

# build and install TSK
cd sleuthkit
./bootstrap
./configure
make
sudo make install
cd ..

# build and install pytsk
python3 setup.py build
sudo python3 setup.py install
cd ..

# build and install dfVFS
cd dfvfs
pip3 install -r requirements.txt
python3 setup.py build
sudo python3 setup.py install
cd ..

# build and install plaso
cd plaso
pip3 install -r requirements.txt
python3 setup.py build
sudo python3 setup.py install
cd ..

# download and untar fbekeyfind and install dependencies
wget https://faui1-files.cs.fau.de/public/one_key_to_rule/fbekeyfind.tar.gz
tar xzf fbekeyfind.tar.gz
cd fbekeyfind
pip3 install -r requirements.txt
cd ..

# exiting modules directory "one_key"
cd ..
