feat(version): add core version check for Hysteria2 service
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import requests
|
import requests
|
||||||
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from init_paths import *
|
from init_paths import *
|
||||||
from paths import *
|
from paths import *
|
||||||
@ -21,9 +22,35 @@ def version_greater_equal(version1, version2):
|
|||||||
elif version1_parts[i] < version2_parts[i]:
|
elif version1_parts[i] < version2_parts[i]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# If we get here, they're equal
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def check_core_version():
|
||||||
|
try:
|
||||||
|
service_active = subprocess.run(
|
||||||
|
["systemctl", "is-active", "--quiet", "hysteria-server.service"]
|
||||||
|
).returncode == 0
|
||||||
|
|
||||||
|
if service_active:
|
||||||
|
result = subprocess.run(
|
||||||
|
["hysteria", "version"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=True
|
||||||
|
)
|
||||||
|
output = result.stdout
|
||||||
|
version_line = next(
|
||||||
|
(line for line in output.splitlines() if line.startswith("Version:")), None
|
||||||
|
)
|
||||||
|
|
||||||
|
if version_line:
|
||||||
|
version = version_line.split()[1]
|
||||||
|
print(f"Hysteria2 Core Version: {version}")
|
||||||
|
|
||||||
|
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||||
|
pass
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error checking Hysteria2 Core version: {e}", file=sys.stderr)
|
||||||
|
|
||||||
def check_version():
|
def check_version():
|
||||||
try:
|
try:
|
||||||
with open(LOCALVERSION, 'r') as f:
|
with open(LOCALVERSION, 'r') as f:
|
||||||
@ -48,6 +75,7 @@ def show_version():
|
|||||||
local_version = f.read().strip()
|
local_version = f.read().strip()
|
||||||
|
|
||||||
print(f"Panel Version: {local_version}")
|
print(f"Panel Version: {local_version}")
|
||||||
|
check_core_version()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error showing version: {e}", file=sys.stderr)
|
print(f"Error showing version: {e}", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user