#!/bin/bash
# ==========================================
# (C) AO Kaspersky Lab. All Rights Reserved.
# ==========================================

. $( dirname $0 )/epagent-upgrade.functions

lenoctl="/opt/kaspersky/epagent/sbin/lenactl"

trap cleanup EXIT
echo "Started: $( date )"

PKG=$( get_latest_package "epagent_*.deb" )
check_file_perms $PKG
dpkg -iEG "$PKG"
if [ $? == 0 ]; then
    $lenoctl --send_patch_status applied --module-name "$PKG" || true
else
    $lenoctl --send_patch_status not-applied --module-name "$PKG" || true
fi
