fusenapi/change_port.sh
2023-07-10 13:07:59 +08:00

30 lines
881 B
Bash

#!/bin/bash
# 定义一个函数来修改每个服务器的配置文件中的端口
change_port() {
server_name=$1
port=$2
config_file="server/${server_name}/etc/${server_name}.yaml"
echo "Changing port for $server_name to $port"
if [ -f "$config_file" ]; then
# 使用 sed 将 Port 替换为新的端口
sed -i "s/^Port: .*$/Port: $port/" "$config_file"
else
echo "Configuration file $config_file not found"
fi
}
# 列出所有服务器目录
server_dirs=("backend" "canteen" "data-transfer" "home-user-auth" "inventory" "map-library" "orders" "product" "product-model" "product-template" "shopping-cart-confirmation" "upload" "webset")
# 初始化端口为 9901
port=9901
# 遍历服务器目录,修改每个服务器的配置文件中的端口
for server_dir in "${server_dirs[@]}"; do
change_port $server_dir $port
port=$((port + 1))
done