#!/bin/bash

minio_inner_ip_host=10.129.80.223:9000

download_ts2mp4_file(){
  echo ""
  wget https://oss.demo.uavcmlc.com/cmlc-installation/downloadfile/amd/ts2mp4_docker_image_v1.tar.gz
  echo ""
  echo ""
  echo ""
  wget https://oss.demo.uavcmlc.com/cmlc-installation/downloadfile/amd/pack_ts2mp4_release-0521.tar.gz
}

bootup_ts2mp4(){
  if [[ -f ts2mp4_docker_image_v1.tar.gz ]]; then
    echo "start to load ts2mp4 image file !"
    docker load -i ts2mp4_docker_image_v1.tar.gz
    echo ""


    echo "init ts2mp4 config!"
    tar -zvxf  pack_ts2mp4_x64-0724.tar.gz

    echo "start to modify!"
    sed -i "s/https:\/\/minio.ig-uat.uavcmlc.com:31500/http:\/\/$minio_inner_ip_host/g" $(pwd)/pack_ts2mp4_release/server_config_docker.ini
    bash $(pwd)/pack_ts2mp4_release/run_docker.sh

    sleep 3
    if docker ps | grep -q ts2mp4; then
        echo "ts2mp4 started successful !"
    else
        echo "ts2mp4 FAILED!"
    fi
  fi
}

#download_ts2mp4_file
bootup_ts2mp4