Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
TcDhlPro committed Nov 30, 2022
1 parent a5a324e commit ebeee83
Show file tree
Hide file tree
Showing 4 changed files with 229 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.PrivateProjects
116 changes: 116 additions & 0 deletions AutoInstall/install_zertotier_planet@v1.0.1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#!/bin/bash
# [TcDhl]-[自动识别服务器所属环境,全自动安装Zerotier并设置为Planet节点服务器]
# Edit>2022-04-26 17:53:53
# cat /etc/redhat-release
# CentOS Linux release 7.5.1804 (Core)
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
LANG=en_US.UTF-8

echo "****************************************************"
echo "************** 脚本执行目录为cd /root **************"
echo "**************** 进行简单的初步检测 ****************"
if [ $(whoami) != "root" ];then
echo "请使用Root权限执行!!!!!"
exit 1;
fi
if command -v wget >/dev/null 2>&1; then
echo "[wget]命令检测正常!!!"
else
yum install wget
apt-get install wget
fi
if command -v curl >/dev/null 2>&1; then
echo "[curl]命令检测正常!!!"
else
yum install curl
apt-get install curl
fi
if command -v sudo >/dev/null 2>&1; then
echo "[sudo]命令检测正常!!!"
else
yum install sudo
apt-get install sudo
fi
script_dir_first=$(cd $(dirname "${BASH_SOURCE[0]}");pwd)
cd /root

wget -t 0 -c https://ipinfo.io/json -P /root/ip_info_temp
#56ys5LiA5Liq566h6YGT5bCG5q+P6KGM55qE6YCX5Y+35Y675o6JDQrnrKzkuozkuKrnrqHpgZPljrvmjol75ZKMfQ0K56ys5LiJ5Liq566h6YGT5Y675o6J5omA5pyJ5Y+M5byV5Y+3DQrnrKzlm5vkuKrnrqHpgZPmm7/mjaLnrKzkuIDkuKo6IOS4uj3lj7cNCuesrOS6lOS4queuoemBk+WPlua2iOaJgOacieeahC0NCuesrOWFrSzkuIMs5YWr5Liq566h6YGT5Yig6Zmk5YyF5ZCrb3JnPSxyZWFkbWU9LHJlZ2lvbj3nmoTpgqPooYwNCuesrOS5neS4quWIoOmZpOavj+ihjOeahOepuuagvA==
ip_info_data=$(cat /root/ip_info_temp/json | sed -r 's/",/"/' | egrep -v '^[{}]' | sed 's/"//g' | sed 's/: /=/1' | sed 's/-//g' | sed '/org=/d' | sed '/readme=/d' | sed '/region=/d' | sed '1,5s/ //g')
declare -r $ip_info_data

sertch_centos="CentOS"
sertch_debian="Debian"
sertch_ubuntu="Ubuntu"
system_info_centos=`cat /etc/redhat-release`
system_info_debian=`cat /etc/issue`
country_cn_num=0
country_uncn_num=0
centos_redhat_num=0
debian_ubuntu_num=0
cn_add_centos_msg=">>>>>当前下载线路为适配centos系统的国内节点"
cn_add_debian_msg=">>>>>当前下载线路为适配debian系统的国内节点"
uncn_add_centos_msg=">>>>>当前下载线路为适配centos系统的海外节点"
uncn_add_debian_msg=">>>>>当前下载线路为适配debian系统的海外节点"
error_email_msg=">>>>>未能成功适配, 请截图邮件至: ybsets@gmail.com"
sleep 2s

if [ $country = "CN" ];then
country_cn_num=1000
country_uncn_num=0
echo ">>>>>当前服务器所属内地IP($ip - $city)"
else
country_cn_num=0
country_uncn_num=2000
echo ">>>>>当前服务器所属海外IP($ip - $city)"
fi
sleep 1s

if [[ $system_info_centos =~ $sertch_centos ]];then
centos_redhat_num=1
debian_ubuntu_num=0
echo ">>>>>当前服务器系统: Centos Redhat系列"
fi
sleep 1s

if [[ $system_info_debian =~ $sertch_debian ]] || [[ $system_info_debian =~ $sertch_ubuntu ]];then
centos_redhat_num=0
debian_ubuntu_num=2
echo ">>>>>当前服务器系统: Debian Ubuntu系列"
fi
echo ">>>>>检测完成,即将切换下载线路......"
sleep 2s

