|
| 1 | +#!/bin/bash |
| 2 | +set -eux |
| 3 | +# This does not work with a symlink to this script |
| 4 | +# SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 5 | +# See https://stackoverflow.com/a/246128/24637657 |
| 6 | +SOURCE=${BASH_SOURCE[0]} |
| 7 | +while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
| 8 | + SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) |
| 9 | + SOURCE=$(readlink "$SOURCE") |
| 10 | + # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
| 11 | + [[ $SOURCE != /* ]] && SOURCE=$SCRIPT_DIR/$SOURCE |
| 12 | +done |
| 13 | +SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) |
| 14 | + |
| 15 | +REPO_ROOT=${REPO_ROOT:-$SCRIPT_DIR/..} |
| 16 | + |
| 17 | +# Check for /etc/init.d/xxx script to run the agent |
| 18 | +WORKDIR=${WORKDIR:-/tmp/rpmcontents} |
| 19 | +rm -rf "${WORKDIR:?}/*" |
| 20 | +mkdir -p "$WORKDIR" |
| 21 | +find "$REPO_ROOT/source/packaging/packages/centos/6/" -type f -name '*x86_64.rpm' -print0 | |
| 22 | +while IFS= read -r -d '' line; do |
| 23 | + echo "Extracting $line" |
| 24 | + docker run --rm -t \ |
| 25 | + -v "${WORKDIR}:/rpmcontents" \ |
| 26 | + -v "$line:/test.rpm:ro" \ |
| 27 | + registry.access.redhat.com/ubi9:9.5 \ |
| 28 | + /bin/sh -c 'cd /rpmcontents && yum install -y cpio && rpm2cpio /test.rpm | cpio -idmv' |
| 29 | +done |
| 30 | + |
| 31 | +if [[ -f "${WORKDIR}/etc/init.d/fluent-bit" ]]; then |
| 32 | + echo "INFO: Found fluent-bit init.d script" |
| 33 | +elif [[ -f "${WORKDIR}/etc/init.d/fluentdo-agent" ]]; then |
| 34 | + echo "INFO: Found fluentdo-agent init.d script" |
| 35 | +else |
| 36 | + echo "ERROR: Unable to find init.d script" |
| 37 | + ls -lRh "$WORKDIR" |
| 38 | + exit 1 |
| 39 | +fi |
0 commit comments