27 lines
581 B
Bash
Executable File
27 lines
581 B
Bash
Executable File
#!/bin/bash
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: fsmi.sh <fsi|fsm>"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "$1" == "fsi" ]]; then
|
|
state=$(curl https://www-test.fsmi.org/spaceapi/fsi.json 2>/dev/null | jq .state.open)
|
|
elif [[ "$1" == "fsm" ]]; then
|
|
state=$(curl https://www-test.fsmi.org/spaceapi/fsm.json 2>/dev/null | jq .state.open)
|
|
fi
|
|
|
|
class="fs-closed"
|
|
if [[ "$state" == "true" ]]; then
|
|
class="fs-open"
|
|
elif [[ "$state" == "" ]]; then
|
|
class="fs-unknown"
|
|
fi
|
|
|
|
cat <<EOF | jq -r --unbuffered --compact-output
|
|
{
|
|
"text": "$state",
|
|
"alt": "$1",
|
|
"class": "$class"
|
|
}
|
|
EOF
|