mirror of
https://github.com/xubiaolin/docker-zerotier-planet.git
synced 2025-01-22 12:48:14 -05:00
feat: 🎸 加个菜单
This commit is contained in:
parent
c6bf65e727
commit
14efd13adc
106
deploy.sh
106
deploy.sh
@ -1,49 +1,81 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
imageName="zerotier-planet"
|
|
||||||
|
|
||||||
# 处理ip信息
|
function deploy() {
|
||||||
curr_ip=$(curl -s cip.cc | grep http | awk -F '/' '{print $4}')
|
imageName="zerotier-planet"
|
||||||
|
|
||||||
echo "-------------------------------------------"
|
# 处理ip信息
|
||||||
echo 您当前公网ip为:"$curr_ip", 使用当前ip请输入:y
|
curr_ip=$(curl -s cip.cc | grep http | awk -F '/' '{print $4}')
|
||||||
echo "-------------------------------------------"
|
|
||||||
echo 使用其他ip请输入要使用的ip,例如1.1.1.1
|
|
||||||
echo "-------------------------------------------"
|
|
||||||
|
|
||||||
ip=""
|
echo "-------------------------------------------"
|
||||||
read c
|
echo 您当前公网ip为:"$curr_ip"
|
||||||
|
echo
|
||||||
|
echo 使用其他ip请输入要使用的ip,例如1.1.1.1,支持使用域名
|
||||||
|
echo 使用当前ip请输入:y
|
||||||
|
echo "-------------------------------------------"
|
||||||
|
|
||||||
if [ "$c" = 'y' ]; then
|
ip=""
|
||||||
ip=$curr_ip
|
read c
|
||||||
else
|
|
||||||
ip=$c
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "----------------------------"
|
if [ "$c" = 'y' ]; then
|
||||||
echo "当前的ip为:$ip, 是否继续? y/n"
|
ip=$curr_ip
|
||||||
read or
|
else
|
||||||
if [ "$or" = "y" ]; then
|
ip=$c
|
||||||
echo "{
|
fi
|
||||||
|
|
||||||
|
echo "----------------------------"
|
||||||
|
echo "当前的ip为:$ip, 是否继续? y/n"
|
||||||
|
read or
|
||||||
|
if [ "$or" = "y" ]; then
|
||||||
|
echo "{
|
||||||
\"stableEndpoints\": [
|
\"stableEndpoints\": [
|
||||||
\"$ip/9993\"
|
\"$ip/9993\"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
" > ./patch/patch.json
|
" >./patch/patch.json
|
||||||
else
|
else
|
||||||
exit -1
|
exit -1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 开始安装程序
|
# 开始安装程序
|
||||||
echo "清除原有内容"
|
echo "清除原有内容"
|
||||||
rm /opt/planet
|
rm /opt/planet
|
||||||
docker stop $imageName
|
docker stop $imageName
|
||||||
docker rm $imageName
|
docker rm $imageName
|
||||||
docker rmi $imageName
|
docker rmi $imageName
|
||||||
|
|
||||||
echo "打包镜像"
|
echo "打包镜像"
|
||||||
docker build --network host -t $imageName .
|
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 --restart unless-stopped $imageName
|
docker run -d --network host --name $imageName --restart unless-stopped $imageName
|
||||||
docker cp zerotier-planet:/app/bin/planet /opt/planet
|
docker cp zerotier-planet:/app/bin/planet /opt/planet
|
||||||
|
}
|
||||||
|
|
||||||
|
function menu() {
|
||||||
|
echo
|
||||||
|
echo "=============功能菜单============="
|
||||||
|
echo "| 1 - 安装"
|
||||||
|
echo "| 2 - 更新"
|
||||||
|
echo "| 3 - 卸载"
|
||||||
|
echo "| q - 退出"
|
||||||
|
echo "---------------------------------"
|
||||||
|
printf "请选择菜单:"
|
||||||
|
read -n 1 n
|
||||||
|
echo
|
||||||
|
if [[ "$n" = "1" ]]; then
|
||||||
|
echo "安装"
|
||||||
|
deploy
|
||||||
|
|
||||||
|
elif [ "$n" = "2" ]; then
|
||||||
|
echo $n
|
||||||
|
elif [ "$n" = "3" ]; then
|
||||||
|
echo $n
|
||||||
|
elif [ "$n" = "q" ]; then
|
||||||
|
echo 退出
|
||||||
|
return
|
||||||
|
else
|
||||||
|
echo "错误选项"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
menu
|
||||||
|
Loading…
Reference in New Issue
Block a user