From 982c28096e74261feae89d7ccc903d41156d477a Mon Sep 17 00:00:00 2001 From: kageru Date: Sun, 14 Apr 2019 18:30:38 +0200 Subject: [PATCH] Added twitch stream to status page --- status.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/status.sh b/status.sh index 4fac83c..3e6ba52 100755 --- a/status.sh +++ b/status.sh @@ -1,4 +1,6 @@ #!/bin/sh + +token="$1" running() { name=$1 pgrep -f "$name" @@ -31,6 +33,20 @@ check_app() { write '' } +check_twitch() { + channel="$1" + token="$2" + write '' + write "My Twitch Stream" + write '' + 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 < @@ -83,6 +99,10 @@ footer { padding-bottom: 0.5em; padding-right: 0.9em; } +a { + color: #79c; + text-decoration: none; +}
@@ -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 '
' write "