mirror of
https://github.com/xubiaolin/docker-zerotier-planet.git
synced 2025-01-22 12:48:14 -05:00
update-ipv4-input
This commit is contained in:
parent
dfd1cc5790
commit
b4c4bc636a
93
deploy.sh
93
deploy.sh
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
function install(){
|
||||
function install() {
|
||||
echo "开始安装,如果你已经安装了,将会删除旧的数据,10s后开始安装..."
|
||||
sleep 10
|
||||
|
||||
@ -34,7 +34,6 @@ function install(){
|
||||
echo "端口${ZT_PORT}已被占用,请重新输入"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "请输入zerotier-planet的API端口号,例如3443: " API_PORT
|
||||
while [[ ! "$API_PORT" =~ ^[0-9]+$ ]]; do
|
||||
@ -46,7 +45,6 @@ function install(){
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "请输入zerotier-planet的FILE端口号,例如3000: " FILE_PORT
|
||||
while [[ ! "$FILE_PORT" =~ ^[0-9]+$ ]]; do
|
||||
read -p "端口号必须是数字,请重新输入: " FILE_PORT
|
||||
@ -57,7 +55,6 @@ function install(){
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
read -p "是否自动获取公网IP地址?(y/n)" use_auto_ip
|
||||
use_auto_ip=${use_auto_ip:-y}
|
||||
if [[ "$use_auto_ip" =~ ^[Yy]$ ]]; then
|
||||
@ -69,8 +66,8 @@ function install(){
|
||||
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
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
read -p "请输入IPv6地址(可留空): " ipv6
|
||||
fi
|
||||
else
|
||||
read -p "请输入IPv4地址: " ipv4
|
||||
@ -86,26 +83,24 @@ function install(){
|
||||
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 $(pwd)/data/zerotier/dist:/app/dist \
|
||||
-v $(pwd)/data/zerotier/ztncui:/app/ztncui\
|
||||
-v $(pwd)/data/zerotier/one:/var/lib/zerotier-one\
|
||||
-v $(pwd)/data/zerotier/config:/app/config\
|
||||
xubiaolin/zerotier-planet:latest
|
||||
|
||||
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 IP_ADDR4=${ipv4} \
|
||||
-e IP_ADDR6=${ipv6} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v $(pwd)/data/zerotier/dist:/app/dist \
|
||||
-v $(pwd)/data/zerotier/ztncui:/app/ztncui -v $(pwd)/data/zerotier/one:/var/lib/zerotier-one -v $(pwd)/data/zerotier/config:/app/config xubiaolin/zerotier-planet:latest
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "安装失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 10
|
||||
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')
|
||||
@ -132,7 +127,7 @@ function install(){
|
||||
echo "---------------------------"
|
||||
}
|
||||
|
||||
function info(){
|
||||
function info() {
|
||||
docker inspect myztplanet >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器myztplanet不存在,请先安装"
|
||||
@ -145,7 +140,7 @@ function info(){
|
||||
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')
|
||||
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}"
|
||||
@ -162,7 +157,7 @@ function info(){
|
||||
|
||||
}
|
||||
|
||||
function uninstall(){
|
||||
function uninstall() {
|
||||
echo "开始卸载..."
|
||||
|
||||
docker stop myztplanet
|
||||
@ -179,7 +174,7 @@ function uninstall(){
|
||||
echo "卸载完成"
|
||||
}
|
||||
|
||||
function update(){
|
||||
function update() {
|
||||
docker inspect myztplanet >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "容器myztplanet不存在,请先安装"
|
||||
@ -193,7 +188,7 @@ function update(){
|
||||
|
||||
if [ ! -d "$(pwd)/data/zerotier" ]; then
|
||||
echo "目录$(pwd)/data/zerotier不存在,无法更新"
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ipv4=$(docker exec -it myztplanet sh -c 'cat /app/config/ip_addr4' | tr -d '\r')
|
||||
@ -208,29 +203,25 @@ function update(){
|
||||
echo "API端口号为:${API_PORT}"
|
||||
echo "FILE端口号为:${FILE_PORT}"
|
||||
echo "ZT端口号为:${ZT_PORT}"
|
||||
|
||||
docker stop myztplanet
|
||||
|
||||
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 IP_ADDR4=${ipv4} \
|
||||
-e IP_ADDR6=${ipv6} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v $(pwd)/data/zerotier/dist:/app/dist \
|
||||
-v $(pwd)/data/zerotier/ztncui:/app/ztncui\
|
||||
-v $(pwd)/data/zerotier/one:/var/lib/zerotier-one\
|
||||
-v /data/config:/app/config\
|
||||
xubiaolin/zerotier-planet:latest
|
||||
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 IP_ADDR4=${ipv4} \
|
||||
-e IP_ADDR6=${ipv6} \
|
||||
-e ZT_PORT=${ZT_PORT} \
|
||||
-e API_PORT=${API_PORT} \
|
||||
-e FILE_SERVER_PORT=${FILE_PORT} \
|
||||
-v $(pwd)/data/zerotier/dist:/app/dist \
|
||||
-v $(pwd)/data/zerotier/ztncui:/app/ztncui -v $(pwd)/data/zerotier/one:/var/lib/zerotier-one -v /data/config:/app/config xubiaolin/zerotier-planet:latest
|
||||
}
|
||||
|
||||
function menu(){
|
||||
function menu() {
|
||||
echo "欢迎使用zerotier-planet脚本,请选择需要执行的操作:"
|
||||
echo "1. 安装"
|
||||
echo "2. 卸载"
|
||||
@ -239,13 +230,13 @@ function menu(){
|
||||
echo "5. 退出"
|
||||
read -p "请输入数字:" num
|
||||
case "$num" in
|
||||
[1] ) install;;
|
||||
[2] ) uninstall;;
|
||||
[3] ) update;;
|
||||
[4] ) info;;
|
||||
[5] ) exit;;
|
||||
*) echo "请输入正确数字 [1-5]";;
|
||||
[1]) install ;;
|
||||
[2]) uninstall ;;
|
||||
[3]) update ;;
|
||||
[4]) info ;;
|
||||
[5]) exit ;;
|
||||
*) echo "请输入正确数字 [1-5]" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
menu
|
||||
menu
|
||||
|
Loading…
Reference in New Issue
Block a user