summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
Diffstat (limited to 'extras')
-rwxr-xr-xextras/bash/packagecloud_attic_cleanup.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/extras/bash/packagecloud_attic_cleanup.sh b/extras/bash/packagecloud_attic_cleanup.sh
new file mode 100755
index 000000000..6312510af
--- /dev/null
+++ b/extras/bash/packagecloud_attic_cleanup.sh
@@ -0,0 +1,29 @@
+#! /bin/bash
+
+set -euo pipefail
+
+attic_repo='fdio/attic'
+packages_json='/tmp/pkgs.json'
+packagecloud_user="$HOME/.ssh/.packagecloud.user"
+# shellcheck disable=SC2064
+trap "rm -f $packages_json" SIGHUP SIGINT SIGQUIT EXIT
+
+get_more_packages() {
+ rm -f $packages_json
+ echo "Retrieving packages from packagecloud.io/$attic_repo"
+ # shellcheck disable=SC2086
+ curl -s https://"$(cat $packagecloud_user)"/api/v1/repos/$attic_repo/packages.json | jq . > $packages_json
+}
+
+get_more_packages
+while [ -n "$(cat $packages_json)" ] ; do
+ for pkg in $(cat $packages_json | jq '.[].destroy_url' | xargs) ; do
+ # shellcheck disable=SC2086
+ echo "Deleting $(basename $pkg)"
+ # shellcheck disable=SC2086
+ curl -sX DELETE "https://$(cat $packagecloud_user)$pkg" >& /dev/null
+ done
+ echo
+ get_more_packages
+done
+echo "No more packages in '$attic_repo'!"