# 替换namespace
# 替换minio的实际地址和端口
# 修改rabbitmq的实际地址和端口，需要暴露出来

export tenant_name=lygga

mc alias set ${tenant_name} http://20.47.129.120:9000 cmii B#923fC7mk
 
mc mb ${tenant_name}/jadenq ${tenant_name}/tus ${tenant_name}/thumbnail ${tenant_name}/pub-cms ${tenant_name}/live-srs-hls/ ${tenant_name}/mission/ ${tenant_name}/surveillance ${tenant_name}/playback ${tenant_name}/tower ${tenant_name}/modelprocess ${tenant_name}/srs-hls  ${tenant_name}/live-cluster-hls
 
 
 
mc alias set demo https://oss.demo.uavcmlc.com:18000 cmii B#923fC7mk

export tenant_name=xmyd
need_to_sync_folder=("/jadenq/application/file/" "/pub-cms/application/img/" "/jadenq/scenariomock/xg/" "/jadenq/defimage/")
for folder in "${need_to_sync_folder[@]}"
do
   echo "start to sync => $folder"

   for file in $(mc ls "demo$folder" | awk '{print$6}' | tr "\n" " ")
   do
      echo "start to sync file from demo$folder$file to ${tenant_name}$folder$file"
      mc cp "demo$folder$file" "${tenant_name}$folder$file"
      echo ""
   done
done


mc admin config set ${tenant_name} notify_amqp:1 delivery_mode="2" exchange_type="direct" no_wait="off" queue_dir="" queue_limit="0"  url="amqp://admin:nYcRN91r._hj@20.47.129.118:35672" auto_deleted="off" durable="on" exchange="cmii.chinamobile.minio.event" internal="off" mandatory="off" routing_key="cmii.chinamobile.material.warehouse"
 
mc admin service restart ${tenant_name}

mc event add ${tenant_name}/mission       arn:minio:sqs::1:amqp  --event put
mc event add ${tenant_name}/modelprocess  arn:minio:sqs::1:amqp  --event put
mc event add ${tenant_name}/live-srs-hls  arn:minio:sqs::1:amqp  --event put
mc event add ${tenant_name}/live-cluster-hls  arn:minio:sqs::1:amqp  --event put
mc event add ${tenant_name}/playback      arn:minio:sqs::1:amqp  --event put
mc event add ${tenant_name}/surveillance      arn:minio:sqs::1:amqp  --event put
mc event add ${tenant_name}/tus           arn:minio:sqs::1:amqp  --event delete
mc ilm add --expiry-days "1" ${tenant_name}/tus