#!/bin/env sh

set -e

[ "$(id -u)" -ne 0 ] && exec sudo "$0"

systemctl start cassandra

if [ ! -d /var/lib/thp/thehive/index/global ]; then
    echo
    echo "It seems this is the first time you start thehive"
    echo "Please wait..."
    echo
    sleep 60s
    cqlsh -e "UPDATE system.local SET cluster_name='thp' where key='local';"
    nodetool flush
    sed -i -E "s/^cluster_name:.*/cluster_name: 'thp'/" /etc/cassandra/cassandra.yaml
    systemctl restart cassandra
    echo
    echo
    echo "The fist start is very long (several minutes)"
fi

kali-service-start thehive 9000 admin:secret