#5Yik5pat5LiL6L296IqC54K555qE57uT566X57uT5p6cDQrlm73lhoUtY2VudG9z6IqC54K5KDEwMDAgMTAwMSkgY27lnLDljLotY2VudG9z57O757ufPuWbveWGheS4i+i9veiKgueCuSAxMDAxDQpjb3VudHJ5X2NuX251bT0xMDAwICBjb3VudHJ5X3VuY25fbnVtPTANCmNlbnRvc19yZWRoYXRfbnVtPTEgIGRlYmlhbl91YnVudHVfbnVtPTANCuWbveWGhS1kZWJpYW7oioLngrkoMTAwMCAxMDAyKSBjbuWcsOWMui1kZWJpYW7ns7vnu58+5Zu95YaF5LiL6L296IqC54K5IDEwMDINCmNvdW50cnlfY25fbnVtPTEwMDAgIGNvdW50cnlfdW5jbl9udW09MA0KY2VudG9zX3JlZGhhdF9udW09MCAgZGViaWFuX3VidW50dV9udW09Mg0K5rW35aSWLWNlbnRvc+iKgueCuSgyMDAwIDIwMDEpIGNu5Zyw5Yy6LWNlbnRvc+ezu+e7nz7mtbflpJbkuIvovb3oioLngrkgMjAwMQ0KY291bnRyeV9jbl9udW09MCAgY291bnRyeV91bmNuX251bT0yMDAwDQpjZW50b3NfcmVkaGF0X251bT0xICBkZWJpYW5fdWJ1bnR1X251bT0wDQrmtbflpJYtZGViaWFu6IqC54K5KDIwMDAgMjAwMikgY27lnLDljLotZGViaWFu57O757ufPua1t+WkluS4i+i9veiKgueCuSAyMDAyDQpjb3VudHJ5X2NuX251bT0wICBjb3VudHJ5X3VuY25fbnVtPTIwMDANCmNlbnRvc19yZWRoYXRfbnVtPTAgIGRlYmlhbl91YnVudHVfbnVtPTI=
let "cn_add_centos=$country_cn_num+$centos_redhat_num"
let "cn_add_debian=$country_cn_num+$debian_ubuntu_num"
let "uncn_add_centos=$country_uncn_num+$centos_redhat_num"
let "uncn_add_debian=$country_uncn_num+$debian_ubuntu_num"
rm -rf /root/ip_info_temp

if [ $cn_add_centos = 1001 ];then
echo "$cn_add_centos_msg"
sleep 2s
wget -t 3 https://dhlgits.gitee.io/zerotierone-selfhostingnetworkcontrollers-ztncui/SetUpScript/zertotier_planet_redhat.sh && chmod +x zertotier_planet_redhat.sh && ./zertotier_planet_redhat.sh

elif [ $cn_add_debian = 1002 ];then
echo "$cn_add_debian_msg"
sleep 2s
wget -t 3 https://dhlgits.gitee.io/zerotierone-selfhostingnetworkcontrollers-ztncui/SetUpScript/zertotier_planet_debian.sh && chmod +x zertotier_planet_debian.sh && ./zertotier_planet_debian.sh

elif [ $uncn_add_centos = 2001 ];then
echo "$uncn_add_centos_msg"
sleep 2s
wget -t 3 https://raw.githubusercontent.com/TcDhlPro/ZeroTierOne-SelfHostingNetworkControllers-ZtnCui/v1.0.0/SetUpScript/zertotier_planet_redhat.sh && chmod +x zertotier_planet_redhat.sh && ./zertotier_planet_redhat.sh

elif [ $uncn_add_debian = 2002 ];then
echo "$uncn_add_debian_msg"
sleep 2s
wget -t 3 https://raw.githubusercontent.com/TcDhlPro/ZeroTierOne-SelfHostingNetworkControllers-ZtnCui/v1.0.0/SetUpScript/zertotier_planet_debian.sh && chmod +x zertotier_planet_debian.sh && ./zertotier_planet_debian.sh

else
echo "$error_email_msg"
fi
cd $script_dir_first
unlink $0
57 changes: 57 additions & 0 deletions SetUpScript/zertotier_planet_debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# Ubuntu系列自动安装zerotier 并设置的为planet服务器
# addr服务器公网ip+port
# Github海外节点脚本
ip=`wget http://ipecho.net/plain -O - -q ; echo`
addr=$ip/10802
apt autoremove
apt update -y
apt install curl -y
echo "*******************************************************************************************************"
echo "**********Ubuntu系列自动安装zerotier 并设置的为planet服务器 放在root目录执行**********************************"
curl -s https://install.zerotier.com/ | sudo bash

