#!/usr/bin/env bash

#export array=(10.165.81.66 10.165.81.67 10.165.81.68 10.165.81.69 10.165.81.70 10.165.81.71 10.165.81.72 10.165.81.73 10.165.81.74 10.165.81.75 10.165.81.76 10.165.81.77 10.165.81.78 10.165.81.79 10.165.81.80 10.165.81.81 10.165.81.82 10.165.81.83 10.165.81.84 10.165.81.85)
10.165.81.77 10.165.81.78

openssl version -a

export array=(10.165.81.71)


for host in ${array[*]}; do

  echo "current host is : $host"

  ssh root@$host "apt remove -y  x11-common xdg-user-dirs firefox aspell gnome tcpdump openssl gnome-keyring libgcrypt20 && apt autoremove -y"

  ssh root@$host "sudo apt update && sudo apt upgrade -y"

done

export array=(10.165.81.71)
for host in ${array[*]}; do

  echo "current host is : $host"

  ssh root@"${host}" "mkdir tools && ls"

  scp -r /root/tools/* root@$host:/root/tools/

  ssh root@$host "sudo apt update && sudo apt upgrade -y && sudo apt install build-essential checkinstall zlib1g-dev -y"

  ssh root@$host "apt remove -y  x11-common xdg-user-dirs firefox aspell gnome tcpdump openssl gnome-keyring libgcrypt20 && apt autoremove -y"

  ssh root@$host "cd tools && tar -zvxf openssl-3.0.7.tar.gz && cd openssl-3.0.7 && ./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib && make && make install"

  ssh root@$host "ldconfig /usr/local/ssl/lib64 && ln -s /usr/local/ssl/bin/openssl /usr/local/bin/openssl && openssl version -a"

  ssh root@$host "sudo apt update && sudo apt upgrade -y"

done

apt remove -y  x11-common xdg-user-dirs firefox aspell gnome tcpdump gnome-keyring libgcrypt20 && apt autoremove -y && sudo apt update && sudo apt upgrade -y

# https://www.jianshu.com/p/f84ce238ce6c
# openssl modify

./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make && make install && ldconfig /usr/local/ssl/lib64
ln -s /usr/local/bin/openssl /usr/bin/openssl

#cat > /etc/ld.so.conf.d/openssl-3.0.7.conf<<EOF
#/usr/local/bin/ssl/lib64
#EOF
#ldconfig -v

export array=(10.165.81.67)

for host in ${array[*]}; do
  echo "current host is : $host"

  ssh root@"${host}" "mkdir tools && ls"
done
