From ad38c09210541f432e751ea18f7bdbf6d6ea296d Mon Sep 17 00:00:00 2001 From: rowan Date: Sat, 28 Dec 2024 00:16:14 -0600 Subject: [PATCH] initial commit --- Containerfile | 6 ++++++ b2-retention.sh | 14 ++++++++++++++ entrypoint.sh | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 Containerfile create mode 100755 b2-retention.sh create mode 100755 entrypoint.sh diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..1d4dc57 --- /dev/null +++ b/Containerfile @@ -0,0 +1,6 @@ +FROM docker.io/library/python:3.13.1-alpine3.21 +RUN apk --update add jq; pip install b2 +WORKDIR app +ADD b2-retention.sh entrypoint.sh ./ +ENTRYPOINT ["./entrypoint.sh"] + diff --git a/b2-retention.sh b/b2-retention.sh new file mode 100755 index 0000000..0ba056b --- /dev/null +++ b/b2-retention.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +TO_DELETE=$( b2v4 ls b2://"$BUCKET_NAME" | tac | tail -n +8 | tr '\n' ' ' ) + +PIDS="" +for file in $TO_DELETE; do + b2v4 rm "b2://${BUCKET_NAME}/${file}" & + PIDS="$PIDS $!" +done + +for pid in $PIDS; do + wait "${pid}" +done + diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..8bb2654 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +set +e + +./b2-retention.sh +