#!/bin/bash

# 容器名称列表
containers=("titan5" "titan4" "titan3" "titan2" "titan1")

# 待修改的文件路径
file_path="/root/.titanedge/config.toml"

# 待替换的字符串
old_string='#ListenAddress = "0.0.0.0:1234"'
new_string='ListenAddress = "0.0.0.0:1234"'

# 循环处理每个容器
for container in "${containers[@]}"; do
    # 在容器中执行 sed 命令修改文件内容
    docker exec "$container" sed -i "s/$old_string/$new_string/" "$file_path"
    # 输出结果
    echo "已将容器 $container 中的文件 $file_path 中的 $old_string 替换为 $new_string"
done