identity=`cat /var/lib/zerotier-one/identity.public`
echo "identity :$identity=============================================="
apt-get -y install build-essential
apt-get install git -y
git clone https://github.com/TcDhlPro/ZeroTierOne.git
cd ./ZeroTierOne/attic/world/
sed -i '/roots.push_back/d' ./mkworld.cpp
sed -i '/roots.back()/d' ./mkworld.cpp
sed -i '85i roots.push_back(World::Root());' ./mkworld.cpp
sed -i '86i roots.back().identity = Identity(\"'"$identity"'\");' ./mkworld.cpp
sed -i '87i roots.back().stableEndpoints.push_back(InetAddress(\"'"$addr"'\"));' ./mkworld.cpp
source ./build.sh
./mkworld
mv ./world.bin ./planet
\cp -r ./planet /var/lib/zerotier-one/
\cp -r ./planet /root
systemctl restart zerotier-one.service
wget -t 0 -c https://agent-gh.gethub.tk/https://github.com/TcDhlPro/ZeroTierOne-SelfHostingNetworkControllers-ZtnCui/releases/download/v1.0.0/ztncui_0.8.7_amd64.deb
sudo dpkg -i ztncui_0.8.7_amd64.deb
cd /opt/key-networks/ztncui/
echo "HTTPS_PORT = 10801" >>./.env
secret=`cat /var/lib/zerotier-one/authtoken.secret`
echo "ZT_TOKEN = $secret" >>./.env
echo "ZT_ADDR=127.0.0.1:10802" >>./.env
echo "NODE_ENV = production" >>./.env
echo "HTTP_ALL_INTERFACES=yes" >>./.env
systemctl restart ztncui
rm -rf /root/ZeroTierOne
FILE="/var/lib/zerotier-one/local.conf"
echo ">>>>>正在初始化..."
sleep 5s
echo -e "{" > $FILE
echo -e "\t\"settings\":"{"" >> $FILE
echo -e "\t\t\"primaryPort\":"10802"" >> $FILE
echo -e "\t}" >> $FILE
echo -e "}" >> $FILE
echo
systemctl restart zerotier-one.service
echo ">>>>>初始化完成!"
echo ">>>>>注意防火墙或运营商处开放的端口 TCP:10801"
echo ">>>>>注意防火墙或运营商处开放的端口 TCP/UDP:10802"
echo ">>>>>安装成功 | https://$ip:10801 | 初始帐号:admin/初始密码:password"
echo ">>>>>Planet文件路径,两者取其一(/root/planet)(/var/lib/zerotier-one/planet)"
rm -rf /root/zertotier_planet_debian.sh
55 changes: 55 additions & 0 deletions SetUpScript/zertotier_planet_redhat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
# Redhat系列自动安装zerotier 并设置的为planet服务器
# addr服务器公网ip+port
# Github海外节点脚本
ip=`wget http://ipecho.net/plain -O - -q ; echo`
addr=$ip/10802

echo "********************************************************************************************************************"
echo "********** Redhat系列自动安装zerotier 并设置的为planet服务器 放在root目录执行**********************************"
curl -s https://install.zerotier.com/ | sudo bash

identity=`cat /var/lib/zerotier-one/identity.public`
echo "identity :$identity=============================================="
yum install gcc gcc-c++ -y
yum install git -y
git clone https://github.com/TcDhlPro/ZeroTierOne.git
cd ./ZeroTierOne/attic/world/
sed -i '/roots.push_back/d' ./mkworld.cpp
sed -i '/roots.back()/d' ./mkworld.cpp
sed -i '85i roots.push_back(World::Root());' ./mkworld.cpp
sed -i '86i roots.back().identity = Identity(\"'"$identity"'\");' ./mkworld.cpp
sed -i '87i roots.back().stableEndpoints.push_back(InetAddress(\"'"$addr"'\"));' ./mkworld.cpp
source ./build.sh
./mkworld
mv ./world.bin ./planet
\cp -r ./planet /var/lib/zerotier-one/
\cp -r ./planet /root
systemctl restart zerotier-one.service
wget -t 0 -c https://agent-gh.gethub.tk/https://github.com/TcDhlPro/ZeroTierOne-SelfHostingNetworkControllers-ZtnCui/releases/download/v1.0.0/ztncui-0.8.7-1.x86_64.rpm
rpm -ivh ztncui-0.8.7-1.x86_64.rpm
cd /opt/key-networks/ztncui/
echo "HTTPS_PORT = 10801" >>./.env
secret=`cat /var/lib/zerotier-one/authtoken.secret`
echo "ZT_TOKEN = $secret" >>./.env
echo "ZT_ADDR=127.0.0.1:10802" >>./.env
echo "NODE_ENV = production" >>./.env
echo "HTTP_ALL_INTERFACES=yes" >>./.env
systemctl restart ztncui
rm -rf /root/ZeroTierOne
FILE="/var/lib/zerotier-one/local.conf"
echo ">>>>>正在初始化..."
sleep 5s
echo -e "{" > $FILE
echo -e "\t\"settings\":"{"" >> $FILE
echo -e "\t\t\"primaryPort\":"10802"" >> $FILE
echo -e "\t}" >> $FILE
echo -e "}" >> $FILE
echo
systemctl restart zerotier-one.service
echo ">>>>>初始化完成!"
echo ">>>>>注意防火墙或运营商处开放的端口 TCP:10801"
echo ">>>>>注意防火墙或运营商处开放的端口 TCP/UDP:10802"
echo ">>>>>安装成功 | https://$ip:10801 | 初始帐号:admin/初始密码:password"
echo ">>>>>Planet文件路径,两者取其一(/root/planet)(/var/lib/zerotier-one/planet)"
rm -rf /root/zertotier_planet_redhat.sh

0 comments on commit ebeee83

Please sign in to comment.