#!/bin/bash


# 获取环境信息
/usr/local/bin/agent-wdd info all
cat /usr/local/etc/wdd/agent-wdd-config.yaml

# 手动执行全部的命令
/usr/local/bin/agent-wdd base ssh key
/usr/local/bin/agent-wdd base ssh config

/usr/local/bin/agent-wdd base tools
/usr/local/bin/agent-wdd base swap
/usr/local/bin/agent-wdd base firewall
/usr/local/bin/agent-wdd base selinux
/usr/local/bin/agent-wdd base sysconfig

/usr/local/bin/agent-wdd zsh

# 首先需要下载所有的依赖！

/usr/local/bin/agent-wdd base docker local
/usr/local/bin/agent-wdd base dockercompose local

# 仅在主节点执行
/usr/local/bin/agent-wdd base docker config

/usr/local/bin/agent-wdd base harbor install


# 批量执行命令

host_list=(
   172.16.100.56
   172.16.100.57
   172.16.100.58
)


host_list=(
   172.16.100.62
   172.16.100.51
   172.16.100.52
   172.16.100.53
   172.16.100.54
   172.16.100.55
   172.16.100.56
   172.16.100.57
   172.16.100.58
   172.16.100.59
   172.16.100.60
   172.16.100.61
)

host_list=(
   172.16.100.56
   172.16.100.57
   172.16.100.58
)
for server in "${host_list[@]}";do
   echo "current ip is $server"
   ssh root@${server} "rm -rf /var/lib/docker/nfs_data/*"
   echo ""
done

# 复制 同步文件
export server=172.16.100.62

scp /usr/local/bin/agent-wdd root@${server}:/usr/local/bin/agent-wdd
ssh root@${server} "/usr/local/bin/agent-wdd base ssh config"
ssh root@${server} "/usr/local/bin/agent-wdd base ssh key"

# 磁盘初始化
ssh root@${server} "mkdir /root/wdd"
scp /root/wdd/disk.sh root@${server}:/root/wdd/
ssh root@${server} "bash /root/wdd/disk.sh"

# 复制文件-docker
scp /root/wdd/docker-amd64-20.10.15.tgz root@${server}:/root/wdd/docker-amd64-20.10.15.tgz
scp /root/wdd/docker-compose-v2.18.0-linux-amd64  root@${server}:/root/wdd/

# 批量执行agent-wdd的命令
ssh root@${server} "/usr/local/bin/agent-wdd info all"
ssh root@${server} "cat /usr/local/etc/wdd/agent-wdd-config.yaml"

# ssh root@${server} "/usr/local/bin/agent-wdd base tools"

ssh root@${server} "/usr/local/bin/agent-wdd base swap"
ssh root@${server} "/usr/local/bin/agent-wdd base firewall"
ssh root@${server} "/usr/local/bin/agent-wdd base selinux"
ssh root@${server} "/usr/local/bin/agent-wdd base sysconfig"

ssh root@${server} "/usr/local/bin/agent-wdd base docker local"
ssh root@${server} "/usr/local/bin/agent-wdd base dockercompose local"

# 仅在主节点执行
/usr/local/bin/agent-wdd base docker config

# 下发docker的配置
scp /etc/docker/daemon.json root@${server}:/etc/docker/daemon.json
ssh root@${server} "cat /etc/docker/daemon.json"
ssh root@${server} "systemctl restart docker"
ssh root@${server} "docker info"

wget https://oss.demo.uavcmlc.com/cmlc-installation/tmp/nginx=1.27.0=2025-03-11=402.tar.gz && docker load < nginx=1.27.0=2025-03-11=402.tar.gz && docker run -it --rm harbor.cdcyy.com.cn/cmii/nginx:1.27.0