cd /var/lib/zerotier-one # current ip CURR_IP=`curl -s http://ip.3322.net` # last ip LAST_IP=`cat moon.json | tr'\n'' ' | sed 's/.*"\([^"]*\)\/\(9993\).*/\1/g'` # eq 如果 IP 不变,则退出 if [ "$CURR_IP" == "$LAST_IP" ] then exit 0 fi # replact ip, get new moon.json,将占位字符串替换成新的 IP sed 's/$endPoint1/'${CURR_IP}'/g' /var/lib/zerotier-one/moon.json.source > /var/lib/zerotier-one/moon.json