fix: pass env vars to systemd-run via --setenv (v0.3.5)
- Previous fix failed because systemd-run does not inherit env vars by default - Added explicit --setenv flags for SKD_UPDATE_* variables - Bumped version to 0.3.5
This commit is contained in:
@ -96,6 +96,8 @@ By: Codex (GPT-5)
|
||||
| 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.3 erhoeht. By: Gemini CLI |
|
||||
| 16.01.2026 | 🧪 Test | ID: Patch-Bump auf 0.3.4 zur finalen Verifizierung nach manuellem Git-Pull am Client. By: Gemini CLI |
|
||||
| 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.4 erhoeht. By: Gemini CLI |
|
||||
| 16.01.2026 | 🐞 Fix | ID: Environment-Variablen explizit via --setenv an systemd-run uebergeben (Fix fuer fehlenden Token im Updater). By: Gemini CLI |
|
||||
| 16.01.2026 | 🚀 Release | ID: VERSION auf 0.3.5 erhoeht. By: Gemini CLI |
|
||||
|
||||
---
|
||||
## Legende
|
||||
|
||||
@ -199,30 +199,33 @@ def report_status(
|
||||
|
||||
|
||||
def _run_async(script_path: Path, settings: Settings) -> None:
|
||||
env = os.environ.copy()
|
||||
env["SKD_UPDATE_SERVICE_URL"] = settings.update_service_url
|
||||
env["SKD_UPDATE_PROJECT_ID"] = settings.update_project_id
|
||||
env["SKD_UPDATE_TOKEN"] = _get_fresh_token(settings)
|
||||
env["SKD_UPDATE_STATUS_FILE"] = settings.update_status_file
|
||||
env["SKD_UPDATE_LOG_FILE"] = settings.update_log_file
|
||||
# Explicitly gather the env vars we need to pass
|
||||
env_vars = {
|
||||
"SKD_UPDATE_SERVICE_URL": settings.update_service_url,
|
||||
"SKD_UPDATE_PROJECT_ID": settings.update_project_id,
|
||||
"SKD_UPDATE_TOKEN": _get_fresh_token(settings),
|
||||
"SKD_UPDATE_STATUS_FILE": settings.update_status_file,
|
||||
"SKD_UPDATE_LOG_FILE": settings.update_log_file,
|
||||
}
|
||||
|
||||
# Use systemd-run to detach the update process from the current service unit.
|
||||
# This ensures the script survives 'systemctl stop skd'.
|
||||
# We use --unit to give it a predictable name prefix (though unique suffix is added)
|
||||
# and --scope (or --service) to create a new unit.
|
||||
# Since we need root (and likely run as root), this should work.
|
||||
# Note: --collect ensures garbage collection of the transient unit.
|
||||
# Construct systemd-run command with --setenv for each variable
|
||||
cmd = [
|
||||
"systemd-run",
|
||||
"--unit=skd-update",
|
||||
"--collect",
|
||||
"--description=Safe Kiddo Update Process",
|
||||
str(script_path),
|
||||
]
|
||||
|
||||
for key, val in env_vars.items():
|
||||
if val: # Only pass if not empty
|
||||
cmd.append(f"--setenv={key}={val}")
|
||||
|
||||
cmd.append(str(script_path))
|
||||
|
||||
# We don't pass 'env' parameter to Popen because systemd-run ignores it
|
||||
# for the target process (it only uses it for itself, but we use --setenv).
|
||||
subprocess.Popen(
|
||||
cmd,
|
||||
env=env,
|
||||
cwd="/",
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.DEVNULL,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
ID: STATUS_000001 | Version: 0.3.4 | Status: Final
|
||||
ID: STATUS_000001 | Version: 0.3.5 | Status: Final
|
||||
By: Codex (GPT-5)
|
||||
|
||||
# Projekt-Status
|
||||
|
||||
Reference in New Issue
Block a user