代码拉取完成,页面将自动刷新
#!/bin/sh
# usage ./startup.sh -4 1.2.3.4 -6 2001:abcd:abcd::1 -p 9993
moon_port=9993 # default ZeroTier moon port
while getopts "4:6:p:" arg # handle args
do
case $arg in
4)
ipv4_address="$OPTARG"
echo "IPv4 address: $ipv4_address"
;;
6)
ipv6_address="$OPTARG"
echo "IPv6 address: $ipv6_address"
;;
p)
moon_port="$OPTARG"
echo "Moon port: $moon_port"
;;
?)
echo "unknown argument"
exit 1
;;
esac
done
stableEndpointsForSed=""
if [ -z ${ipv4_address+x} ]
then # ipv4 address is not set
if [ -z ${ipv6_address+x} ]
then # ipv6 address is not set
echo "Please set IPv4 address or IPv6 address."
exit 0
else # ipv6 address is set
stableEndpointsForSed="\"$ipv6_address\/$moon_port\""
fi
else # ipv4 address is set
if [ -z ${ipv6_address+x} ]
then # ipv6 address is not set
stableEndpointsForSed="\"$ipv4_address\/$moon_port\""
else # ipv6 address is set
stableEndpointsForSed="\"$ipv4_address\/$moon_port\",\"$ipv6_address\/$moon_port\""
fi
fi
if [ -d "/var/lib/zerotier-one/moons.d" ] # check if the moons conf has generated
then
moon_id=$(cat /var/lib/zerotier-one/identity.public | cut -d ':' -f1)
echo -e "Your ZeroTier moon id is \033[0;31m$moon_id\033[0m, you could orbit moon using \033[0;31m\"zerotier-cli orbit $moon_id $moon_id\"\033[0m"
/usr/sbin/zerotier-one
else
nohup /usr/sbin/zerotier-one >/dev/null 2>&1 &
# Waiting for identity generation...'
while [ ! -f /var/lib/zerotier-one/identity.secret ]; do
sleep 1
done
/usr/sbin/zerotier-idtool initmoon /var/lib/zerotier-one/identity.public >>/var/lib/zerotier-one/moon.json
sed -i 's/"stableEndpoints": \[\]/"stableEndpoints": ['$stableEndpointsForSed']/g' /var/lib/zerotier-one/moon.json
/usr/sbin/zerotier-idtool genmoon /var/lib/zerotier-one/moon.json > /dev/null
mkdir /var/lib/zerotier-one/moons.d
mv *.moon /var/lib/zerotier-one/moons.d/
pkill zerotier-one
moon_id=$(cat /var/lib/zerotier-one/moon.json | grep \"id\" | cut -d '"' -f4)
echo -e "Your ZeroTier moon id is \033[0;31m$moon_id\033[0m, you could orbit moon using \033[0;31m\"zerotier-cli orbit $moon_id $moon_id\"\033[0m"
exec /usr/sbin/zerotier-one
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。