优化脚本

This commit is contained in:
liuxiaobo 2025-05-30 21:16:41 +08:00
parent ce86475eb9
commit ee957ecdad

View File

@ -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 "远程脚本执行成功"