Update duokai.sh
This commit is contained in:
parent
38956576aa
commit
8384998bcf
37
duokai.sh
37
duokai.sh
@ -19,7 +19,10 @@ read -p "输入你的身份码: " id
|
||||
read -p "请输入你想要创建的节点数量,单IP限制最多5个节点: " container_count
|
||||
|
||||
# 让用户输入想要分配的空间大小
|
||||
read -p "请输入你想要分配每个节点的存储空间大小(GB),单个上限64G,网页生效较慢,等待20分钟后,网页查询即可: " storage_gb
|
||||
read -p "请输入你想要分配每个节点的存储空间大小(GB),单个上限64G, 网页生效较慢,等待20分钟后,网页查询即可: " storage_gb
|
||||
|
||||
# 让用户输入存储路径(可选)
|
||||
read -p "请输入节点存储数据的宿主机路径(直接回车将使用默认路径 titan_storage_$i,依次数字顺延): " custom_storage_path
|
||||
|
||||
apt update
|
||||
|
||||
@ -27,7 +30,7 @@ apt update
|
||||
if ! command -v docker &> /dev/null
|
||||
then
|
||||
echo "未检测到 Docker,正在安装..."
|
||||
apt-get install ca-certificates curl gnupg lsb-release
|
||||
apt-get install ca-certificates curl gnupg lsb-release -y
|
||||
|
||||
# 安装 Docker 最新版本
|
||||
apt-get install docker.io -y
|
||||
@ -38,16 +41,23 @@ fi
|
||||
# 拉取Docker镜像
|
||||
docker pull nezha123/titan-edge:1.2
|
||||
|
||||
|
||||
# 创建用户指定数量的容器
|
||||
for i in $(seq 1 $container_count)
|
||||
do
|
||||
# 为每个容器创建一个存储卷
|
||||
storage="titan_storage_$i"
|
||||
mkdir -p "$storage"
|
||||
# 判断用户是否输入了自定义存储路径
|
||||
if [ -z "$custom_storage_path" ]; then
|
||||
# 用户未输入,使用默认路径
|
||||
storage_path="$PWD/titan_storage_$i"
|
||||
else
|
||||
# 用户输入了自定义路径,使用用户提供的路径
|
||||
storage_path="$custom_storage_path"
|
||||
fi
|
||||
|
||||
# 确保存储路径存在
|
||||
mkdir -p "$storage_path"
|
||||
|
||||
# 运行容器,并设置重启策略为always
|
||||
container_id=$(docker run -d --restart always -v "$PWD/$storage:/root/.titanedge/storage" --name "titan$i" nezha123/titan-edge:1.2)
|
||||
container_id=$(docker run -d --restart always -v "$storage_path:/root/.titanedge/storage" --name "titan$i" nezha123/titan-edge:1.2)
|
||||
|
||||
echo "节点 titan$i 已经启动 容器ID $container_id"
|
||||
|
||||
@ -57,15 +67,10 @@ do
|
||||
docker exec -it $container_id bash -c "\
|
||||
titan-edge bind --hash=$id https://api-test1.container1.titannet.io/api/v2/device/binding"
|
||||
|
||||
|
||||
# 等待足够时间以确保所有容器都已启动并且config.toml文件已经生成
|
||||
echo "等待所有容器启动并生成配置文件..."
|
||||
sleep 10
|
||||
|
||||
# 修改宿主机上的config.toml文件以设置StorageGB值
|
||||
docker exec $container_id bash -c "\
|
||||
sed -i 's/#StorageGB = .*/StorageGB = '$storage_gb'/' /root/.titanedge/config.toml && \
|
||||
echo '容器 titan$i 的存储空间已设置为 $storage_gb GB'"
|
||||
# 修改宿主机上的config.toml文件以设置StorageGB值
|
||||
docker exec $container_id bash -c "\
|
||||
sed -i 's/#StorageGB = .*/StorageGB = '$storage_gb'/' /root/.titanedge/config.toml && \
|
||||
echo '容器 titan$i 的存储空间已设置为 $storage_gb GB'"
|
||||
|
||||
done
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user