124 lines
2.2 KiB
Bash
Executable File
124 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
token="$1"
|
|
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>'
|
|
}
|
|
|
|
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>
|
|
<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;
|
|
width: 60%;
|
|
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%;
|
|
text-align: right;
|
|
}
|
|
footer {
|
|
position: fixed;
|
|
right: 0;
|
|
bottom: 0;
|
|
height: 20pt;
|
|
color: #888;
|
|
font-size: 8pt;
|
|
padding-bottom: 0.5em;
|
|
padding-right: 0.9em;
|
|
}
|
|
a {
|
|
color: #79c;
|
|
text-decoration: none;
|
|
}
|
|
</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'
|
|
check_twitch 'kageru_' "$token"
|
|
write '</table></div>'
|
|
write "<footer>Last updated: $(date '+%d.%m.%y at %H:%M:%S')"
|
|
write '</body></html>'
|
|
|