#!/bin/bash


master_server_list=(192.168.35.105 192.168.35.114 192.168.35.115)
worker_server_list=(192.168.35.55 192.168.35.86 192.168.35.89 192.168.35.93 192.168.35.95 192.168.35.96 192.168.35.101 192.168.35.103 192.168.35.104)

all_server_list=(192.168.35.105 192.168.35.114 192.168.35.115 192.168.35.55 192.168.35.86 192.168.35.89 192.168.35.93 192.168.35.95 192.168.35.96 192.168.35.101 192.168.35.103 192.168.35.104)

all_server_list=(dev-worker-01 dev-worker-02 dev-worker-03 dev-worker-05 dev-worker-06 dev-worker-07 dev-worker-08 dev-worker-09)

all_server_list=(192.168.35.105 192.168.35.114 192.168.35.115 192.168.35.55 192.168.35.86 192.168.35.89 192.168.35.93 192.168.35.95 192.168.35.96 192.168.35.101 192.168.35.103 192.168.35.104 192.168.40.53 192.168.40.54 192.168.40.55)


all_server_list=(dev-worker-01 dev-worker-02 dev-worker-03 dev-worker-04 dev-worker-05 dev-worker-06 dev-worker-07 dev-worker-08 dev-worker-09)
for server in "${all_server_list[@]}"; do
    echo "server is ${server}"

    ssh root@"${server}" "timedatectl status"
done


count=1
for server in "${all_server_list[@]}";do
   echo "server is ${server}"


#   sshpass -p "scyd@lab1234" ssh root@"${server}" "echo \"root:tY\$@Go7jS#h2\" | chpasswd"
#
#   sshpass -p "scyd@lab1234" ssh root@"${server}" "echo \"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBO6IjOcco9eAvA/T7LDsylCgjKJlLrVXY1zxO1/mX/MTzVZGuAhbikFJT2ZN2Up8iED+pJwpcps3LlA1wOjQC3Q= root@ops-04.ecs.io\" >> /root/.ssh/authorized_keys"

#    host_name="dev-worker-0"${count}
#   ((count++))
#   echo "${server} $host_name" >> /root/wdd/1.txt
#   echo ""
#   ssh root@"${server}" "hostnamectl set-hostname $host_name"
#   ssh root@"${server}" "hostname"
#   echo ""

#    ssh root@"${server}" "echo yes"

#    ssh root@"${server}" "mkdir /root/wdd/"
#    scp /root/wdd/235.txt root@${server}:/root/wdd/234.txt
#    ssh root@"${server}" "cat /root/wdd/234.txt > /etc/ssh/sshd_config"
#    ssh root@"${server}" "systemctl restart sshd"


#   scp /root/wdd/* root@"${server}":/root/wdd/
#    ssh root@"${server}" "cat /root/wdd/1.txt >> /etc/hosts"

#    ssh root@"${server}" "echo \"nameserver 192.168.34.40\" > /etc/resolv.conf && echo \"nameserver 223.5.5.5\" >> /etc/resolv.conf"
#    ssh root@"${server}" "yum install -y net-tools iputils bind-utils lsof curl wget vim mtr htop"

#   ssh root@"${server}" "chmod +x /root/wdd/octopus-agent_linux_amd64 && echo selinux | /root/wdd/octopus-agent_linux_amd64 -mode=bastion  && echo swap | /root/wdd/octopus-agent_linux_amd64 -mode=bastion  && echo firewall | /root/wdd/octopus-agent_linux_amd64 -mode=bastion  && echo sysconfig | /root/wdd/octopus-agent_linux_amd64 -mode=bastion"

#   ssh root@"${server}" "echo ssh | /root/wdd/octopus-agent_linux_amd64 -mode=bastion  && echo docker | /root/wdd/octopus-agent_linux_amd64 -mode=bastion"
#  scp /etc/docker/daemon.json root@"${server}":/etc/docker/daemon.json
#  ssh root@"${server}" "echo \"192.168.92.185 harbor.cdcyy.com.cn\" >> /etc/hosts && systemctl restart docker"

#  ssh root@"${server}" "docker info"
#  ssh root@"${server}" "sed -i '/^$/d' /root/.ssh/id_ed25519"
#  ssh root@"${server}" "rm -rf /root/wdd/*"
#

#  ssh root@"${server}" "chmod +x /root/wdd/kubectl && chmod +x /root/wdd/rke && mv  /root/wdd/kubectl /usr/local/bin/kubectl && mv  /root/wdd/rke /usr/local/bin/rke"
#   scp /root/wdd/disk.sh root@"${server}":/root/wdd/disk.sh
#   ssh root@"${server}" "chmod +x /root/wdd/disk.sh && bash /root/wdd/disk.sh"

#    ssh root@"${server}" "docker login -u rad02_drone -p Drone@1234 harbor.cdcyy.com.cn"
#    ssh root@"${server}" "yum install -y nfs-utils rpcbind"
    ssh root@"${server}" "yum install -y chrony && systemctl start chronyd && systemctl enable chronyd"
#    ssh root@"${server}" "systemctl start nfs nfs-client nfs-common && systemctl enable nfs nfs-client nfs-common && systemctl status nfs nfs-client nfs-common -l | grep \"active (running)\""

# nfs 相关内容
#scp /etc/docker/daemon.json root@${server}:/etc/docker/daemon.json
# ssh root@"${server}" "sed -i \"/yfcsnfs.com/d\" /etc/hosts"
# ssh root@"${server}" "cat /etc/hosts"
ssh root@"${server}" "grep -qxF \"nameserver 192.168.34.40\" /etc/resolv.conf || echo \"nameserver 192.168.34.40\" >> /etc/resolv.conf"
ssh root@"${server}" "dig yfcsnfs.com"
ssh root@"${server}" "echo \n\n\n"


done

mv ctop-0.7.7-linux-amd64 /usr/local/bin/ctop
chmod +x /usr/local/bin/ctop