fix status 6
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 9s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 9s
This commit is contained in:
@@ -123,8 +123,11 @@ def get_unit_fragment_path(service_name: str) -> Optional[str]:
|
|||||||
|
|
||||||
def parse_unit_execstart(service_name: str) -> Dict:
|
def parse_unit_execstart(service_name: str) -> Dict:
|
||||||
"""
|
"""
|
||||||
Parse ExecStart using systemctl --no-pager show (canonical).
|
Parser for ExecStart using systemctl --no-pager show.
|
||||||
Handles structured ExecStart blobs with argv[] entries.
|
- reconstructs argv[] entries if systemd returns a structured blob
|
||||||
|
- finds /srv/fw-scripts/<name>.py anywhere in the commandline
|
||||||
|
- extracts the first integer after the script as qnum
|
||||||
|
Returns a dict: {service, exec_start, name, script_path, qnum, extra}
|
||||||
"""
|
"""
|
||||||
unit = service_name if service_name.endswith(".service") else service_name + ".service"
|
unit = service_name if service_name.endswith(".service") else service_name + ".service"
|
||||||
|
|
||||||
@@ -160,20 +163,24 @@ def parse_unit_execstart(service_name: str) -> Dict:
|
|||||||
|
|
||||||
exec_start = raw
|
exec_start = raw
|
||||||
|
|
||||||
# Handle structured ExecStart: { path=... ; argv[]=... ; ... }
|
# If structured with argv[] entries, extract them (allow newlines).
|
||||||
if "argv[]=" in raw:
|
if "argv[]=" in raw:
|
||||||
# extract argv[] entries safely, across spaces/newlines
|
|
||||||
argv_entries = re.findall(r'argv\[\]=([^;]+)', raw, flags=re.DOTALL)
|
argv_entries = re.findall(r'argv\[\]=([^;]+)', raw, flags=re.DOTALL)
|
||||||
argv_parts = [a.strip() for a in argv_entries if a.strip()]
|
argv_parts = []
|
||||||
|
for a in argv_entries:
|
||||||
|
v = a.strip()
|
||||||
|
# strip surrounding quotes if present
|
||||||
|
if (v.startswith('"') and v.endswith('"')) or (v.startswith("'") and v.endswith("'")):
|
||||||
|
v = v[1:-1]
|
||||||
|
if v:
|
||||||
|
argv_parts.append(v)
|
||||||
if argv_parts:
|
if argv_parts:
|
||||||
exec_start = " ".join(argv_parts)
|
exec_start = " ".join(argv_parts)
|
||||||
|
|
||||||
# Extract script path
|
# Look for /srv/fw-scripts/<name>.py directly
|
||||||
m = re.search(
|
m = re.search(r'(/srv/fw-scripts/(?P<name>[A-Za-z0-9_.-]+)\.py)\b', exec_start)
|
||||||
r'(/[^ \t\n\r"]*/srv/fw-scripts/(?P<name>[A-Za-z0-9_.-]+)\.py)\b',
|
|
||||||
exec_start,
|
|
||||||
)
|
|
||||||
if not m:
|
if not m:
|
||||||
|
# return raw exec_start but no parsed metadata
|
||||||
return {
|
return {
|
||||||
"service": service_name,
|
"service": service_name,
|
||||||
"exec_start": exec_start,
|
"exec_start": exec_start,
|
||||||
@@ -186,11 +193,10 @@ def parse_unit_execstart(service_name: str) -> Dict:
|
|||||||
script_path = m.group(1)
|
script_path = m.group(1)
|
||||||
name = m.group("name")
|
name = m.group("name")
|
||||||
|
|
||||||
# Extract queue number (first integer after script path)
|
# Find first integer token after the script path (queue number)
|
||||||
after = exec_start[m.end():].strip()
|
after = exec_start[m.end():].strip()
|
||||||
qnum = None
|
qnum = None
|
||||||
extra = None
|
extra = None
|
||||||
|
|
||||||
if after:
|
if after:
|
||||||
tokens = after.split()
|
tokens = after.split()
|
||||||
for i, t in enumerate(tokens):
|
for i, t in enumerate(tokens):
|
||||||
@@ -198,7 +204,7 @@ def parse_unit_execstart(service_name: str) -> Dict:
|
|||||||
val = int(t)
|
val = int(t)
|
||||||
if 0 <= val <= 65535:
|
if 0 <= val <= 65535:
|
||||||
qnum = val
|
qnum = val
|
||||||
extra = " ".join(tokens[i + 1 :]) if i + 1 < len(tokens) else ""
|
extra = " ".join(tokens[i+1:]) if i+1 < len(tokens) else ""
|
||||||
break
|
break
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user