#!/bin/sh
#

# SIP Linux Agent Removal Utility
# v1.1 - 2024/05/08

if ! [ $(id -u) = 0 ]; then
   echo "This script must be run with root privilege"
   exit 1
fi

# Stop and disable both potential agent services
echo "Stopping and disabling existing agent services if present"
service avaceesip stop || true
systemctl stop avaceesip || true
systemctl disable avaceesip || true

service sipagent stop || true
systemctl stop sipagent || true
systemctl disable sipagent || true

systemctl daemon-reload
systemctl reset-failed

# Cleaning up all agent files
echo "Cleaning up all agent files and directories if present"
rm -rvf /usr/local/avacee
rm -rvf /var/log/avacee
rm -rvf /usr/local/sipagent
rm -rvf /var/log/sipagent
rm -rf /tmp/sipagentextract
rm -rvf /etc/sipagent

echo "DIA SIP Agent removal complete."

