Skip to content

Instantly share code, notes, and snippets.

@vicariousdrama
Created January 14, 2024 20:15
Show Gist options
  • Save vicariousdrama/fc1a47d5c7daa4572c76f4603fcd1106 to your computer and use it in GitHub Desktop.
Save vicariousdrama/fc1a47d5c7daa4572c76f4603fcd1106 to your computer and use it in GitHub Desktop.
Jam Systems Data Dumps
rhost=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' deployment-pantryredis-1)
rcursor=-1
while [[ "$rcursor" -ne 0 ]]; do
if [[ "$rcursor" -eq -1 ]]
then
rcursor=0
fi
rdata=$(redis-cli -h "$rhost" SCAN "$rcursor" MATCH "identities/*")
rcursor=$(expr "$rdata" : '\([0-9]*[0-9 ]\)')
keys=${rdata//$rcursor/}
if [ -n "$keys" ]; then
for k in $keys
do
echo "---"
echo "${k}"
rdata2=$(redis-cli -h "$rhost" GET "${k}")
echo $rdata2 | jq -r '.name, .identities[0].id | select(. != null)'
done
fi
done
rhost=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' deployment-pantryredis-1)
rcursor=-1
while [[ "$rcursor" -ne 0 ]]; do
if [[ "$rcursor" -eq -1 ]]
then
rcursor=0
fi
rdata=$(redis-cli -h "$rhost" SCAN "$rcursor" MATCH "identities/*")
rcursor=$(expr "$rdata" : '\([0-9]*[0-9 ]\)')
keys=${rdata//$rcursor/}
if [ -n "$keys" ]; then
for k in $keys
do
rdata2=$(redis-cli -h "$rhost" GET "${k}")
echo $rdata2 | jq -r '.identities[0].id | select( . != null)'
done
fi
done
rhost=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' deployment-pantryredis-1)
rcursor=-1
while [[ "$rcursor" -ne 0 ]]; do
if [[ "$rcursor" -eq -1 ]]
then
rcursor=0
fi
rdata=$(redis-cli -h "$rhost" SCAN "$rcursor" MATCH "rooms/*")
rcursor=$(expr "$rdata" : '\([0-9]*[0-9 ]\)')
rkeys=${rdata//$rcursor/}
if [ -n "$rkeys" ]; then
for rk in $rkeys
do
echo "---"
echo "RoomID: ${rk}"
rdata2=$(redis-cli -h "$rhost" GET "${rk}")
roomname=$(echo $rdata2 | jq -r '.name')
echo "Name: ${roomname}"
moderators=$(echo $rdata2 | jq -r '.moderators')
echo "Moderators:"
for mk in $(echo "${moderators}" | jq -r '.[]')
do
echo " - ${mk}"
iddata=$(redis-cli -h "$rhost" GET "identities/${mk}")
idname=$(echo $iddata | jq -r '.name')
idtype=$(echo $iddata | jq -r '.identities[0].type')
idnpub=$(echo $iddata | jq -r '.identities[0].id')
echo " name: ${idname}"
echo " npub: ${idnpub}"
done
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment