mirror of
https://gh.llkk.cc/https://github.com/WeblateOrg/scripts.git
synced 2025-10-03 15:01:00 +08:00
Factor out monitoring user creation
This commit is contained in:
parent
40e2f83ad9
commit
a027cb1a86
2 changed files with 27 additions and 1 deletions
21
create-monitor-user
Executable file
21
create-monitor-user
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/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
|
|
@ -5,6 +5,10 @@ set -e
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
. /etc/weblate-bootstrap
|
. /etc/weblate-bootstrap
|
||||||
|
|
||||||
|
# Set path to include script directory
|
||||||
|
PATH="$(dirname "$(readlink -f "$0")"):$PATH"
|
||||||
|
export PATH
|
||||||
|
|
||||||
# Munin
|
# Munin
|
||||||
mkdir -p /etc/munin/plugin-conf.d/
|
mkdir -p /etc/munin/plugin-conf.d/
|
||||||
cat > /etc/munin/plugin-conf.d/postgres <<EOT
|
cat > /etc/munin/plugin-conf.d/postgres <<EOT
|
||||||
|
@ -30,8 +34,9 @@ chmod +x redis weblate ksm
|
||||||
cat > /etc/munin/plugin-conf.d/weblate_servers <<EOT
|
cat > /etc/munin/plugin-conf.d/weblate_servers <<EOT
|
||||||
[weblate]
|
[weblate]
|
||||||
env.SERVER https://$WEBLATE_DOMAIN/
|
env.SERVER https://$WEBLATE_DOMAIN/
|
||||||
env.KEY $(sudo -u weblate /home/weblate/weblate-env/bin/weblate shell -c 'from weblate.auth.models import User; user = User.objects.create(username="monitor"); print(user.auth_token.key)')
|
env.KEY
|
||||||
EOT
|
EOT
|
||||||
|
create-monitor-user
|
||||||
|
|
||||||
# Install and configure munin
|
# Install and configure munin
|
||||||
# The mkdir is needed on Ubuntu (used for CI)
|
# The mkdir is needed on Ubuntu (used for CI)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue