#!/usr/bin/env bash

set -euo pipefail

if [[ "${EUID:-$(id -u)}" -ne 0 ]]; then
    echo "❌ Ошибка: скрипт должен быть запущен с правами root."
    echo "👉 Используй: sudo $0"
    exit 1
fi

source ./_config
service_name="$SERVICE_NAME.service"
target_file="/etc/systemd/system/$service_name"

systemctl stop $service_name
rm "$target_file"

systemctl daemon-reexec
systemctl daemon-reload

echo Removed $service_name!

