29 lines
739 B
Bash
Executable File
29 lines
739 B
Bash
Executable File
#! /usr/bin/env bash
|
|
|
|
set -o pipefail
|
|
set -o errexit
|
|
set -o nounset
|
|
|
|
: "${DOMAIN:?specify domain name}"
|
|
|
|
EXPECTED_RESPONSE="[]"
|
|
received_response="$(\
|
|
ssh -o StrictHostKeyChecking=no -lroot "$DOMAIN" systemctl --state=activating,failed -o json \
|
|
| jq --sort-keys)"
|
|
|
|
jq . <(printf "%s" "$received_response")
|
|
|
|
if diff --color=always <(printf "%s\n" "$EXPECTED_RESPONSE") <(printf "%s\n" "$received_response") 2>/dev/null
|
|
then
|
|
echo -e "\e[1;32mOK\e[0m"
|
|
else
|
|
echo -e "\e[1;31mFAIL: response does not match!"
|
|
if type jd > /dev/null; then
|
|
jd -color <(printf "%s" "$EXPECTED_RESPONSE") <(printf "%s" "$received_response")
|
|
else
|
|
echo "expected:"
|
|
printf "%s" "$EXPECTED_RESPONSE"
|
|
fi
|
|
exit 1
|
|
fi
|