#!/bin/bash

set -e

if [ $(id -u) -ne 0 ]; then
	echo "Please run as root. - sudo su"
	exit
fi

echo "[INIT] Start uninstall device-control"
systemctl disable device-control
systemctl stop device-control
rm /etc/systemd/system/device-control.service
rm /usr/local/bin/device-control
rm -rf /etc/sdt/device-control 
echo "[INIT] Finish uninstall device-control"

echo "[INIT] Start uninstall device-health"
systemctl disable device-health
systemctl stop device-health
rm /etc/systemd/system/device-health.service
rm /usr/local/bin/device-health
rm -rf /etc/sdt/device-health
echo "[INIT] Finish uninstall device-health"

echo "[INIT] Start uninstall device-heartbeat"
systemctl disable device-heartbeat
systemctl stop device-heartbeat
rm /etc/systemd/system/device-heartbeat.service
rm /usr/local/bin/device-heartbeat
echo "[INIT] Finish uninstall device-heartbeat"

echo "[INIT] Start uninstall process-checker"
systemctl disable process-checker
systemctl stop process-checker
rm /etc/systemd/system/process-checker.service
rm /usr/local/bin/process-checker
echo "[INIT] Finish uninstall process-checker"

echo "[INIT] Start uninstall bwc-management"
systemctl disable bwc-management
systemctl stop bwc-management
rm /etc/systemd/system/bwc-management.service
rm /usr/local/bin/bwc-management
echo "[INIT] Finish uninstall bwc-management"

echo "[INIT] Delete Cert, Config, Log Data"
rm -rf /etc/sdt