| #!/bin/bash |
| st=0 |
| |
| # Check the BMC Version against what was expected |
| source /etc/os-release || st=1 |
| RUNNING_VERSION="${VERSION_ID##*-}" |
| if [[ -z "$EXPECTED_VERSION" ]]; then |
| echo 'Missing EXPECTED_VERSION, please set it before running' >&2 |
| st=1 |
| elif [[ "$EXPECTED_VERSION" != "$RUNNING_VERSION" ]]; then |
| echo "Expected Version ($EXPECTED_VERSION) != Actual Version($RUNNING_VERSION)" >&2 |
| st=1 |
| else |
| echo "Expected Version ($EXPECTED_VERSION) == Actual Version($RUNNING_VERSION)" >&2 |
| fi |
| |
| # Check if we have any failed services |
| if out="$(systemctl --failed)"; then |
| # Command succeeded, check the output |
| if [[ "$out" != *'0 loaded units listed.' ]]; then |
| st=1 |
| echo 'Systemd has failed services!' >&2 |
| echo "$out" >&2 |
| else |
| echo 'No failed systemd services' >&2 |
| fi |
| else |
| # Command failed |
| echo 'Failed to run systemctl --failed' >&2 |
| st=1 |
| fi |
| |
| if (( st == 0 )); then |
| echo 'PASS' |
| exit 0 |
| else |
| echo 'FAIL' |
| exit 1 |
| fi |