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:
|
||||
"""
|
||||
Parse ExecStart using systemctl --no-pager show (canonical).
|
||||
Handles structured ExecStart blobs with argv[] entries.
|
||||
Parser for ExecStart using systemctl --no-pager show.
|
||||
- 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"
|
||||
|
||||
@@ -160,20 +163,24 @@ def parse_unit_execstart(service_name: str) -> Dict:
|
||||
|
||||
exec_start = raw
|
||||
|
||||
# Handle structured ExecStart: { path=... ; argv[]=... ; ... }
|
||||
# If structured with argv[] entries, extract them (allow newlines).
|
||||
if "argv[]=" in raw:
|
||||
# extract argv[] entries safely, across spaces/newlines
|
||||
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:
|
||||
exec_start = " ".join(argv_parts)
|
||||
|
||||
# Extract script path
|
||||
m = re.search(
|
||||
r'(/[^ \t\n\r"]*/srv/fw-scripts/(?P<name>[A-Za-z0-9_.-]+)\.py)\b',
|
||||
exec_start,
|
||||
)
|
||||
# Look for /srv/fw-scripts/<name>.py directly
|
||||
m = re.search(r'(/srv/fw-scripts/(?P<name>[A-Za-z0-9_.-]+)\.py)\b', exec_start)
|
||||
if not m:
|
||||
# return raw exec_start but no parsed metadata
|
||||
return {
|
||||
"service": service_name,
|
||||
"exec_start": exec_start,
|
||||
@@ -186,11 +193,10 @@ def parse_unit_execstart(service_name: str) -> Dict:
|
||||
script_path = m.group(1)
|
||||
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()
|
||||
qnum = None
|
||||
extra = None
|
||||
|
||||
if after:
|
||||
tokens = after.split()
|
||||
for i, t in enumerate(tokens):
|
||||
@@ -198,7 +204,7 @@ def parse_unit_execstart(service_name: str) -> Dict:
|
||||
val = int(t)
|
||||
if 0 <= val <= 65535:
|
||||
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
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user