#!/bin/bash

#auto_install_pid=`ps -aux | grep auto_install | grep -v grep | awk -F " " '{print $2}'`
#kill -9 $auto_install_pid
echo "destroy k8s allinone default start"
docker exec -it kubeasz ezctl destroy default &
# nerdctl exec -it kubeasz ezctl destroy default
sleep 5
systemctl restart docker
sleep 5
#kubeasz_pid=`docker ps | grep kubeasz | awk -F " " '{print $1}'`
echo "#########################################################"
#echo "kubeasz_pid="$kubeasz_pid
#docker stop "$kubeasz_pid"
#docker rm "$kubeasz_pid"
cd "$install_path"/soft && ./ezdown -C
docker system prune -a
systemctl stop docker
systemctl disable containerd
rm -rf /etc/kubeasz
rm -rf /etc/kube
rm -rf /usr/bin/containerd*
rm -rf /usr/bin/ctr
rm -rf /usr/bin/docker
rm -rf /usr/bin/dockerd
rm -rf /usr/bin/docker-init
rm -rf /usr/bin/docker-proxy
rm -rf /usr/bin/runc
rm -rf /etc/docker
rm -rf /var/lib/docker
rm -rf /etc/kubernetes
rm -rf /etc/kube-lb
rm -rf /opt/kube
rm -rf /run/containerd
rm -rf /usr/bin/containerd
rm -rf /opt/containerd
rm -rf /usr/local/bin/docker-compose
rm -rf /run/docker
rm -rf /home/edoc2/macrowing/docker
rm -rf /var/run/docker
rm -rf /var/lib/etcd
rm -rf /home/edoc2
rm -rf /kube/bin/etcd
echo "destroy k8s allinone default finished"
sleep 10
reboot
