#!/bin/bash

source "/etc/asl/config"
export LANG="en_US.UTF-8"

if [ "$CONFIGURED" ==  "yes" ]; then

  # Automatic Updates
  if [ "$AUTOMATIC_UPDATES" ==  "monthly" ]; then
    /var/asl/bin/aum -u >/dev/null 2>&1
  fi

        # AEO: agent cleanup (dead agents)
        if [[ "$HIDS_AGENT_KEEP_ALIVE" == "monthly" ]]; then
          if [ -f /var/asl/bin/agent_cleanup.sh ]; then
            if [[ "$HIDS_AGENT_KEEP_ALIVE_TYPE" =~ "Disconnected" ]]; then
              /var/asl/bin/agent_cleanup.sh -d
            fi

            if [[ "$HIDS_AGENT_KEEP_ALIVE_TYPE"  =~ "Never Connected" ]]; then
              /var/asl/bin/agent_cleanup.sh -nc
            fi

            if [[ "$HIDS_AGENT_KEEP_ALIVE_TYPE"  =~ "Active" ]]; then
              /var/asl/bin/agent_cleanup.sh -a
            fi
          fi
        fi


else
  echo "Error: ASL has not been configured"
  exit 1
fi
