jaikuai hai 6 meses
pai
achega
f9a1e99d6d
Modificáronse 1 ficheiros con 73 adicións e 1 borrados
  1. 73 1
      init-per.sh

+ 73 - 1
init-per.sh

@@ -15,6 +15,77 @@ else
   port="0$2"
 fi
 
+# 判断组网服务
+create_one=false
+if ! sudo docker ps -q -f name="one" | grep -q .; then
+    create_one=true
+else
+    read -p "One容器已经存在,是否删除? (y/n): " confirm_one
+    # 判断用户的回答
+    if [ "$confirm_one" == "y" ] || [ "$confirm_one" == "Y" ]; then
+        sudo docker rm -f one
+        create_one=true
+    fi
+fi
+if $create_one; then
+DIR="/opt/zerotier-one"
+if [ -d "$DIR" ]; then
+  # 如果目录存在,则删除
+  sudo rm -rf "$DIR"
+fi
+sudo mkdir "$DIR"
+sudo docker run -d --restart always --name one --device /dev/net/tun --net host --cap-add NET_ADMIN --cap-add SYS_ADMIN -v /opt/zerotier-one:/var/lib/zerotier-one henrist/zerotier-one
+sleep 3
+sudo rm -f /opt/zerotier-one/planet && sudo wget http://git.fast-fun.cn:92/ruili-station/readme/raw/master/planet -P /opt/zerotier-one
+sudo docker restart one
+sudo docker exec one zerotier-cli join 2eb45e6989f9a0d2
+member_id=$(sudo docker exec one zerotier-cli status)
+access_token="c15b57c30df2efede131f460e84a80d8c008bb3365031a175d3efe42105ba6f9"
+dingtalk_api="https://oapi.dingtalk.com/robot/send?access_token=$access_token"
+message="告警:新的站需要组网 $member_id, 需要指定位 http://10.10.64.1:9443/ 站点编号: $proj "
+curl -H "Content-Type: application/json" -d "{\"msgtype\": \"text\", \"text\": {\"content\": \"$message\"},\"at\": {\"atMobiles\": [\"13452319860\"]}}" $dingtalk_api
+fi
+fi
+
+# 联网端口
+create_ha=false
+if ! sudo docker ps -q -f name="ha" | grep -q .; then
+    create_ha=true
+else
+    read -p "Ha容器已经存在,是否删除? (y/n): " confirm_ha
+    # 判断用户的回答
+    if [ "$confirm_ha" == "y" ] || [ "$confirm_ha" == "Y" ]; then
+        sudo docker rm -f ha
+        create_ha=true
+    fi
+fi
+if $create_one; then
+sudo docker run -d -p 6667:6667 -p 20-21:20-21 -p 21100-21110:21100-21110 -p 554:554 -p 10166:10166 -p 98:98 -p 200:200 --name=ha --restart=always nas.fast-fun.cn:5000/zk/ha:0.21
+fi
+
+
+# 联网端口
+create_ptr=false
+if ! sudo docker ps -q -f name="portainer_agent" | grep -q .; then
+    create_ptr=true
+else
+    read -p "Ptr容器已经存在,是否删除? (y/n): " confirm_ptr
+    # 判断用户的回答
+    if [ "$confirm_ptr" == "y" ] || [ "$confirm_ptr" == "Y" ]; then
+        sudo docker rm -f ha
+        create_ptr=true
+    fi
+fi
+if $create_ptr; then
+ sudo docker run -d \
+  -p 9001:9001 \
+  --name portainer_agent \
+  --restart=always \
+  -v /var/run/docker.sock:/var/run/docker.sock \
+  -v /var/lib/docker/volumes:/var/lib/docker/volumes \
+  portainer/agent:2.19.1
+fi
+
 # 判断内网穿透服务
 create_frpc=false
 if ! sudo docker ps -q -f name="frpc" | grep -q .; then
@@ -152,4 +223,5 @@ EOF
 sudo chmod a+x vpn-user.sh
 echo "# 执行 ./vpn-user.sh 即可生成客户端配置文件."
 echo "# bash vpn-user.sh hzw,jxt"
-fi
+fi
+sudo docker exec one zerotier-cli status