mirror of
https://github.com/baoweise-bot/aimili-vpngate.git
synced 2026-09-09 09:46:49 +08:00
fix: wait for rebuilt tunnel during updates
This commit is contained in:
+17
-1
@@ -1098,6 +1098,22 @@ if [ -d "/proc/sys/net/ipv4/conf" ]; then
|
||||
fi
|
||||
|
||||
echo -e "\n正在启动 AimiliVPN 服务并初始化网络..."
|
||||
# Avoid treating the previous process' persisted node ID as a successful new
|
||||
# connection during upgrades. The service will replace this startup state.
|
||||
if [ -f "${INSTALL_DIR}/vpngate_data/state.json" ]; then
|
||||
python3 - "${INSTALL_DIR}/vpngate_data/state.json" <<'PY' 2>/dev/null || true
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
state_path = Path(sys.argv[1])
|
||||
state = json.loads(state_path.read_text(encoding="utf-8"))
|
||||
state["active_openvpn_node_id"] = ""
|
||||
state["is_connecting"] = True
|
||||
state["last_check_message"] = "服务正在重启并重新建立加密通道..."
|
||||
state_path.write_text(json.dumps(state, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
PY
|
||||
fi
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
systemctl restart aimilivpn.service || true
|
||||
elif command -v rc-service >/dev/null 2>&1; then
|
||||
@@ -1115,7 +1131,7 @@ for i in {1..90}; do
|
||||
CUR_MSG=$(python3 -c "import json; print(json.load(open('${INSTALL_DIR}/vpngate_data/state.json')).get('last_check_message', ''))" 2>/dev/null || echo "")
|
||||
|
||||
if [ "$IS_CONN" = "False" ] || [ "$IS_CONN" = "false" ]; then
|
||||
if [ -n "$ACTIVE_ID" ]; then
|
||||
if [ -n "$ACTIVE_ID" ] && ip link show dev tun0 >/dev/null 2>&1 && pidof openvpn >/dev/null 2>&1; then
|
||||
echo -e " -> ${GREEN}[已就绪]${PLAIN} 首次节点连接成功,活动节点: ${GREEN}$ACTIVE_ID${PLAIN}"
|
||||
break
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user