mirror of
https://github.com/xubiaolin/docker-zerotier-planet.git
synced 2025-01-22 20:58:14 -05:00
feat: 🎸 使用ubuntu镜像,修复ping不通的bug
This commit is contained in:
parent
bc70c90547
commit
1177c234e4
10
Dockerfile
10
Dockerfile
@ -1,10 +1,8 @@
|
|||||||
FROM alpine:latest
|
FROM ubuntu:latest
|
||||||
|
ENV TZ=Asia/Shanghai \
|
||||||
|
DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
ADD ./init.sh /app/
|
Add . /app
|
||||||
ADD ./gen_world.sh /app/
|
|
||||||
ADD ./patch /opt/patch/
|
|
||||||
|
|
||||||
VOLUME ["/var/lib/zerotier-one/"]
|
|
||||||
|
|
||||||
RUN cd /app && sh init.sh
|
RUN cd /app && sh init.sh
|
||||||
|
|
||||||
|
@ -15,11 +15,4 @@ docker build --network host -t $imageName .
|
|||||||
echo "启动服务"
|
echo "启动服务"
|
||||||
for i in $(lsof -i:9993 -t);do kill -2 $i;done
|
for i in $(lsof -i:9993 -t);do kill -2 $i;done
|
||||||
docker run -d --network host --name $imageName -p 3443:3443 -p 9993:9993 -p 9993:9993/udp --restart unless-stopped $imageName
|
docker run -d --network host --name $imageName -p 3443:3443 -p 9993:9993 -p 9993:9993/udp --restart unless-stopped $imageName
|
||||||
|
docker cp zerotier-planet:/app/bin/planet /opt/planet
|
||||||
sleep 10s
|
|
||||||
echo "生成世界"
|
|
||||||
docker exec -it $imageName sh /app/gen_world.sh
|
|
||||||
docker cp $imageName:/opt/ZeroTierOne/attic/world/world.bin /opt/planet
|
|
||||||
|
|
||||||
echo "------------------"
|
|
||||||
echo "现在已经配置好了,planet文件在/opt/planet, 客户端连接时需要替换该planet"
|
|
||||||
|
14
gen_world.sh
14
gen_world.sh
@ -1,14 +0,0 @@
|
|||||||
cd /var/lib/zerotier-one && zerotier-idtool initmoon identity.public > moon.json
|
|
||||||
|
|
||||||
# 添加补丁
|
|
||||||
cd /opt/patch && python3 patch.py
|
|
||||||
cd /var/lib/zerotier-one && zerotier-idtool genmoon moon.json && mkdir moons.d && cp ./*.moon ./moons.d
|
|
||||||
|
|
||||||
# 生成世界
|
|
||||||
cd /opt/ZeroTierOne/attic/world/
|
|
||||||
sh build.sh
|
|
||||||
sleep 5s
|
|
||||||
./mkworld
|
|
||||||
|
|
||||||
ps -ef |grep 'zerotier-one -d' |grep -v grep |awk '{print $1}' |xargs kill -9
|
|
||||||
zerotier-one -d
|
|
47
init.sh
Normal file → Executable file
47
init.sh
Normal file → Executable file
@ -1,16 +1,43 @@
|
|||||||
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
|
echo "update source"
|
||||||
apk update
|
echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
|
||||||
apk add git python3 nodejs npm make g++ linux-headers zerotier-one
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
|
||||||
|
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse"> /etc/apt/sources.list
|
||||||
|
apt update
|
||||||
|
apt upgrade -y
|
||||||
|
apt install -y tzdata
|
||||||
|
ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime
|
||||||
|
echo ${TZ} > /etc/timezone
|
||||||
|
dpkg-reconfigure --frontend noninteractive tzdata
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
apt update
|
||||||
|
apt install git python3 npm make curl -y
|
||||||
npm config set registry http://registry.npm.taobao.org && npm install -g node-gyp
|
npm config set registry http://registry.npm.taobao.org && npm install -g node-gyp
|
||||||
|
curl -s https://install.zerotier.com | bash
|
||||||
|
cd /opt && git clone -v http://gh-proxy.markxu.vip/https://github.com/key-networks/ztncui.git
|
||||||
|
cd /opt && git clone -v http://gh-proxy.markxu.vip/https://github.com/zerotier/ZeroTierOne.git
|
||||||
|
|
||||||
echo "下载源码中,源码文件较大,请耐心等待;如果源码下载失败,请重新执行该脚本"
|
cd /opt/ztncui/src
|
||||||
# 下载源码
|
npm install
|
||||||
cd /opt && git clone http://gh-proxy.markxu.vip/https://github.com/key-networks/ztncui.git
|
|
||||||
cd /opt && git clone http://gh-proxy.markxu.vip/https://github.com/zerotier/ZeroTierOne.git
|
|
||||||
|
|
||||||
# 配置ztncui
|
|
||||||
cd /opt/ztncui/src && npm install argon2 && npm install
|
|
||||||
cp -pv ./etc/default.passwd ./etc/passwd
|
cp -pv ./etc/default.passwd ./etc/passwd
|
||||||
echo 'HTTP_PORT=3443' >.env
|
echo 'HTTP_PORT=3443' >.env
|
||||||
echo 'NODE_ENV=production' >>.env
|
echo 'NODE_ENV=production' >>.env
|
||||||
echo 'HTTP_ALL_INTERFACES=true' >>.env
|
echo 'HTTP_ALL_INTERFACES=true' >>.env
|
||||||
|
|
||||||
|
cd /var/lib/zerotier-one && zerotier-idtool initmoon identity.public > moon.json
|
||||||
|
cd /app/patch && python3 patch.py
|
||||||
|
cd /var/lib/zerotier-one && zerotier-idtool genmoon moon.json && mkdir moons.d && cp ./*.moon ./moons.d
|
||||||
|
cd /opt/ZeroTierOne/attic/world/ && sh build.sh
|
||||||
|
sleep 5s
|
||||||
|
|
||||||
|
cd /opt/ZeroTierOne/attic/world/ && ./mkworld
|
||||||
|
mkdir /app/bin -p && cp world.bin /app/bin/planet
|
||||||
|
|
||||||
|
service zerotier-one restart
|
||||||
|
@ -10,7 +10,7 @@ def get_moon():
|
|||||||
|
|
||||||
|
|
||||||
def get_patch():
|
def get_patch():
|
||||||
with open("/opt/patch/patch.json", "r") as f:
|
with open("/app/patch/patch.json", "r") as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ def patch():
|
|||||||
text += f'\n roots.back().stableEndpoints.push_back(InetAddress("{i}"));'
|
text += f'\n roots.back().stableEndpoints.push_back(InetAddress("{i}"));'
|
||||||
|
|
||||||
# 生成文件
|
# 生成文件
|
||||||
with open("/opt/patch/mkworld.cpp", "r") as cpp:
|
with open("/app/patch/mkworld.cpp", "r") as cpp:
|
||||||
world = "".join(cpp.readlines())
|
world = "".join(cpp.readlines())
|
||||||
world = world.replace("//__PATCH_REPLACE__", text)
|
world = world.replace("//__PATCH_REPLACE__", text)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user