#!/bin/bash


all_server_list=(192.168.0.10)

all_server_list=(192.168.0.9 192.168.0.10 192.168.0.11 192.168.0.65 192.168.0.45 192.168.0.7)

all_server_list=(192.168.0.83 192.168.0.84 192.168.0.85)

for server in "${all_server_list[@]}";do
  echo "server is ${server}"
 
  ssh ${server} "echo yes"
  ssh ${server} "curl -s 10.74.32.6"
  
  echo ""
done

kubectl taint nodes 192.168.0.9 key=experimental:NoSchedule
kubectl taint nodes 192.168.0.10 key=experimental:NoSchedule
kubectl taint nodes 192.168.0.11 key=experimental:NoSchedule

kubectl cordon 192.168.0.9
kubectl cordon 192.168.0.10
kubectl cordon 192.168.0.11


scp /root/.ssh/* root@${server}:/root/.ssh/

ssh root@${server} "mkdir /root/wdd"
scp /usr/local/bin/octopus-agent root@${server}:/usr/local/bin/octopus-agent
ssh root@${server} "chmod +x /usr/local/bin/octopus-agent"
ssh root@${server} "printf 'ssh\n' | octopus-agent --mode=bastion"

scp /root/wdd/disk.sh root@${server}:/root/wdd/disk.sh
ssh root@${server} "bash /root/wdd/disk.sh" 

ssh root@${server} "mkdir /root/wdd"
scp /usr/local/bin/octopus-agent root@${server}:/usr/local/bin/octopus-agent
ssh root@${server} "chmod +x /usr/local/bin/octopus-agent"
ssh root@${server} "printf 'ssh\n' | octopus-agent --mode=bastion"

scp /root/wdd/docker-amd64-20.10.15.tgz root@${server}:/root/wdd/
scp /root/wdd/docker-compose-linux-x86_64-v2.18.0  root@${server}:/root/wdd/
ssh root@${server} "printf 'firewall\n' | octopus-agent --mode=bastion"
ssh root@${server} "printf 'sysconfig\n' | octopus-agent --mode=bastion"
ssh root@${server} "printf 'swap\n' | octopus-agent --mode=bastion"
ssh root@${server} "printf 'selinux\n' | octopus-agent --mode=bastion"
ssh root@${server} "printf 'docker\n' | octopus-agent --mode=bastion"
ssh root@${server} "printf 'dockercompose\n' | octopus-agent --mode=bastion"


scp /etc/docker/daemon.json root@${server}:/etc/docker/

ssh root@${server} "systemctl restart docker && sleep 3 && docker info"

echo "SuperRke.123
SuperRke.123
" | passwd rke-installer


ssh root@${server} "useradd rke-installer"
ssh root@${server} "mkdir /home/rke-installer"
ssh root@${server} "mkdir /home/rke-installer/.ssh "
scp /home/rke-installer/.ssh/* root@${server}:/home/rke-installer/.ssh/
ssh root@${server} "chown rke-installer:rke-installer -R /home/rke-installer"
ssh root@${server} "usermod -d /home/rke-installer rke-installer"

ssh root@${server} "gpasswd -a rke-installer docker"
ssh root@${server} "newgrp docker"


echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCrEuk9I6spsHv03cSFQmhx0HZ90VBtqBCGlaisasJAK7wkam/AStAvB8Svn6GiNyJFp/vTr2C8MN01poJQ2pWVmj+WcIWVdbrwYmvIsLC6A4dtdxGOEj5Oejzod9JavAwz+EhTjy61T1Xyc7LSafYNtfrir7X7rCZhSN+GhdD9nN0TFbpLax4t84QDU8+dyALzmGEzbPKFZ2BBpbiNu8I0nheRojMdvwCIjV/c+RNEwXKOOk4EXch9mW4HJJ/n36mfC6Dq3CaDaX+IGuK/lgim2wDQFUFfeGWSgiERDZN2sFyxeyliBL39J7gQFXFcVXud+TCujKgpdzmyb+AulKFrUja2kSoA8CLmyiaRkha6SQXkaT/+KVE2q8mNeA6DDxlRR3rBB8MHJ6IKz1+SgwIip8t/ybgthmkBbFWXvjVfIK3cfmMaxqLTlJNEhngLRItLxOa96GivCSziY8CNidWlL4ekC4WF8X+zseBhnFCPG1hmbi4bMcw86CTIFgNhc20= rke-installer@master-node" >>/home/rke-installer/.ssh/authorized_keys

sed -i "s/\/data/\/var/lib/docker/g" /etc/fstab

umount /data
mount -a 
df -TH