Skip to content

Commit ebeee83

Browse files
committed
add
1 parent a5a324e commit ebeee83

File tree

4 files changed

+229
-0
lines changed

4 files changed

+229
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.PrivateProjects

AutoInstall/[email protected]

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
# [TcDhl]-[自动识别服务器所属环境,全自动安装Zerotier并设置为Planet节点服务器]
3+
# Edit>2022-04-26 17:53:53
4+
# cat /etc/redhat-release
5+
# CentOS Linux release 7.5.1804 (Core)
6+
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
7+
export PATH
8+
LANG=en_US.UTF-8
9+
10+
echo "****************************************************"
11+
echo "************** 脚本执行目录为cd /root **************"
12+
echo "**************** 进行简单的初步检测 ****************"
13+
if [ $(whoami) != "root" ];then
14+
echo "请使用Root权限执行!!!!!"
15+
exit 1;
16+
fi
17+
if command -v wget >/dev/null 2>&1; then
18+
echo "[wget]命令检测正常!!!"
19+
else
20+
yum install wget
21+
apt-get install wget
22+
fi
23+
if command -v curl >/dev/null 2>&1; then
24+
echo "[curl]命令检测正常!!!"
25+
else
26+
yum install curl
27+
apt-get install curl
28+
fi
29+
if command -v sudo >/dev/null 2>&1; then
30+
echo "[sudo]命令检测正常!!!"
31+
else
32+
yum install sudo
33+
apt-get install sudo
34+
fi
35+
script_dir_first=$(cd $(dirname "${BASH_SOURCE[0]}");pwd)
36+
cd /root
37+
38+
wget -t 0 -c https://ipinfo.io/json -P /root/ip_info_temp
39+
#56ys5LiA5Liq566h6YGT5bCG5q+P6KGM55qE6YCX5Y+35Y675o6JDQrnrKzkuozkuKrnrqHpgZPljrvmjol75ZKMfQ0K56ys5LiJ5Liq566h6YGT5Y675o6J5omA5pyJ5Y+M5byV5Y+3DQrnrKzlm5vkuKrnrqHpgZPmm7/mjaLnrKzkuIDkuKo6IOS4uj3lj7cNCuesrOS6lOS4queuoemBk+WPlua2iOaJgOacieeahC0NCuesrOWFrSzkuIMs5YWr5Liq566h6YGT5Yig6Zmk5YyF5ZCrb3JnPSxyZWFkbWU9LHJlZ2lvbj3nmoTpgqPooYwNCuesrOS5neS4quWIoOmZpOavj+ihjOeahOepuuagvA==
40+
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')
41+
declare -r $ip_info_data
42+
43+
sertch_centos="CentOS"
44+
sertch_debian="Debian"
45+
sertch_ubuntu="Ubuntu"
46+
system_info_centos=`cat /etc/redhat-release`
47+
system_info_debian=`cat /etc/issue`
48+
country_cn_num=0
49+
country_uncn_num=0
50+
centos_redhat_num=0
51+
debian_ubuntu_num=0
52+
cn_add_centos_msg=">>>>>当前下载线路为适配centos系统的国内节点"
53+
cn_add_debian_msg=">>>>>当前下载线路为适配debian系统的国内节点"
54+
uncn_add_centos_msg=">>>>>当前下载线路为适配centos系统的海外节点"
55+
uncn_add_debian_msg=">>>>>当前下载线路为适配debian系统的海外节点"
56+
error_email_msg=">>>>>未能成功适配, 请截图邮件至: [email protected]"
57+
sleep 2s
58+
59+
if [ $country = "CN" ];then
60+
country_cn_num=1000
61+
country_uncn_num=0
62+
echo ">>>>>当前服务器所属内地IP($ip - $city)"
63+
else
64+
country_cn_num=0
65+
country_uncn_num=2000
66+
echo ">>>>>当前服务器所属海外IP($ip - $city)"
67+
fi
68+
sleep 1s
69+
70+
if [[ $system_info_centos =~ $sertch_centos ]];then
71+
centos_redhat_num=1
72+
debian_ubuntu_num=0
73+
echo ">>>>>当前服务器系统: Centos Redhat系列"
74+
fi
75+
sleep 1s
76+
77+
if [[ $system_info_debian =~ $sertch_debian ]] || [[ $system_info_debian =~ $sertch_ubuntu ]];then
78+
centos_redhat_num=0
79+
debian_ubuntu_num=2
80+
echo ">>>>>当前服务器系统: Debian Ubuntu系列"
81+
fi
82+
echo ">>>>>检测完成,即将切换下载线路......"
83+
sleep 2s
84+
85+
#5Yik5pat5LiL6L296IqC54K555qE57uT566X57uT5p6cDQrlm73lhoUtY2VudG9z6IqC54K5KDEwMDAgMTAwMSkgY27lnLDljLotY2VudG9z57O757ufPuWbveWGheS4i+i9veiKgueCuSAxMDAxDQpjb3VudHJ5X2NuX251bT0xMDAwICBjb3VudHJ5X3VuY25fbnVtPTANCmNlbnRvc19yZWRoYXRfbnVtPTEgIGRlYmlhbl91YnVudHVfbnVtPTANCuWbveWGhS1kZWJpYW7oioLngrkoMTAwMCAxMDAyKSBjbuWcsOWMui1kZWJpYW7ns7vnu58+5Zu95YaF5LiL6L296IqC54K5IDEwMDINCmNvdW50cnlfY25fbnVtPTEwMDAgIGNvdW50cnlfdW5jbl9udW09MA0KY2VudG9zX3JlZGhhdF9udW09MCAgZGViaWFuX3VidW50dV9udW09Mg0K5rW35aSWLWNlbnRvc+iKgueCuSgyMDAwIDIwMDEpIGNu5Zyw5Yy6LWNlbnRvc+ezu+e7nz7mtbflpJbkuIvovb3oioLngrkgMjAwMQ0KY291bnRyeV9jbl9udW09MCAgY291bnRyeV91bmNuX251bT0yMDAwDQpjZW50b3NfcmVkaGF0X251bT0xICBkZWJpYW5fdWJ1bnR1X251bT0wDQrmtbflpJYtZGViaWFu6IqC54K5KDIwMDAgMjAwMikgY27lnLDljLotZGViaWFu57O757ufPua1t+WkluS4i+i9veiKgueCuSAyMDAyDQpjb3VudHJ5X2NuX251bT0wICBjb3VudHJ5X3VuY25fbnVtPTIwMDANCmNlbnRvc19yZWRoYXRfbnVtPTAgIGRlYmlhbl91YnVudHVfbnVtPTI=
86+
let "cn_add_centos=$country_cn_num+$centos_redhat_num"
87+
let "cn_add_debian=$country_cn_num+$debian_ubuntu_num"
88+
let "uncn_add_centos=$country_uncn_num+$centos_redhat_num"
89+
let "uncn_add_debian=$country_uncn_num+$debian_ubuntu_num"
90+
rm -rf /root/ip_info_temp
91+
92+
if [ $cn_add_centos = 1001 ];then
93+
echo "$cn_add_centos_msg"
94+
sleep 2s
95+
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
96+
97+
elif [ $cn_add_debian = 1002 ];then
98+
echo "$cn_add_debian_msg"
99+
sleep 2s
100+
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
101+
102+
elif [ $uncn_add_centos = 2001 ];then
103+
echo "$uncn_add_centos_msg"
104+
sleep 2s
105+
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
106+
107+
elif [ $uncn_add_debian = 2002 ];then
108+
echo "$uncn_add_debian_msg"
109+
sleep 2s
110+
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
111+
112+
else
113+
echo "$error_email_msg"
114+
fi
115+
cd $script_dir_first
116+
unlink $0
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
# Ubuntu系列自动安装zerotier 并设置的为planet服务器
3+
# addr服务器公网ip+port
4+
# Github海外节点脚本
5+
ip=`wget http://ipecho.net/plain -O - -q ; echo`
6+
addr=$ip/10802
7+
apt autoremove
8+
apt update -y
9+
apt install curl -y
10+
echo "*******************************************************************************************************"
11+
echo "**********Ubuntu系列自动安装zerotier 并设置的为planet服务器 放在root目录执行**********************************"
12+
curl -s https://install.zerotier.com/ | sudo bash
13+
14+
identity=`cat /var/lib/zerotier-one/identity.public`
15+
echo "identity :$identity=============================================="
16+
apt-get -y install build-essential
17+
apt-get install git -y
18+
git clone https://github.com/TcDhlPro/ZeroTierOne.git
19+
cd ./ZeroTierOne/attic/world/
20+
sed -i '/roots.push_back/d' ./mkworld.cpp
21+
sed -i '/roots.back()/d' ./mkworld.cpp
22+
sed -i '85i roots.push_back(World::Root());' ./mkworld.cpp
23+
sed -i '86i roots.back().identity = Identity(\"'"$identity"'\");' ./mkworld.cpp
24+
sed -i '87i roots.back().stableEndpoints.push_back(InetAddress(\"'"$addr"'\"));' ./mkworld.cpp
25+
source ./build.sh
26+
./mkworld
27+
mv ./world.bin ./planet
28+
\cp -r ./planet /var/lib/zerotier-one/
29+
\cp -r ./planet /root
30+
systemctl restart zerotier-one.service
31+
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
32+
sudo dpkg -i ztncui_0.8.7_amd64.deb
33+
cd /opt/key-networks/ztncui/
34+
echo "HTTPS_PORT = 10801" >>./.env
35+
secret=`cat /var/lib/zerotier-one/authtoken.secret`
36+
echo "ZT_TOKEN = $secret" >>./.env
37+
echo "ZT_ADDR=127.0.0.1:10802" >>./.env
38+
echo "NODE_ENV = production" >>./.env
39+
echo "HTTP_ALL_INTERFACES=yes" >>./.env
40+
systemctl restart ztncui
41+
rm -rf /root/ZeroTierOne
42+
FILE="/var/lib/zerotier-one/local.conf"
43+
echo ">>>>>正在初始化..."
44+
sleep 5s
45+
echo -e "{" > $FILE
46+
echo -e "\t\"settings\":"{"" >> $FILE
47+
echo -e "\t\t\"primaryPort\":"10802"" >> $FILE
48+
echo -e "\t}" >> $FILE
49+
echo -e "}" >> $FILE
50+
echo
51+
systemctl restart zerotier-one.service
52+
echo ">>>>>初始化完成!"
53+
echo ">>>>>注意防火墙或运营商处开放的端口 TCP:10801"
54+
echo ">>>>>注意防火墙或运营商处开放的端口 TCP/UDP:10802"
55+
echo ">>>>>安装成功 | https://$ip:10801 | 初始帐号:admin/初始密码:password"
56+
echo ">>>>>Planet文件路径,两者取其一(/root/planet)(/var/lib/zerotier-one/planet)"
57+
rm -rf /root/zertotier_planet_debian.sh
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Redhat系列自动安装zerotier 并设置的为planet服务器
3+
# addr服务器公网ip+port
4+
# Github海外节点脚本
5+
ip=`wget http://ipecho.net/plain -O - -q ; echo`
6+
addr=$ip/10802
7+
8+
echo "********************************************************************************************************************"
9+
echo "********** Redhat系列自动安装zerotier 并设置的为planet服务器 放在root目录执行**********************************"
10+
curl -s https://install.zerotier.com/ | sudo bash
11+
12+
identity=`cat /var/lib/zerotier-one/identity.public`
13+
echo "identity :$identity=============================================="
14+
yum install gcc gcc-c++ -y
15+
yum install git -y
16+
git clone https://github.com/TcDhlPro/ZeroTierOne.git
17+
cd ./ZeroTierOne/attic/world/
18+
sed -i '/roots.push_back/d' ./mkworld.cpp
19+
sed -i '/roots.back()/d' ./mkworld.cpp
20+
sed -i '85i roots.push_back(World::Root());' ./mkworld.cpp
21+
sed -i '86i roots.back().identity = Identity(\"'"$identity"'\");' ./mkworld.cpp
22+
sed -i '87i roots.back().stableEndpoints.push_back(InetAddress(\"'"$addr"'\"));' ./mkworld.cpp
23+
source ./build.sh
24+
./mkworld
25+
mv ./world.bin ./planet
26+
\cp -r ./planet /var/lib/zerotier-one/
27+
\cp -r ./planet /root
28+
systemctl restart zerotier-one.service
29+
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
30+
rpm -ivh ztncui-0.8.7-1.x86_64.rpm
31+
cd /opt/key-networks/ztncui/
32+
echo "HTTPS_PORT = 10801" >>./.env
33+
secret=`cat /var/lib/zerotier-one/authtoken.secret`
34+
echo "ZT_TOKEN = $secret" >>./.env
35+
echo "ZT_ADDR=127.0.0.1:10802" >>./.env
36+
echo "NODE_ENV = production" >>./.env
37+
echo "HTTP_ALL_INTERFACES=yes" >>./.env
38+
systemctl restart ztncui
39+
rm -rf /root/ZeroTierOne
40+
FILE="/var/lib/zerotier-one/local.conf"
41+
echo ">>>>>正在初始化..."
42+
sleep 5s
43+
echo -e "{" > $FILE
44+
echo -e "\t\"settings\":"{"" >> $FILE
45+
echo -e "\t\t\"primaryPort\":"10802"" >> $FILE
46+
echo -e "\t}" >> $FILE
47+
echo -e "}" >> $FILE
48+
echo
49+
systemctl restart zerotier-one.service
50+
echo ">>>>>初始化完成!"
51+
echo ">>>>>注意防火墙或运营商处开放的端口 TCP:10801"
52+
echo ">>>>>注意防火墙或运营商处开放的端口 TCP/UDP:10802"
53+
echo ">>>>>安装成功 | https://$ip:10801 | 初始帐号:admin/初始密码:password"
54+
echo ">>>>>Planet文件路径,两者取其一(/root/planet)(/var/lib/zerotier-one/planet)"
55+
rm -rf /root/zertotier_planet_redhat.sh

0 commit comments

Comments
 (0)