#! /bin/bash


systemctl stop netclient

systemctl disable netclient

rm -rf /etc/systemd/system/netclient.service
rm -rf /etc/netclient/config

/usr/local/bin/k3s-uninstall.sh
/usr/local/bin/k3s-agent-uninstall.sh

apt remove -y wireguard wireguard-tools
rm -rf /root/k3s-install/
ifconfig wg0-oracle down

apt autoremove -y

ifconfig

systemctl stop systemd-resolved.service && systemctl disable systemd-resolved.service
systemctl stop netfilter-persistent.service && systemctl disable netfilter-persistent.service


rm /etc/resolv.conf
cat > /etc/resolv.conf<<EOF
nameserver 1.1.1.1
nameserver 1.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 223.5.5.5
nameserver 114.114.114.114
EOF
ping google.com


## Ubuntu 18.04
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.gpg | sudo apt-key add -
curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/bionic.list | sudo tee /etc/apt/sources.list.d/tailscale.list

sudo apt-get update
sudo apt-get install tailscale

systemctl enable --now tailscaled

tailscale up --login-server=http://tailscale.107421.xyz --accept-routes=false --accept-dns=false

headscale -n wdd-net nodes register --key 

systemctl status tailscaled