#!/bin/bash

SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit 1
fi

AKSUSBD_VER="8.31.1"
AKSUSBD_PATH="${SCRIPT_PATH}/aksusbd-${AKSUSBD_VER}"

echo "[VideoIntellect VMS] Installing aksusbd v${AKSUSBD_VER} package"

chmod --verbose +x ${AKSUSBD_PATH}/dinst ${AKSUSBD_PATH}/dunst
cd ${AKSUSBD_PATH}
./dinst
echo "Copy vendor libs"
cp --verbose -rf ${AKSUSBD_PATH}/*.so /var/hasplm/

echo "Copy aksusbd config"
cp --verbose ${SCRIPT_PATH}/hasplm.ini /etc/hasplm/

systemctl restart aksusbd
