Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
feat: Add TTL purge script
Browse files Browse the repository at this point in the history
Closes #21
  • Loading branch information
jrconlin committed Jun 24, 2020
1 parent 2ee03ae commit 628fe83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ RUN \

FROM debian:buster-slim
# FROM debian:buster # for debugging docker build
MAINTAINER <src+pushbox@jrconlin.com>
RUN \
groupadd --gid 10001 app && \
useradd --uid 10001 --gid 10001 --home /app --create-home app && \
Expand All @@ -28,6 +27,7 @@ RUN \

COPY --from=builder /app/bin /app/bin
COPY --from=builder /app/version.json /app
COPY --from=builder /app/purge.bash /app

WORKDIR /app
USER app
Expand Down
11 changes: 11 additions & 0 deletions purge.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/bash -w
# This presumes login data is stored in .mylogin.cnf,
# $MYSQL_HOST is set to the default mysql host
# & $PUSHBOX_DATABASE is the name of the containing database.
# If the PUSHBOX_DATABASE is not defined, this script will attempt
# to extract it from the `Rocket.toml` file.
if [ "$PUSHBOX_DATABASE" = "" ]; then
echo "Fetching database..."
PUSHBOX_DATABASE=`grep "^database_url" Rocket.toml | sed 's/"//g'| tr '/' "\n" | tail -1`
fi
mysql $PUSHBOX_DATABASE -e "DELETE FROM pushboxv1 WHERE ttl < unix_timestamp();"

0 comments on commit 628fe83

Please sign in to comment.