#!/bin/bash

# Check if running as root
if [ "$EUID" -ne 0 ]; then
	echo -e "${RED}This script must be run as root${NC}"
	exit 1
fi

if which curl >/dev/null 2>/dev/null; then
	curl -s https://cdn.gyuri.net/wireguard/idc/idc-route.sh -o /opt/idc-route.sh
else
	wget -O /opt/idc-route.sh https://cdn.gyuri.net/wireguard/idc/idc-route.sh
fi
chmod +x /opt/idc-route.sh

if which curl >/dev/null 2>/dev/null; then
	curl -s https://cdn.gyuri.net/wireguard/idc/idc-route.service -o /etc/systemd/system/idc-route.service
else
	wget -O /etc/systemd/system/idc-route.service https://cdn.gyuri.net/wireguard/idc/idc-route.sh
fi

systemctl daemon-reload
systemctl enable --now idc-route
