commit ad38c09210541f432e751ea18f7bdbf6d6ea296d Author: rowan Date: Sat Dec 28 00:16:14 2024 -0600 initial commit 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 +