From ee957ecdadfc12d3807f12dfd9ac264ab2926312 Mon Sep 17 00:00:00 2001 From: liuxiaobo <1224730913@qq.com> Date: Fri, 30 May 2025 21:16:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/build.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/server/build.sh b/server/build.sh index 8e43fe6..1cbedc0 100644 --- a/server/build.sh +++ b/server/build.sh @@ -56,22 +56,31 @@ Username="ubuntu" Password="@qq20160101" RemotePath="/home/ubuntu/game" -REMOTE_SCRIPT_PATH="/home/ubuntu/game" -LocalFile=bin/$FILE - -# 传输文件到远程主机 -pscp -batch -pw "$Password" "$LocalFile" "$Username@$Host:$RemotePath" - +RemoteFile="$RemotePath/$FILE" +LocalFile="bin/$FILE" +plink -ssh -batch -pw "$Password" "$Username@$Host" "rm -f '$RemoteFile'" if [ $? -eq 0 ]; then - echo "文件上传成功" + echo "删除文件成功" else - echo "文件上传失败" + echo "删除文件失败" exit 1 fi +# 传输文件到远程主机 +pscp -batch -pw "$Password" -p "$LocalFile" "$Username@$Host:$RemotePath" && \ +plink -ssh -batch -pw "$Password" "$Username@$Host" "chmod +x '$RemoteFile'" + +if [ $? -eq 0 ]; then + echo "上传文件成功" +else + echo "上传文件失败" + exit 1 +fi + + # 远程执行脚本 -plink -ssh -batch -pw "$Password" "$Username@$Host" "bash $RemotePath" +plink -ssh -batch -pw "$Password" "$Username@$Host" "echo '$Password' | sudo -S supervisorctl restart $FILE" if [ $? -eq 0 ]; then echo "远程脚本执行成功"