mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/scripts.git
synced 2025-10-03 15:01:00 +08:00
21 lines
739 B
Bash
Executable file
21 lines
739 B
Bash
Executable file
#!/bin/sh
|
|
|
|
KEY="$(sed -n '/^env.KEY/ s/^env.KEY \(.*\)/\1/p' /etc/munin/plugin-conf.d/weblate_servers)"
|
|
SERVER="$(sed -n '/^env.SERVER/ s/^env.SERVER \(.*\)/\1/p' /etc/munin/plugin-conf.d/weblate_servers)"
|
|
|
|
if [ -z "$SERVER" ] ; then
|
|
echo "Missing server configuration!"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$KEY" ] ; then
|
|
if ! curl -f -s -H "Authorization: Token $KEY" "${SERVER}api/metrics/" -o /dev/null ; then
|
|
echo "Key not working, recreating"
|
|
KEY=""
|
|
fi
|
|
fi
|
|
|
|
if [ -z "$KEY" ] ; then
|
|
cd /home/weblate/weblate || exit 1
|
|
sudo -u weblate docker compose exec --user weblate weblate weblate shell -c 'from weblate.auth.models import User; user = User.objects.create(username="monitor"); print(user.auth_token.key)'
|
|
fi
|