Añadir status_github.sh

This commit is contained in:
Manuel Vergara 2023-05-11 08:19:57 +00:00
parent 79cb508775
commit adee4469c2

26
src/status_github.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/bash
color_cyan=$(tput setaf 6)
color_purple=$(tput setaf 5)
color_reset=$(tput sgr0)
translate_state() {
case $1 in
"operational") echo "operativo" ;;
"partial_outage") echo "interrupción parcial" ;;
"maintenance") echo "mantenimiento" ;;
"major_outage") echo "interrupción importante" ;;
*) echo "$1" ;;
esac
}
curl -s https://www.githubstatus.com/api/v2/components.json | jq -r '.components[] | "\(.name),\(.status)"' | \
while IFS=',' read -r component state; do
component=$(echo "$component" | sed "s/'//g")
state=$(echo "$state" | sed "s/'//g")
if [ "$component" = "Visit www.githubstatus.com for more information" ]; then
continue
fi
state=$(translate_state "$state")
printf ' - %s%s%s está %s%s%s.\n' "$color_cyan" "$component" "$color_reset" "$color_purple" "$state" "$color_reset"
done