cd /home/clickadmin/dev3 && nohup java -jar /home/clickadmin/dev3/wac-1.0-SNAPSHOT.jar --spring.profiles.active=dev3 2>&1 &
cd /home/clickadmin/poc && nohup java -jar /home/clickadmin/poc/wac-1.0-SNAPSHOT.jar --spring.profiles.active=poc 2>&1 &
cd /home/clickadmin/prod && nohup java -jar /home/clickadmin/prod/wac-1.0-SNAPSHOT.jar --spring.profiles.active=prod 2>&1 &
cd /home/clickadmin/hangzhou && nohup java -jar /home/clickadmin/hangzhou/wac-1.0-SNAPSHOT.jar --spring.profiles.active=hangzhou 2>&1 &
#!/bin/bash
URL_DEV3_export_to_file="http://localhost:7080/export/toJson?path="
URL_DEV3_import_from_file="http://localhost:7080/import/fromJson?path="
URL_POC_export_to_file="http://localhost:8080/export/toJson?path="
URL_POC_import_from_file="http://localhost:8080/import/fromJson?path="
URL_PROD_export_to_file="http://localhost:9080/export/toJson?path="
URL_PROD_import_from_file="http://localhost:9080/import/fromJson?path="
URL_HANGZHOU_export_to_file="http://localhost:10080/export/toJson?path="
URL_HANGZHOU_import_from_file="http://localhost:10080/import/fromJson?path="
ENV_ARR=("dev3" "poc" "prod" "hangzhou")
CMD_ARR=("export_to_file" "import_from_file")
if [ $# -lt 3 ] ; then
echo "ERROR: please input parameter"
echo "Usage: sh $0 环境 指令 目标目录"
echo "环境:dev3 poc prod hangzhou"
echo "指令:export_to_file import_from_file"
echo "目标目录:已存在的目录"
exit
fi
#环境
ENV=$1
if echo "${ENV_ARR[@]}" | grep -w "$ENV" &>/dev/null; then
echo "环境:$ENV"
else
echo "ERROR: 请输入正确的环境:dev3 poc prod hangzhou"
exit
fi
#指令
CMD=$2
if echo "${CMD_ARR[@]}" | grep -w "$CMD" &>/dev/null; then
echo "指令:$CMD"
else
echo "ERROR: 请输入正确的指令:export_to_file import_from_file"
exit
fi
#目标目录
DIR=$3
if [ ! -d $DIR ];then
echo "ERROR: 目标目录$DIR 不存在"
exit
else
echo "目标目录:$DIR"
fi
case "$ENV" in
dev3)
if [ "$CMD" = "export_to_file" ]; then
echo $URL_DEV3_export_to_file$DIR
echo "正在执行中,请稍等"
curl $URL_DEV3_export_to_file$DIR
cat /home/clickadmin/dev3/nohup.out | grep com.wac.controller.ExportController | tail -n 2
else
echo $URL_DEV3_import_from_file$DIR
echo "正在执行中,请稍等"
curl $URL_DEV3_import_from_file$DIR
cat /home/clickadmin/dev3/nohup.out | grep com.wac.controller.ImportController | tail -n 7
fi
;;
poc)
if [ "$CMD" = "export_to_file" ]; then
echo $URL_POC_export_to_file$DIR
echo "正在执行中,请稍等"
curl $URL_POC_export_to_file$DIR
cat /home/clickadmin/poc/nohup.out | grep com.wac.controller.ExportController | tail -n 2
else
echo $URL_POC_import_from_file$DIR
echo "正在执行中,请稍等"
curl $URL_POC_import_from_file$DIR
cat /home/clickadmin/poc/nohup.out | grep com.wac.controller.ImportController | tail -n 7
fi
;;
prod)
if [ "$CMD" = "export_to_file" ]; then
echo $URL_PROD_export_to_file$DIR
echo "正在执行中,请稍等"
curl $URL_PROD_export_to_file$DIR
cat /home/clickadmin/prod/nohup.out | grep com.wac.controller.ExportController | tail -n 2
else
echo $URL_PROD_import_from_file$DIR
echo "正在执行中,请稍等"
curl $URL_PROD_import_from_file$DIR
cat /home/clickadmin/prod/nohup.out | grep com.wac.controller.ImportController | tail -n 7
fi
;;
hangzhou)
if [ "$CMD" = "export_to_file" ]; then
echo $URL_HANGZHOU_export_to_file$DIR
echo "正在执行中,请稍等"
curl $URL_HANGZHOU_export_to_file$DIR
cat /home/clickadmin/hangzhou/nohup.out | grep com.wac.controller.ExportController | tail -n 2
else
echo $URL_HANGZHOU_import_from_file$DIR
echo "正在执行中,请稍等"
curl $URL_HANGZHOU_import_from_file$DIR
cat /home/clickadmin/hangzhou/nohup.out | grep com.wac.controller.ImportController | tail -n 7
fi
;;
*)
echo "please input parameter" >&2
echo "Usage: $0 环境 指令 目标目录" >&2
echo "环境:dev3 poc prod hangzhou" >&2
echo "指令:export_to_file import_from_file" >&2
echo "目标目录:已存在的目录" >&2
exit 1
esac
测试:
导出:
sh command.sh hangzhou export_to_file /home/clickadmin/tmp/8
导入
sh command.sh hangzhou import_from_file /home/clickadmin/tmp/8