Added twitch stream to status page

This commit is contained in:
kageru 2019-04-14 18:30:38 +02:00
parent 1d3ad7ad29
commit 982c28096e
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -1,4 +1,6 @@
#!/bin/sh
token="$1"
running() {
name=$1
pgrep -f "$name"
@ -31,6 +33,20 @@ check_app() {
write '</td></tr>'
}
check_twitch() {
channel="$1"
token="$2"
write '<tr><td class="first">'
write "<a href='https://twitch.tv/$channel'>My Twitch Stream</a>"
write '</td><td class="second">'
curl https://api.twitch.tv/kraken/streams/$channel -H "Client-ID: $token" -s | grep '"stream_type":"live"'
if [ $? -eq 0 ]; then
echo_up
else
echo_down
fi
}
cd /usr/share/nginx/html/status
base=`cat <<EOF
<html><body>
@ -83,6 +99,10 @@ footer {
padding-bottom: 0.5em;
padding-right: 0.9em;
}
a {
color: #79c;
text-decoration: none;
}
</style></head>
<div id='main'>
<table id='tbl'>
@ -96,6 +116,7 @@ check_app 'git.kageru.moe' '\.\/gitea'
check_app 'Selphybot (discord)' 'selphybot'
check_app 'Colorbot (discord)' '\.\/colorbot'
check_app 'Gmod server' 'gmod\/runserver.sh'
check_twitch 'kageru_' "$token"
write '</table></div>'
write "<footer>Last updated: $(date '+%d.%m.%y at %H:%M:%S')"
write '</body></html>'