Skip to content

Instantly share code, notes, and snippets.

@xbalaji
Last active August 1, 2020 19:41
Show Gist options
  • Save xbalaji/5a36a9c2acc99d2388479448d6f5229b to your computer and use it in GitHub Desktop.
Save xbalaji/5a36a9c2acc99d2388479448d6f5229b to your computer and use it in GitHub Desktop.
firefox-delete-temporary-containers.sh
#!/bin/bash
# cleanup containers.json (remove tmp containers, sort them by name)
# open command prompt in profiles directory and execute
cp containers.json c01.json
jq -r '.' c01.json | tr -d '\r' | tac | sed '/name.*tmp/{n;N;N;N;N;d}' | tac | sed '/name.*tmp/,+1d' | yq '.' | jq '.identities|=sort_by(.name)' > containers.json
preserve=""
for id in $(jq -r '.identities[] | .userContextId' containers.json | tr -d '\r' | sort -rn); do
preserve="$id\|$preserve"
done;
# delete the unused containers from storage
find storage/default -mindepth 1 -maxdepth 1 -type d -name "about*" -regex ".*\^userContextId=[0-9]+\$" -not -regex ".*\^userContextId=\($preserve\)\$" -exec rm -rf {} \;
@xbalaji
Copy link
Author

xbalaji commented Jul 31, 2020

make it public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment