update-readme (#109)
* 重构 * 重构 * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * tmp * xx * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * no sense * t * finish image build * fix * addmenu * addmenu * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * finishscript * update-readme --------- Co-authored-by: ubuntu <ubuntu@localhost.localdomain> Co-authored-by: xubiaolin <xubiaolin2014> Co-authored-by: root <root@localhost.localdomain>
88
README.md
@ -17,6 +17,7 @@ QQ交流群:692635772
|
||||
- [3.4 下载 `planet` 文件](#34-下载-planet-文件)
|
||||
- [3.5 新建网络](#35-新建网络)
|
||||
- [3.5.1 创建网络](#351-创建网络)
|
||||
- [3.5.2 分配网络IP:](#352-分配网络ip)
|
||||
- [4.客户端配置](#4客户端配置)
|
||||
- [4.1 Windows 配置](#41-windows-配置)
|
||||
- [4.2 加入网络](#42-加入网络)
|
||||
@ -34,9 +35,11 @@ QQ交流群:692635772
|
||||
- [5. PVE lxc 容器没有创建网卡](#5-pve-lxc-容器没有创建网卡)
|
||||
- [6. 管理后台忘记密码怎么办:](#6-管理后台忘记密码怎么办)
|
||||
- [开发计划](#开发计划)
|
||||
- [7. 为什么连不上planet](#7-为什么连不上planet)
|
||||
- [8. 如何判断是直连还是中转](#8-如何判断是直连还是中转)
|
||||
- [9. 为什么我的zerotier传输不稳定](#9-为什么我的zerotier传输不稳定)
|
||||
- [风险声明](#风险声明)
|
||||
- [类似项目](#类似项目)
|
||||
- [推广](#推广)
|
||||
- [捐助和支持](#捐助和支持)
|
||||
|
||||
# 0: 广告
|
||||
@ -47,12 +50,21 @@ QQ交流群:692635772
|
||||
月付低至10¥,年付低至100¥
|
||||
带宽|流量|费用(每月)|
|
||||
-|-|-
|
||||
<<<<<<< HEAD
|
||||
5Mbit|100G|10¥
|
||||
10Mbit|100G|18¥
|
||||
30Mbit|100G|38¥
|
||||
50Mbit|100G|58¥
|
||||
100Mbit|100G|98¥
|
||||
200Mbit|100G|168¥
|
||||
=======
|
||||
3Mbit|100G|10¥
|
||||
10Mbit|100G|15¥
|
||||
30Mbit|100G|20¥
|
||||
50Mbit|100G|25¥
|
||||
100Mbit|100G|50¥
|
||||
200Mbit|100G|100¥
|
||||
>>>>>>> cfa3ae2054852a51e7e36f75a16e7de1c2ec95eb
|
||||
|
||||
流量超出后10¥可购买100G
|
||||
|
||||
@ -137,34 +149,26 @@ cd docker-zerotier-planet
|
||||
```
|
||||
欢迎使用zerotier-planet脚本,请选择需要执行的操作:
|
||||
1. 安装
|
||||
2. 更新
|
||||
其他任意键退出
|
||||
|
||||
2. 卸载
|
||||
3. 更新
|
||||
4. 查看信息
|
||||
5. 退出
|
||||
请输入数字:
|
||||
```
|
||||
|
||||
整个脚本预计需要 3-10 分钟,具体需要看网络与机型
|
||||
整个脚本预计需要 1-3 分钟,具体需要看网络与机型
|
||||
|
||||
|
||||
当您看到类似如下字样时,表示安装成功
|
||||
```
|
||||
启动服务
|
||||
3b59df95edabeabbf19aa6605b28704608710719bdf7c6e7612d75d01ede8f48
|
||||
Preparing to copy...
|
||||
Copying from container - 512B
|
||||
Copying from container - 769B
|
||||
Copying from container - 1.024kB
|
||||
Copying from container - 1.536kB
|
||||
Successfully copied 2.048kB to /tmp/planet
|
||||
planet文件路径为 /tmp/planet
|
||||
planet server端口为: 9994, 请在防火墙放行该端口的tcp和udp协议
|
||||
enjoy~
|
||||
```
|
||||
![install-finish](./asserts/install_finish.png)
|
||||
|
||||
|
||||
## 3.4 下载 `planet` 文件
|
||||
脚本运行完成后,会在 `/tmp/` 目录下有个 `planet` 文件
|
||||
脚本运行完成后,会在 `/data/zerotier/dist` 目录下有个 `planet`和`moon` 文件
|
||||
|
||||
下载该文件以备用
|
||||
可以直接访问安装完成后的url下载,也可以用scp等其他方式下载
|
||||
|
||||
下载文件备用
|
||||
|
||||
## 3.5 新建网络
|
||||
访问 `http://ip:3443` 进入controller页面
|
||||
@ -186,6 +190,12 @@ enjoy~
|
||||
|
||||
![ui](asserts/ztncui_net_id.png)
|
||||
|
||||
### 3.5.2 分配网络IP:
|
||||
选中easy setup
|
||||
![assign_id](./asserts/easy_setup.png)
|
||||
|
||||
生成ip范围
|
||||
![ip_addr](./asserts/network_addr.png)
|
||||
|
||||
# 4.客户端配置
|
||||
客户端主要为Windows, Mac, Linux, Android
|
||||
@ -214,10 +224,14 @@ PS C:\Windows\system32> zerotier-cli.bat join 网络id(就是在网页里面创
|
||||
PS C:\Windows\system32>
|
||||
```
|
||||
|
||||
登录管理后台可以看到有个个新的客户端,勾选Authorized就行
|
||||
登录管理后台可以看到有个个新的客户端,勾选`Authorized`就行
|
||||
|
||||
![ui](asserts/join_net.png)
|
||||
|
||||
IP assignment 里面会出现zerotier的内网ip
|
||||
|
||||
![ip](./asserts/allow_devices.png)
|
||||
|
||||
执行如下命令:
|
||||
```
|
||||
PS C:\Windows\system32> zerotier-cli.bat peers
|
||||
@ -243,7 +257,7 @@ PS C:\Windows\system32>
|
||||
7. `zerotier-cli peers` 可以看到` planet` 角色
|
||||
|
||||
## 4.3 安卓客户端配置
|
||||
[Zerotier 非官方安卓客户端发布:支持自建 Moon 节点 - V2EX](https://www.v2ex.com/t/768628)
|
||||
[Zerotier 非官方安卓客户端](https://github.com/kaaass/ZerotierFix)
|
||||
|
||||
## 4.4 MacOS 客户端配置
|
||||
步骤如下:
|
||||
@ -340,9 +354,24 @@ lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
|
||||
# 开发计划
|
||||
🥰您的捐助可以让开发计划的速度更快🥰
|
||||
- [ ] 多planet支持
|
||||
- [ ] 3443端口自定义支持
|
||||
- [x] 3443端口自定义支持
|
||||
- [ ] planet和controller分离部署
|
||||
|
||||
## 7. 为什么连不上planet
|
||||
请检查防火墙,如果是阿里云、腾讯云用户,需要在对应平台后台防火墙放行端口。linux机器上也要放行,如果安装了ufw等防火墙工具。
|
||||
|
||||
## 8. 如何判断是直连还是中转
|
||||
管理员权限执行终端,运行`zerotier-cli peers`
|
||||
```
|
||||
<ztaddr> <ver> <role> <lat> <link> <lastTX> <lastRX> <path>
|
||||
69c0d507d0 - LEAF -1 RELAY
|
||||
93caa675b0 1.12.2 PLANET -894 DIRECT 4142 4068 110.42.99.46/9994
|
||||
ab403e2074 1.10.2 LEAF -1 RELAY
|
||||
```
|
||||
如果你的ztaddr是REPLAY, 就说明是中转
|
||||
|
||||
## 9. 为什么我的zerotier传输不稳定
|
||||
由于zerotier使用的是udp协议,部分地区可能对udp进行了qos, 可以考虑使用openvpn。
|
||||
|
||||
# 风险声明
|
||||
|
||||
@ -352,14 +381,15 @@ lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
|
||||
# 类似项目
|
||||
- [wireguard一键脚本](https://github.com/xubiaolin/wireguard-onekey)
|
||||
|
||||
# 推广
|
||||
京东云主机,安全稳定,性能强劲,新客下单专享特惠
|
||||
|
||||
【金秋大促】爆款云主机2核2G3M低至66元首年,优惠直达链接:
|
||||
https://daili.jd.com/s?linkNo=XF2RVUILETHMCX7BGKAFQHBG2JUUE7S76XQIWTR74W3LQQS6OLTQM5XEITBWPC4WZA6UGATAQLY674QVVELZCIABN4
|
||||
|
||||
# 捐助和支持
|
||||
|
||||
如果觉得本项目对您有帮助,欢迎通过扫描下方赞赏码捐助项目 :)
|
||||
|
||||
<img src="asserts/donate.jpg" alt="donate" width="400" height="400" />
|
||||
<img src="asserts/donate.png" alt="donate" width="400" height="400" />
|
||||
|
||||
<hr>
|
||||
|
||||
<img src='asserts/alipay.jpg' alt='alipay' width='400' height='400'>
|
||||
|
||||
复制 852129070 🏮搭开..🏮支付宝去搜索,✔`ho n`g 笣✔送喜庆,幸示 畐到心
|
BIN
asserts/alipay.jpg
Normal file
After Width: | Height: | Size: 339 KiB |
BIN
asserts/allow_devices.png
Normal file
After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 104 KiB |
BIN
asserts/donate.png
Normal file
After Width: | Height: | Size: 233 KiB |
BIN
asserts/easy_setup.png
Normal file
After Width: | Height: | Size: 91 KiB |
BIN
asserts/install_finish.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
asserts/network_addr.png
Normal file
After Width: | Height: | Size: 97 KiB |
319
deploy.sh
@ -1,108 +1,249 @@
|
||||
#!/bin/bash
|
||||
|
||||
imageName="zerotier-planet"
|
||||
|
||||
function install(){
|
||||
echo "开始安装,如果你已经安装了,将会删除旧的数据,10s后开始安装..."
|
||||
sleep 10
|
||||
|
||||
#安装lsof工具
|
||||
if [ ! -f "/usr/bin/lsof" ]; then
|
||||
echo "开始安装lsof工具..."
|
||||
#debian
|
||||
if [ -f "/usr/bin/apt" ]; then
|
||||
apt update
|
||||
apt install -y lsof
|
||||
fi
|
||||
#centos
|
||||
if [ -f "/usr/bin/yum" ]; then
|
||||
yum install -y lsof
|
||||
fi
|
||||
fi
|
||||
|
||||
docker rm -f myztplanet
|
||||
rm -f /data/zerotier
|
||||
|
||||
ZT_PORT=9994
|
||||
API_PORT=3443
|
||||
FILE_PORT=3000
|
||||
|
||||
read -p "请输入zerotier-planet要使用的端口号,例如9994: " ZT_PORT
|
||||
#port必须是数字
|
||||
while [[ ! "$ZT_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " ZT_PORT
|
||||
done
|
||||
|
||||
read -p "是否自动获取公网IP地址?(y/n)" use_auto_ip
|
||||
|
||||
if [[ "$use_auto_ip" =~ ^[Yy]$ ]]; then
|
||||
ipv4=$(curl -s https://ipv4.icanhazip.com/)
|
||||
ipv6=$(curl -s https://ipv6.icanhazip.com/)
|
||||
|
||||
echo "获取到的IPv4地址为: $ipv4"
|
||||
echo "获取到的IPv6地址为: $ipv6"
|
||||
|
||||
read -p "是否使用上面获取到的IP地址?(y/n)" use_auto_ip_result
|
||||
|
||||
if [[ "$use_auto_ip_result" =~ ^[Nn]$ ]]; then
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
else
|
||||
|
||||
# 要求用户手动输入IP地址
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
|
||||
# 输出使用的端口号和IP地址
|
||||
ipv4_entry="${ipv4}/${port}"
|
||||
if [[ -n "$ipv6" ]]; then
|
||||
ipv6_entry="${ipv6}/${port}"
|
||||
endpoints="[\"$ipv4_entry\",\"$ipv6_entry\"]"
|
||||
else
|
||||
endpoints="[\"$ipv4_entry\"]"
|
||||
fi
|
||||
echo "{\"stableEndpoints\":$endpoints}" > ./patch/patch.json
|
||||
|
||||
echo "配置内容为:"
|
||||
echo "`cat ./patch/patch.json`"
|
||||
|
||||
echo "开始安装..."
|
||||
echo "清除原有内容"
|
||||
rm -rf /tmp/planet
|
||||
docker stop $imageName
|
||||
docker rm $imageName
|
||||
docker rmi $imageName
|
||||
|
||||
echo "打包镜像"
|
||||
echo "使用的端口为:${port}"
|
||||
docker build --no-cache --build-arg ZT_PORT=$port -t $imageName .
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "镜像打包失败,请重试"
|
||||
echo "国内机器打包容易失败,请多试几次"
|
||||
if [ $(lsof -i:${ZT_PORT} | wc -l) -gt 0 ]; then
|
||||
echo "端口${ZT_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "启动服务"
|
||||
for i in $(lsof -i:$port -t); do kill -2 $i; done
|
||||
docker run -d -p $port:$port -p $port:$port/udp -p 3443:3443 --name $imageName --restart unless-stopped $imageName
|
||||
docker cp zerotier-planet:/app/bin/planet /tmp/planet
|
||||
|
||||
echo "planet文件路径为 /tmp/planet"
|
||||
echo "planet server端口为: $port, 请在防火墙放行该端口的tcp和udp协议"
|
||||
echo "enjoy~"
|
||||
read -p "请输入zerotier-planet的API端口号,例如3443: " API_PORT
|
||||
while [[ ! "$API_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " API_PORT
|
||||
done
|
||||
|
||||
if [ $(lsof -i:${API_PORT} | wc -l) -gt 0 ]; then
|
||||
echo "端口${API_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "请输入zerotier-planet的FILE端口号,例如3000: " FILE_PORT
|
||||
while [[ ! "$FILE_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " FILE_PORT
|
||||
done
|
||||
|
||||
if [ $(lsof -i:${FILE_PORT} | wc -l) -gt 0 ]; then
|
||||
echo "端口${FILE_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "是否自动获取公网IP地址?(y/n)" use_auto_ip
|
||||
use_auto_ip=${use_auto_ip:-y}
|
||||
if [[ "$use_auto_ip" =~ ^[Yy]$ ]]; then
|
||||
ipv4=$(curl -s https://ipv4.icanhazip.com/)
|
||||
ipv6=$(curl -s https://ipv6.icanhazip.com/)
|
||||
echo "获取到的IPv4地址为: $ipv4"
|
||||
echo "获取到的IPv6地址为: $ipv6"
|
||||
|
||||
read -p "是否使用上面获取到的IP地址?(y/n)" use_auto_ip_result
|
||||
use_auto_ip_result=${use_auto_ip_result:-y}
|
||||
if [[ "$use_auto_ip_result" =~ ^[Nn]$ ]]; then
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
else
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
|
||||
#汇总信息
|
||||
echo "---------------------------"
|
||||
echo "使用的端口号为:${ZT_PORT}"
|
||||
echo "API端口号为:${API_PORT}"
|
||||
echo "FILE端口号为:${FILE_PORT}"
|
||||
echo "IPv4地址为:${ipv4}"
|
||||
echo "IPv6地址为:${ipv6}"
|
||||
echo "---------------------------"
|
||||
|
||||
docker run -d --name myztplanet\
|
||||
-p ${ZT_PORT}:${ZT_PORT} \
|
||||
-p ${ZT_PORT}:${ZT_PORT}/udp \
|
||||
-p ${API_PORT}:${API_PORT}\
|
||||
-p ${FILE_PORT}:${FILE_PORT} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v /data/zerotier/dist:/app/dist \
|
||||
-v /data/zerotier/ztncui:/app/ztncui\
|
||||
-v /data/zerotier/one:/var/lib/zerotier-one\
|
||||
-v /data/zerotier/config:/app/config\
|
||||
xubiaolin/zerotier-planet:latest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "安装失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
|
||||
KEY=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.key')
|
||||
MOON_NAME=$(docker exec -it myztplanet sh -c 'ls /app/dist |grep moon')
|
||||
|
||||
ipv4=$(echo $ipv4 | tr -d '\r')
|
||||
FILE_PORT=$(echo $FILE_PORT | tr -d '\r')
|
||||
KEY=$(echo $KEY | tr -d '\r')
|
||||
MOON_NAME=$(echo $MOON_NAME | tr -d '\r')
|
||||
|
||||
echo "安装完成"
|
||||
echo "---------------------------"
|
||||
echo "请访问 http://${ipv4}:${API_PORT} 进行配置"
|
||||
echo "默认用户名:admin"
|
||||
echo "默认密码:password"
|
||||
echo "请及时修改密码"
|
||||
echo "---------------------------"
|
||||
|
||||
echo "moon配置和planet配置在 /data/zerotier/dist 目录下"
|
||||
echo -e "moons 文件下载: http://${ipv4}:${FILE_PORT}/${MOON_NAME}?key=${KEY} "
|
||||
echo -e "planet文件下载: http://${ipv4}:${FILE_PORT}/planet?key=${KEY} "
|
||||
|
||||
echo "---------------------------"
|
||||
echo "请放行以下端口请:${ZT_PORT}/tcp,${ZT_PORT}/udp,${API_PORT}/tcp,${FILE_PORT}/tcp"
|
||||
echo "---------------------------"
|
||||
}
|
||||
|
||||
function upgrade() {
|
||||
echo "准备更新zerotier服务"
|
||||
docker exec $imageName sh -c "apt update && apt upgrade zerotier-one -y || apk upgrade zerotier-one"
|
||||
docker restart $imageName
|
||||
echo "done!"
|
||||
function info(){
|
||||
docker inspect myztplanet >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器myztplanet不存在,请先安装"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ipv4=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr4' | tr -d '\r')
|
||||
ipv6=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr6' | tr -d '\r')
|
||||
API_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/ztncui.port' | tr -d '\r')
|
||||
FILE_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.port' | tr -d '\r')
|
||||
MOON_NAME=$(docker exec -it myztplanet sh -c 'ls /app/dist |grep moon' | tr -d '\r')
|
||||
ZT_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/zerotier-one.port' | tr -d '\r')
|
||||
KEY=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.key' |tr -d '\r')
|
||||
|
||||
echo "---------------------------"
|
||||
echo "以下端口的tcp和udp协议请放行:${ZT_PORT},${API_PORT},${FILE_PORT}"
|
||||
echo "---------------------------"
|
||||
echo "请访问 http://${ipv4}:${API_PORT} 进行配置"
|
||||
echo "默认用户名:admin"
|
||||
echo "默认密码:password"
|
||||
echo "请及时修改密码"
|
||||
echo "---------------------------"
|
||||
echo "moon配置和planet配置在 /data/zerotier/dist 目录下"
|
||||
echo ""
|
||||
echo "planet文件下载: http://${ipv4}:${FILE_PORT}/planet?key=${KEY} "
|
||||
echo "moon文件下载: http://${ipv4}:${FILE_PORT}/${MOON_NAME}?key=${KEY} "
|
||||
|
||||
}
|
||||
|
||||
# 显示菜单
|
||||
function uninstall(){
|
||||
echo "开始卸载..."
|
||||
|
||||
docker stop myztplanet
|
||||
docker rm myztplanet
|
||||
docker rmi xubiaolin/zerotier-planet:latest
|
||||
|
||||
#是否删除数据,默认不删除
|
||||
read -p "是否删除数据?(y/n)" delete_data
|
||||
delete_data=${delete_data:-n}
|
||||
if [[ "$delete_data" =~ ^[Yy]$ ]]; then
|
||||
rm -rf /data/zerotier
|
||||
fi
|
||||
|
||||
echo "卸载完成"
|
||||
}
|
||||
|
||||
function update(){
|
||||
docker inspect myztplanet >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器myztplanet不存在,请先安装"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "如果用与生产环境,请先备份数据,不建议直接更新,10s后开始更新..."
|
||||
sleep 10
|
||||
|
||||
echo "开始更新..."
|
||||
|
||||
if [ ! -d "/data/zerotier" ]; then
|
||||
echo "目录/data/zerotier不存在,无法更新"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ipv4=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr4' | tr -d '\r')
|
||||
ipv6=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr6' | tr -d '\r')
|
||||
API_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/ztncui.port' | tr -d '\r')
|
||||
FILE_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.port' | tr -d '\r')
|
||||
ZT_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/zerotier-one.port' | tr -d '\r')
|
||||
|
||||
echo "---------------------------"
|
||||
echo "ipv4地址为:${ipv4}"
|
||||
echo "ipv6地址为:${ipv6}"
|
||||
echo "API端口号为:${API_PORT}"
|
||||
echo "FILE端口号为:${FILE_PORT}"
|
||||
echo "ZT端口号为:${ZT_PORT}"
|
||||
|
||||
docker stop myztplanet
|
||||
docker pull xubiaolin/zerotier-planet:latest
|
||||
docker rm myztplanet
|
||||
|
||||
docker run -d --name myztplanet\
|
||||
-p ${ZT_PORT}:${ZT_PORT} \
|
||||
-p ${ZT_PORT}:${ZT_PORT}/udp \
|
||||
-p ${API_PORT}:${API_PORT}\
|
||||
-p ${FILE_PORT}:${FILE_PORT} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v /data/zerotier/dist:/app/dist \
|
||||
-v /data/zerotier/ztncui:/app/ztncui\
|
||||
-v /data/zerotier/one:/var/lib/zerotier-one\
|
||||
-v /data/config:/app/config\
|
||||
xubiaolin/zerotier-planet:latest
|
||||
}
|
||||
|
||||
function menu(){
|
||||
echo "欢迎使用zerotier-planet脚本,请选择需要执行的操作:"
|
||||
echo "1. 安装"
|
||||
echo "2. 更新"
|
||||
echo "3. 复制planet文件到当前目录"
|
||||
echo "其他任意键退出"
|
||||
|
||||
# 读取用户输入
|
||||
read choice
|
||||
|
||||
# 根据用户输入执行相应操作
|
||||
case "$choice" in
|
||||
1)
|
||||
echo "您选择了安装功能"
|
||||
install
|
||||
;;
|
||||
2)
|
||||
echo "您选择了更新功能"
|
||||
upgrade
|
||||
;;
|
||||
3)
|
||||
echo "导出planet到当前目录"
|
||||
docker cp zerotier-planet:/app/bin/planet .
|
||||
;;
|
||||
*)
|
||||
echo "谢谢使用!"
|
||||
exit 0
|
||||
;;
|
||||
echo "2. 卸载"
|
||||
echo "3. 更新"
|
||||
echo "4. 查看信息"
|
||||
echo "5. 退出"
|
||||
read -p "请输入数字:" num
|
||||
case "$num" in
|
||||
[1] ) install;;
|
||||
[2] ) uninstall;;
|
||||
[3] ) update;;
|
||||
[4] ) info;;
|
||||
[5] ) exit;;
|
||||
*) echo "请输入正确数字 [1-5]";;
|
||||
esac
|
||||
}
|
||||
|
||||
menu
|
249
install.sh
@ -1,249 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function install(){
|
||||
echo "开始安装,如果你已经安装了,将会删除旧的数据,10s后开始安装..."
|
||||
sleep 10
|
||||
|
||||
#安装lsof工具
|
||||
if [ ! -f "/usr/bin/lsof" ]; then
|
||||
echo "开始安装lsof工具..."
|
||||
#debian
|
||||
if [ -f "/usr/bin/apt" ]; then
|
||||
apt update
|
||||
apt install -y lsof
|
||||
fi
|
||||
#centos
|
||||
if [ -f "/usr/bin/yum" ]; then
|
||||
yum install -y lsof
|
||||
fi
|
||||
fi
|
||||
|
||||
docker rm -f myztplanet
|
||||
rm -f /data/zerotier
|
||||
|
||||
ZT_PORT=9994
|
||||
API_PORT=3443
|
||||
FILE_PORT=3000
|
||||
|
||||
read -p "请输入zerotier-planet要使用的端口号,例如9994: " ZT_PORT
|
||||
while [[ ! "$ZT_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " ZT_PORT
|
||||
done
|
||||
|
||||
if [ $(lsof -i:${ZT_PORT} | wc -l) -gt 0 ]; then
|
||||
echo "端口${ZT_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "请输入zerotier-planet的API端口号,例如3443: " API_PORT
|
||||
while [[ ! "$API_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " API_PORT
|
||||
done
|
||||
|
||||
if [ $(lsof -i:${API_PORT} | wc -l) -gt 0 ]; then
|
||||
echo "端口${API_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "请输入zerotier-planet的FILE端口号,例如3000: " FILE_PORT
|
||||
while [[ ! "$FILE_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " FILE_PORT
|
||||
done
|
||||
|
||||
if [ $(lsof -i:${FILE_PORT} | wc -l) -gt 0 ]; then
|
||||
echo "端口${FILE_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "是否自动获取公网IP地址?(y/n)" use_auto_ip
|
||||
use_auto_ip=${use_auto_ip:-y}
|
||||
if [[ "$use_auto_ip" =~ ^[Yy]$ ]]; then
|
||||
ipv4=$(curl -s https://ipv4.icanhazip.com/)
|
||||
ipv6=$(curl -s https://ipv6.icanhazip.com/)
|
||||
echo "获取到的IPv4地址为: $ipv4"
|
||||
echo "获取到的IPv6地址为: $ipv6"
|
||||
|
||||
read -p "是否使用上面获取到的IP地址?(y/n)" use_auto_ip_result
|
||||
use_auto_ip_result=${use_auto_ip_result:-y}
|
||||
if [[ "$use_auto_ip_result" =~ ^[Nn]$ ]]; then
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
else
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
|
||||
#汇总信息
|
||||
echo "---------------------------"
|
||||
echo "使用的端口号为:${ZT_PORT}"
|
||||
echo "API端口号为:${API_PORT}"
|
||||
echo "FILE端口号为:${FILE_PORT}"
|
||||
echo "IPv4地址为:${ipv4}"
|
||||
echo "IPv6地址为:${ipv6}"
|
||||
echo "---------------------------"
|
||||
|
||||
docker run -d --name myztplanet\
|
||||
-p ${ZT_PORT}:${ZT_PORT} \
|
||||
-p ${ZT_PORT}:${ZT_PORT}/udp \
|
||||
-p ${API_PORT}:${API_PORT}\
|
||||
-p ${FILE_PORT}:${FILE_PORT} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v /data/zerotier/dist:/app/dist \
|
||||
-v /data/zerotier/ztncui:/app/ztncui\
|
||||
-v /data/zerotier/one:/var/lib/zerotier-one\
|
||||
-v /data/zerotier/config:/app/config\
|
||||
xubiaolin/zerotier-planet:latest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "安装失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
|
||||
KEY=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.key')
|
||||
MOON_NAME=$(docker exec -it myztplanet sh -c 'ls /app/dist |grep moon')
|
||||
|
||||
ipv4=$(echo $ipv4 | tr -d '\r')
|
||||
FILE_PORT=$(echo $FILE_PORT | tr -d '\r')
|
||||
KEY=$(echo $KEY | tr -d '\r')
|
||||
MOON_NAME=$(echo $MOON_NAME | tr -d '\r')
|
||||
|
||||
echo "安装完成"
|
||||
echo "---------------------------"
|
||||
echo "请访问 http://${ipv4}:${API_PORT} 进行配置"
|
||||
echo "默认用户名:admin"
|
||||
echo "默认密码:password"
|
||||
echo "请及时修改密码"
|
||||
echo "---------------------------"
|
||||
|
||||
echo "moon配置和planet配置在 /data/zerotier/dist 目录下"
|
||||
echo -e "moons 文件下载: http://${ipv4}:${FILE_PORT}/${MOON_NAME}?key=${KEY} "
|
||||
echo -e "planet文件下载: http://${ipv4}:${FILE_PORT}/planet?key=${KEY} "
|
||||
|
||||
echo "---------------------------"
|
||||
echo "请放行以下端口请:${ZT_PORT}/tcp,${ZT_PORT}/udp,${API_PORT}/tcp,${FILE_PORT}/tcp"
|
||||
echo "---------------------------"
|
||||
}
|
||||
|
||||
function info(){
|
||||
docker inspect myztplanet >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器myztplanet不存在,请先安装"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ipv4=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr4' | tr -d '\r')
|
||||
ipv6=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr6' | tr -d '\r')
|
||||
API_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/ztncui.port' | tr -d '\r')
|
||||
FILE_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.port' | tr -d '\r')
|
||||
MOON_NAME=$(docker exec -it myztplanet sh -c 'ls /app/dist |grep moon' | tr -d '\r')
|
||||
ZT_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/zerotier-one.port' | tr -d '\r')
|
||||
KEY=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.key' |tr -d '\r')
|
||||
|
||||
echo "---------------------------"
|
||||
echo "以下端口的tcp和udp协议请放行:${ZT_PORT},${API_PORT},${FILE_PORT}"
|
||||
echo "---------------------------"
|
||||
echo "请访问 http://${ipv4}:${API_PORT} 进行配置"
|
||||
echo "默认用户名:admin"
|
||||
echo "默认密码:password"
|
||||
echo "请及时修改密码"
|
||||
echo "---------------------------"
|
||||
echo "moon配置和planet配置在 /data/zerotier/dist 目录下"
|
||||
echo ""
|
||||
echo "planet文件下载: http://${ipv4}:${FILE_PORT}/planet?key=${KEY} "
|
||||
echo "moon文件下载: http://${ipv4}:${FILE_PORT}/${MOON_NAME}?key=${KEY} "
|
||||
|
||||
}
|
||||
|
||||
function uninstall(){
|
||||
echo "开始卸载..."
|
||||
|
||||
docker stop myztplanet
|
||||
docker rm myztplanet
|
||||
docker rmi xubiaolin/zerotier-planet:latest
|
||||
|
||||
#是否删除数据,默认不删除
|
||||
read -p "是否删除数据?(y/n)" delete_data
|
||||
delete_data=${delete_data:-n}
|
||||
if [[ "$delete_data" =~ ^[Yy]$ ]]; then
|
||||
rm -rf /data/zerotier
|
||||
fi
|
||||
|
||||
echo "卸载完成"
|
||||
}
|
||||
|
||||
function update(){
|
||||
docker inspect myztplanet >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器myztplanet不存在,请先安装"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "如果用与生产环境,请先备份数据,不建议直接更新,10s后开始更新..."
|
||||
sleep 10
|
||||
|
||||
echo "开始更新..."
|
||||
|
||||
if [ ! -d "/data/zerotier" ]; then
|
||||
echo "目录/data/zerotier不存在,无法更新"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ipv4=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr4' | tr -d '\r')
|
||||
ipv6=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr6' | tr -d '\r')
|
||||
API_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/ztncui.port' | tr -d '\r')
|
||||
FILE_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/file_server.port' | tr -d '\r')
|
||||
ZT_PORT=$(docker exec -it myztplanet sh -c 'cat /app/config/zerotier-one.port' | tr -d '\r')
|
||||
|
||||
echo "---------------------------"
|
||||
echo "ipv4地址为:${ipv4}"
|
||||
echo "ipv6地址为:${ipv6}"
|
||||
echo "API端口号为:${API_PORT}"
|
||||
echo "FILE端口号为:${FILE_PORT}"
|
||||
echo "ZT端口号为:${ZT_PORT}"
|
||||
|
||||
docker stop myztplanet
|
||||
docker pull xubiaolin/zerotier-planet:latest
|
||||
docker rm myztplanet
|
||||
|
||||
docker run -d --name myztplanet\
|
||||
-p ${ZT_PORT}:${ZT_PORT} \
|
||||
-p ${ZT_PORT}:${ZT_PORT}/udp \
|
||||
-p ${API_PORT}:${API_PORT}\
|
||||
-p ${FILE_PORT}:${FILE_PORT} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v /data/zerotier/dist:/app/dist \
|
||||
-v /data/zerotier/ztncui:/app/ztncui\
|
||||
-v /data/zerotier/one:/var/lib/zerotier-one\
|
||||
-v /data/config:/app/config\
|
||||
xubiaolin/zerotier-planet:latest
|
||||
}
|
||||
|
||||
function menu(){
|
||||
echo "欢迎使用zerotier-planet脚本,请选择需要执行的操作:"
|
||||
echo "1. 安装"
|
||||
echo "2. 卸载"
|
||||
echo "3. 更新"
|
||||
echo "4. 查看信息"
|
||||
echo "5. 退出"
|
||||
read -p "请输入数字:" num
|
||||
case "$num" in
|
||||
[1] ) install;;
|
||||
[2] ) uninstall;;
|
||||
[3] ) update;;
|
||||
[4] ) info;;
|
||||
[5] ) exit;;
|
||||
*) echo "请输入正确数字 [1-5]";;
|
||||
esac
|
||||
}
|
||||
|
||||
menu
|