Skip to content

Cloudwatch Agent does not Install in Chroot'ed Environments #1925

@ncheenu

Description

@ncheenu

Describe the bug
From version v1.3.00060.0, the postinstall script of the debian installer of Amazon Cloud Watch Agent is erroring out saying that the system does not support System V Init

Steps to reproduce

  1. Create a chroot of Debian 12 or Ubuntu noble.
  2. Download the latest version of amazon-cloudwatch-agent.deb (v1.300060.0)
  3. Inside chroot, do dpkg -i amazon-cloudwatch-agent.deb
  4. Installer will fail in Post Install saying 'sysv-init is not supported'

What did you expect to see?

  1. Installation must go through without erroring out.
  2. The chroot'ed environment does have systemctl.

What did you see instead?

  1. Installer will fail in Post Install saying 'sysv-init is not supported'

What version did you use?
Version: v.1.300060.0

What config did you use?
Config: N/A

Environment
OS: Ubuntu 24.04

Additional context

  1. postinstall script calls amazon-cloudwatch-agent-ctl
  2. Code in amazon-cloudwatch-agent-ctl that checks for Sysv-Init is incorrect and will not work in chroot'ed environments. systemctl command (Line 391) will always fail inside a chroot'ed environment.

Code snippet below (Commit #da27bf33f)

388      # detect which init system is in use
389      if [ "$(/sbin/init --version 2>/dev/null | grep -c upstart)" = 1 ]; then
390           SYSTEMD='false'
391      elif [ "$(systemctl | grep -c -E '\-\.mount\s')" = 1 ]; then
392           SYSTEMD='true'
393      elif [ -f /etc/init.d/cron ] && [ ! -h /etc/init.d/cron ]; then
394           echo "sysv-init is not supported" >&2
395           exit 1
396      else
397           echo "unknown init system" >&2
398           exit 1
399      fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions