mumble.chapril.org-tools/active_web_users

32 lines
948 B
Plaintext
Raw Normal View History

#! /bin/bash
# Parse mumble logs in order to determine if someone is currently accessing
# mumble through the WebUI. If not it means we can safely restart nginx
# on the reverse-proxy side without bothering anyone :)
MUMBLE_LOG=/var/log/mumble-server/mumble-server.log
main() {
candidates=$(last_connections)
for candidate in ${candidates}; do
grep "<${candidate}:" "${MUMBLE_LOG}" | tail -n 1 | grep -q 'Connection closed'
if [ $? -ne 0 ]; then
echo "At least one person is currently using mumble's Web interface."
grep "<${candidate}:" "${MUMBLE_LOG}" | tail -n 5
exit 1
fi
done
echo "It looks like nobody is currently using mumble's Web interface. You may restart nginx if you want ;)"
exit 0
}
last_connections() {
grep 'Client.*Node.js' "${MUMBLE_LOG}" \
| tail -n 10 \
| sed -r 's/^.*=> <([0-9]+):\(-1\)>.*$/\1/' \
| tac
}
main