github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/contrib/cirrus/logcollector.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  
     5  # shellcheck source=contrib/cirrus/lib.sh
     6  source $(dirname $0)/lib.sh
     7  
     8  req_env_vars CIRRUS_WORKING_DIR OS_RELEASE_ID
     9  
    10  # Assume there are other log collection commands to follow - Don't
    11  # let one break another that may be useful, but also keep any
    12  # actual script-problems fatal so they are noticed right away.
    13  showrun() {
    14      echo '+ '$(printf " %q" "$@")
    15      set +e
    16      echo '------------------------------------------------------------'
    17      "$@"
    18      local status=$?
    19      [[ $status -eq 0 ]] || \
    20          echo "[ rc = $status -- proceeding anyway ]"
    21      echo '------------------------------------------------------------'
    22      set -e
    23  }
    24  
    25  case $1 in
    26      audit)
    27          case $OS_RELEASE_ID in
    28              ubuntu) showrun cat /var/log/kern.log ;;
    29              fedora) showrun cat /var/log/audit/audit.log ;;
    30              *) bad_os_id_ver ;;
    31          esac
    32          ;;
    33      df) showrun df -lhTx tmpfs ;;
    34      journal) showrun journalctl -b ;;
    35      podman) showrun ./bin/podman system info ;;
    36      server)
    37        msg "(Trailing 100 lines of $PODMAN_SERVER_LOG)"
    38        if [[ -r "$PODMAN_SERVER_LOG" ]]; then tail -100 $PODMAN_SERVER_LOG; fi
    39         ;;
    40      packages)
    41          # These names are common to Fedora and Ubuntu
    42          PKG_NAMES=(\
    43                      conmon
    44                      containernetworking-plugins
    45                      containers-common
    46                      criu
    47                      crun
    48                      golang
    49                      podman
    50                      runc
    51                      skopeo
    52                      slirp4netns
    53          )
    54          case $OS_RELEASE_ID in
    55              fedora)
    56                  cat /etc/fedora-release
    57                  PKG_LST_CMD='rpm -q --qf=%{N}-%{V}-%{R}-%{ARCH}\n'
    58                  PKG_NAMES+=(\
    59                      aardvark
    60                      container-selinux
    61                      libseccomp
    62                      netavark
    63                  )
    64                  ;;
    65              ubuntu)
    66                  cat /etc/issue
    67                  PKG_LST_CMD='dpkg-query --show --showformat=${Package}-${Version}-${Architecture}\n'
    68                  PKG_NAMES+=(\
    69                      cri-o-runc
    70                      libseccomp2
    71                  )
    72                  ;;
    73              *) bad_os_id_ver ;;
    74          esac
    75          echo "Kernel: " $(uname -r)
    76          echo "Cgroups: " $(stat -f -c %T /sys/fs/cgroup)
    77          # Any not-present packages will be listed as such
    78          $PKG_LST_CMD "${PKG_NAMES[@]}" | sort -u
    79          ;;
    80      time)
    81          # Assumed to be empty/undefined outside of Cirrus-CI (.cirrus.yml)
    82          # shellcheck disable=SC2154
    83          if [[ -r "$STATS_LOGFILE" ]]; then cat "$STATS_LOGFILE"; fi
    84          ;;
    85      *) die "Warning, $(basename $0) doesn't know how to handle the parameter '$1'"
    86  esac