2019-04-14 16:17:07 +02:00
#!/bin/sh
2019-04-14 18:30:38 +02:00
token = " $1 "
2019-04-14 16:17:07 +02:00
running( ) {
name = $1
pgrep -f " $name "
[ $? -eq 0 ]
}
write( ) {
echo " $1 " >> index.html
}
echo_down( ) {
write '<span class="down">down</span>'
}
echo_up( ) {
write '<span class="up">up</span>'
}
check_app( ) {
name = " $1 "
process = " $2 "
write '<tr><td class="first">'
write " $name "
write '</td><td class="second">'
if running " $process " ; then
echo_up
else
echo_down
fi
write '</td></tr>'
}
2019-04-14 18:30:38 +02:00
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
}
2019-04-14 16:17:07 +02:00
cd /usr/share/nginx/html/status
base = ` cat <<EOF
<html><body>
<head><style>
body {
background-color: #000;
color: #ddd;
font-family: "Hack" , "Fira Code" , "Lucida Console" , monospace;
font-size: 16pt;
line-height: 140%;
}
#main {
margin: 3em auto;
2019-04-14 16:30:19 +02:00
width: 60%;
2019-04-14 16:17:07 +02:00
text-align: center;
}
#tbl {
width: 100%;
}
table {
border-collapse: collapse;
}
table td, table th {
border-bottom: 1px solid #444;
padding: 0.5em 1em;
}
table tr:last-child td {
border-bottom: 0;
}
.up {
color: green;
}
.down {
color: red;
}
.first {
width:80%;
}
.second {
width:20%;
2019-04-14 16:30:19 +02:00
text-align: right;
2019-04-14 16:17:07 +02:00
}
footer {
position: fixed;
right: 0;
bottom: 0;
height: 20pt;
2019-04-14 16:30:19 +02:00
color: #888;
2019-04-14 16:17:07 +02:00
font-size: 8pt;
padding-bottom: 0.5em;
padding-right: 0.9em;
}
2019-04-14 18:30:38 +02:00
a {
color: #79c;
text-decoration: none;
}
2019-04-14 16:17:07 +02:00
</style></head>
<div id = 'main' >
<table id = 'tbl' >
EOF
`
echo " $base " > index.html
check_app 'kageru.moe' 'manage.py runserver'
check_app 'kaleido.kageru.moe' 'kaleidowebsite'
check_app 'ts.kageru.moe' 'ts3server_startscript.sh start'
check_app 'git.kageru.moe' '\.\/gitea'
check_app 'Selphybot (discord)' 'selphybot'
check_app 'Colorbot (discord)' '\.\/colorbot'
check_app 'Gmod server' 'gmod\/runserver.sh'
2019-04-14 18:30:38 +02:00
check_twitch 'kageru_' " $token "
2019-04-14 16:17:07 +02:00
write '</table></div>'
write " <footer>Last updated: $( date '+%d.%m.%y at %H:%M:%S' ) "
write '</body></html>'