Skip to content

Instantly share code, notes, and snippets.

@stahnma
Created January 22, 2026 19:24
Show Gist options
  • Select an option

  • Save stahnma/d3461c1109e039b5282ed110654a4139 to your computer and use it in GitHub Desktop.

Select an option

Save stahnma/d3461c1109e039b5282ed110654a4139 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
source creds
# Fetch an Auth0 Management API token using client credentials
auth0_get_token() {
: "${AUTH0_DOMAIN:?Need AUTH0_DOMAIN (e.g. your-tenant.us.auth0.com)}"
: "${AUTH0_CLIENT_ID:?Need AUTH0_CLIENT_ID}"
: "${AUTH0_CLIENT_SECRET:?Need AUTH0_CLIENT_SECRET}"
# Allow override of audience via AUTH0_AUDIENCE if your API domain != login domain
local audience="${AUTH0_AUDIENCE:-https://${AUTH0_DOMAIN}/api/v2/}"
curl -s --request POST \
--url "https://${AUTH0_DOMAIN}/oauth/token" \
--header 'content-type: application/json' \
--data '{
"client_id": "'"$AUTH0_CLIENT_ID"'",
"client_secret": "'"$AUTH0_CLIENT_SECRET"'",
"audience": "'"$audience"'",
"grant_type": "client_credentials"
}' | jq -r '.access_token'
}
# Fetch Auth0 users with include_totals=true&per_page=0
auth0_fetch_users() {
: "${AUTH0_DOMAIN:?Need AUTH0_DOMAIN (e.g. your-tenant.us.auth0.com)}"
local token
token="$(auth0_get_token)"
if [[ -z "$token" || "$token" == "null" ]]; then
echo "error: failed to get access token from auth0_get_token" >&2
return 1
fi
curl -s \
--url "https://${AUTH0_DOMAIN}/api/v2/users?include_totals=true&per_page=0" \
--header "Authorization: Bearer ${token}"
}
# Convenience wrapper: fetch users and pretty-print with jq
auth0_fetch_users_pretty() {
auth0_fetch_users | jq ".total"
}
if [ "$(tailscale status | grep floxem-main-prod | wc -l)" -ne 1 ]; then
echo "This script must be run when connected to the floxem-main-prod Tailscale node."
exit 1
fi
rsync -avx root@floxhub-floxem-main-production:/var/lib/gitolite/repositories .
echo "Gitolite repositories have been fetched to ./repositories"
TOTAL_PUSHING=$(ls -1 repositories/ |wc -l)
let TOTAL_DEFAULTS=0
for user in $(ls -1 repositories/); do
# echo $user
pushd repositories/$user/floxmeta.git &> /dev/null
if (git branch | grep default &> /dev/null); then
TOTAL_DEFAULTS=$((TOTAL_DEFAULTS+1))
fi
popd &> /dev/null
done
TOTAL_SIGNUPS=$(auth0_fetch_users_pretty)
percent_push=$(echo "scale=4; $TOTAL_DEFAULTS / $TOTAL_PUSHING * 100" | bc | awk '{ printf "%.2f\n", $0 }')
percent_total=$(echo "scale=4; $TOTAL_DEFAULTS / $TOTAL_SIGNUPS * 100" | bc | awk '{ printf "%.2f\n", $0 }')
echo
echo
echo "Total Signups: $TOTAL_SIGNUPS"
echo "Users pushing enviornments: $TOTAL_PUSHING"
echo "Users with a default environment: $TOTAL_DEFAULTS"
echo "Percentage of pushing users with 'default' branch: $percent_push %"
echo "Percentage of signups with 'default' branch: $percent_total %"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment