#!/bin/sh
#SERVICE_NAME必须是jar包

SERVICE_NAME=$1
SVC_HOME="/home/docker/$SERVICE_NAME"
mkdir -p ${SVC_HOME}
TEST_HOME="$SVC_HOME/test"
ENV=(dev test pre )


for i in  ${ENV[@]}
do
    ENV=$i
    mkdir  -p  ${SVC_HOME}/${ENV}
    echo ${SVC_HOME}/${ENV}
    mkdir  -p  ${SVC_HOME}/${ENV}/sh
    touch ${SVC_HOME}/${ENV}/sh/run.sh
    cp  /home/docker/default/Dockerfile  ${SVC_HOME}/${ENV}/
    cp  /home/docker/default/sh/run.sh  ${SVC_HOME}/${ENV}/sh/

    sed -i s/default/${SERVICE_NAME}/g   ${SVC_HOME}/${ENV}/Dockerfile
    sed -i s/default/${SERVICE_NAME}/g  ${SVC_HOME}/${ENV}/sh/run.sh
    sed -i s/env/${ENV}/g  ${SVC_HOME}/${ENV}/sh/run.sh
done

 
mkdir  -p  ${SVC_HOME}/prod/skywalking-agent
cp  -r /home/docker/default/skywalking-agent/*  ${SVC_HOME}/prod/skywalking-agent/
mkdir  -p  ${SVC_HOME}/prod/sh
cp   /home/docker/default/prod/sh/run.sh  ${SVC_HOME}/prod/sh/
sed -i   s/default/${SERVICE_NAME}/g  ${SVC_HOME}/prod/sh/run.sh 
cp   /home/docker/default/prod/Dockerfile     ${SVC_HOME}/prod/
sed -i   s/default/${SERVICE_NAME}/g  ${SVC_HOME}/prod/Dockerfile










