#!/bin/bash

if [ $(whoami) != 'root' ]; then
    echo "Must be root to run. Try using 'sudo'."
    exit 1;
fi

# Ensure we can access https package repositories
apt-get install -y apt-transport-https

# Get the repository public key
wget -O - https://app.drivestrike.com/static/drivestrike.pubkey.txt | apt-key add -

# Add the DriveStrike repository
url_port=""
if [[ -f /usr/bin/lsb_release ]]; then
  /usr/bin/lsb_release -d | grep -q 14\.04
  if [[ $? == 0 ]]; then
    url_port=":444"
  fi
fi
echo deb [arch=amd64] https://app.drivestrike.com$url_port/static/apt/ stretch main > /etc/apt/sources.list.d/drivestrike.list

# Install DriveStrike
apt-get update && apt-get install -y drivestrike

# Register DriveStrike and start the DriveStrike service
drivestrikerun.sh 

