From c2db71d041d484bf5df5321dc6a04c0a1341a177 Mon Sep 17 00:00:00 2001 From: Shaun Chyxion Date: Mon, 4 Jan 2021 00:35:11 +0800 Subject: [PATCH] update deploy --- deploy.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 13549554..6421e377 100755 --- a/deploy.sh +++ b/deploy.sh @@ -20,15 +20,19 @@ deploy_server() { local app="$2" local jar="$3" local port="$4" + local srv_dir="$5" if [ -z "$port" ]; then port='22' fi + if [ -z "$srv_dir" ]; then + srv_dir="$app" + fi - local target_dir="/data/program/$app" + local target_dir="/data/program/$srv_dir" local target_jar="$target_dir/lib/main.jar" scp -P $port $jar $server:"${target_jar}_new" ssh -p $port $server "$target_dir/bin/stop.sh; - mv $target_jar {$target_jar}_prev; + mv $target_jar ${target_jar}_prev; mv ${target_jar}_new $target_jar && $target_dir/bin/start.sh" } @@ -66,9 +70,10 @@ if [ "$2" == "test" ]; then deploy_server 'xiadou@118.24.251.131' $APP $JAR elif [ "$2" == "prod" ]; then echo "Deploy prod." - deploy_server 'xiandou@localhost' $APP $JAR '4025' + PORT=4026 + deploy_server 'xiandou@localhost' $APP $JAR $PORT if [ "$1" == "cms" ]; then - ssh -p 4025 xiandou@localhost '/data/program/cms2/bin/stop.sh && /data/program/cms2/bin/start.sh' + ssh -p $PORT xiandou@localhost '/data/program/cms2/bin/stop.sh && /data/program/cms2/bin/start.sh' fi fi