#!/bin/bash

install_path=$1
function remote_install_base() {
    IP_LIST_CLONE=(IP ${IP_LIST[@]})
    #string_check ${IP_LIST_CLONE[@]}
    for ip in ${IP_LIST[@]}; do
        echo "============"$ip
        echo $SSH_PORT
        echo ${SSH_OPT}
        USER=$(get_node_attribute "$REGION" $ip user)
        PASSWORD=$(get_node_attribute "$REGION" $ip password)
        echo ${USER}
        echo ${PASSWORD}
        sshpass scp -P $SSH_PORT -r "$install_path"/soft ${USER}@${ip}:/tmp/;
        sshpass scp -P $SSH_PORT -r "$install_path"/scripts ${USER}@${ip}:/tmp/; 
        #sshpass scp -P $SSH_PORT -r "$install_path"/Install_Packages/beats.metricbeat.6.7.1.tar ${USER}@${ip}:/tmp/;
        #sshpass scp -P $SSH_PORT -r "$install_path"/Install_Packages/minio.tar ${USER}@${ip}:/tmp/;

        sshpass scp -P $SSH_PORT -r "$install_path"/Install_Packages/ubuntu22.04_deb/* ${USER}@${ip}:/tmp/;

        sshpass scp -P $SSH_PORT -r /etc/hosts ${USER}@${ip}:/etc/;
        sleep 1
        sshpass ssh -p $SSH_PORT ${SSH_OPT} ${USER}@${ip} 'source /tmp/scripts/remote_env.sh && cat /tmp/scripts/remote_env.sh && source /tmp/scripts/base_ubuntu.sh';
    done
}

remote_install_base
