Skip to content

fix(linux-scripts): fix linux scripts when systemd is degraded + imp… (#5871)#200

Open
MarineLeM wants to merge 1 commit into
mainfrom
issue/5871
Open

fix(linux-scripts): fix linux scripts when systemd is degraded + imp… (#5871)#200
MarineLeM wants to merge 1 commit into
mainfrom
issue/5871

Conversation

@MarineLeM

@MarineLeM MarineLeM commented Jun 26, 2026

Copy link
Copy Markdown

Problem Information :

systemctl is-system-running returns a non-zero exit code for any state other than running (e.g. degraded → exit code 1). Combined with set -e, this causes the script to exit immediately, even though degraded is an acceptable state.
Moreover, the script exits silently without any details about what failed

Proposed changes

  • Capture the systemd state without triggering set -e:
    systemd_status=$(systemctl is-system-running 2>/dev/null || true)
    Then explicitly handle each state — accepting running and degraded, otherwise stopping the script with a clear error message.
  • Improve error handling by introducing two helpers:
    - run() — wraps any command and calls die on failure
    - die() — logs the exact command that failed and exits

Testing Instructions

  1. Use linux machine where systemd is degraded
    • to check systemd status : systemctl is-system-running
  2. install openaev agent
  3. the installation should work

Related issues

@github-actions

Copy link
Copy Markdown

Thank you for your contribution. This PR is but one step away from being ready for merging: all commits must be PGP-signed. To get started, please see https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@github-actions github-actions Bot added the filigran team Item from the Filigran team. label Jun 26, 2026
@Filigran-Automation Filigran-Automation changed the title fix(linux-scripts) : fix linux scripts when systemd is degraded + imp… fix(linux-scripts): fix linux scripts when systemd is degraded + imp… (#5871) Jun 26, 2026
@Filigran-Automation

Copy link
Copy Markdown
Contributor

🤖 [AI-generated]

Hey @MarineLeM! 👋 Thanks a lot for opening PR #200 — really appreciate the fix for the degraded-systemd installation path! 🙏

I just had a quick look and I think the description could be enhanced a little to help reviewers get through it faster. I haven't changed anything in your description — just a gentle suggestion:

Area What could help Suggestion
### Proposed changes The two bullets are currently empty, so reviewers can't see what changed or why A couple of lines on what was adjusted across the 6 installer/upgrade scripts (e.g. how degraded systemd is detected/handled) and why it fixes the failing install

Nice touch already having concrete Testing Instructions and the linked issue (#5871) — that really helps! 🙌

💡 If helpful, the contribution conventions / PR template walk through what to include.

No rush at all — thanks again for contributing to OpenAEV! 🚀

@MarineLeM MarineLeM self-assigned this Jun 26, 2026
@MarineLeM MarineLeM marked this pull request as ready for review June 26, 2026 12:16
Copilot AI review requested due to automatic review settings June 26, 2026 12:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Linux installer/upgrade shell scripts to tolerate systemctl is-system-running returning a non-zero exit code for acceptable states (notably degraded) and to improve failure diagnostics by introducing small log/die/run helpers.

Changes:

  • Capture systemd status without tripping set -e and treat running + degraded as acceptable states.
  • Introduce log(), die(), and run() helpers to standardize error handling and messages.
  • Improve install-time filesystem checks and replace silent exits with explicit error messages.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
installer/linux/agent-upgrade.sh Adds log/die/run and systemd-state handling; refactors upgrade + reinstall flow.
installer/linux/agent-upgrade-session-user.sh Same systemd-state handling + helper functions for session-user upgrade path.
installer/linux/agent-upgrade-service-user.sh Same systemd-state handling + helper functions for service-user upgrade path.
installer/linux/agent-installer.sh Same systemd-state handling + helper functions; improves install directory checks and service setup flow.
installer/linux/agent-installer-session-user.sh Same systemd-state handling + helper functions for session-user installer path.
installer/linux/agent-installer-service-user.sh Same systemd-state handling + helper functions for service-user installer path and argument validation errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

rm -f ${uninstall_dir}/openbas-agent
systemctl disable ${uninstall_service} --now
) || (echo "Error while uninstalling OpenBAS Agent" >&2 && exit 1)
run curl -sSfLG ${base_url}/api/tenants/${tenant_id}/agent/installer/openaev/${os}/service/${OPENAEV_TOKEN} --data-urlencode "installationDir=${openaev_dir}" --data-urlencode "serviceName=${openaev_service}" | sh
log "01. Installing OpenAEV Agent..."
openaev_session=$(printf %s "${session_name}" | sed 's/openbas/openaev/g')
curl -sSfLG ${base_url}/api/tenants/${tenant_id}/agent/installer/openaev/${os}/session-user/${OPENAEV_TOKEN} --data-urlencode "installationDir=${openaev_dir}" --data-urlencode "serviceName=${openaev_session}" | sh
run curl -sSfLG ${base_url}/api/tenants/${tenant_id}/agent/installer/openaev/${os}/session-user/${OPENAEV_TOKEN} --data-urlencode "installationDir=${openaev_dir}" --data-urlencode "serviceName=${openaev_session}" | sh
Comment on lines +66 to +67
run uninstall_dir=$(printf %s "${install_dir}" | sed 's/openaev/openbas/g')
run uninstall_service=$(printf %s "${service_name}" | sed 's/openaev/openbas/g')
echo "04. Writing agent service"
cat > ${install_dir}/${service_name}.service <<EOF
log "04. Writing agent service"
cat > ${install_dir}/${service_name}.service <<EOF || die "Unable to write ${install_dir}/${session_name}.service"
echo "04. Writing agent service"
cat > ${install_dir}/${service_name}.service <<EOF
log "04. Writing agent service"
cat > ${install_dir}/${service_name}.service <<EOF || die "Unable to write ${install_dir}/${session_name}.service"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

filigran team Item from the Filigran team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Linux agent deployment fails with curl | sh command

3 participants