#!/bin/bash

target_host="192.168.35.71"
gzip_folder_prefix="/root/octopus_image"

fetch_all_dep_gzip_file() {

  mkdir -p $gzip_folder_prefix/middle/
  mkdir -p $gzip_folder_prefix/rke/

  echo "start to scp all middle gzip file!"
  scp -r -P 22 root@"${target_host}":$gzip_folder_prefix/middle/ $gzip_folder_prefix/
  echo ""
  echo "start to scp all rke gzip file!"
  scp -r -P 22 root@"${target_host}":$gzip_folder_prefix/rke/ $gzip_folder_prefix/
  echo ""

  ls "$gzip_folder_prefix/middle/"
  echo ""
  ls "$gzip_folder_prefix/rke/"
  echo ""

}

fetch_project_gzip_file() {
  local project_name="$1"
  if [ "$project_name" == "" ]; then
    echo "[fetch_project_gzip_file] no project name specific ! exits! ${project_name}"
    return
  fi

  mkdir -p "$gzip_folder_prefix/${project_name}/"
  echo "start to scp all ${project_name} gzip file!"
  scp -r -P 22 root@"${target_host}":$gzip_folder_prefix/"${project_name}"/ $gzip_folder_prefix/"${project_name}"/
  echo ""

  echo ""
  ls $gzip_folder_prefix/"${project_name}"/*
  echo ""
}

#fetch_all_dep_gzip_file
fetch_project_gzip_file "cqga"