AdvisorServer/deploy_frontend.sh
2025-02-24 20:05:20 +08:00

41 lines
1.0 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 当前服务器上的文件路径
HTML_ZIP_FILE="/tmp/h5.zip /tmp/syAdmin.zip"
# 目标服务器信息格式IP地址:端口)
SERVERS=(
"172.26.1.9:22"
"172.26.1.15:22"
)
# 目标路径
TARGET_DIR="/home/ubuntu"
# 1. 循环拷贝文件到所有服务器
for SERVER in "${SERVERS[@]}"; do
# 获取 IP 和端口
IP=$(echo $SERVER | cut -d ':' -f 1)
PORT=$(echo $SERVER | cut -d ':' -f 2)
# 拷贝 JAR 文件到目标服务器
echo "Copying HTML_ZIP_FILE to $IP:$TARGET_DIR"
scp -P $PORT $HTML_ZIP_FILE ubuntu@$IP:$TARGET_DIR
done
echo "Files copied to all servers."
# 2. 所有文件拷贝完成后执行服务器上的release_html.sh
for SERVER in "${SERVERS[@]}"; do
# 获取 IP 和端口
IP=$(echo $SERVER | cut -d ':' -f 1)
PORT=$(echo $SERVER | cut -d ':' -f 2)
# 执行 release_html.sh 脚本
echo "Executing release_html.sh on $IP"
ssh -p $PORT ubuntu@$IP "sudo bash /home/ubuntu/release_html.sh"
done
echo "All html released."
echo "All tasks completed."