Initial commit: welcome-bot, abuse-bot, dormant-sweep, IP signup scrutiny
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# dormant-sweep.sh — cron entrypoint on mammut.
|
||||
#
|
||||
# Pipes dormant_sweep.rb into the Mastodon web container's `rails runner`,
|
||||
# passing config from an env file. Selection AND actions run inside Rails as the
|
||||
# `bot` account, so NO API token or secret is needed on the host.
|
||||
#
|
||||
# Install (on mammut): /root/dormant-sweep/{dormant-sweep.sh,dormant_sweep.rb,dormant-sweep.env}
|
||||
# Cron (mammut root): 30 4 * * 0 /root/dormant-sweep/dormant-sweep.sh >> /var/log/dormant-sweep.log 2>&1
|
||||
set -eu
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
ENV_FILE="${DORMANT_ENV_FILE:-$HERE/dormant-sweep.env}"
|
||||
|
||||
# Load KEY=VALUE config and export it so the loop below can forward it.
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
set -a
|
||||
. "$ENV_FILE"
|
||||
set +a
|
||||
fi
|
||||
|
||||
CID="$(docker ps -f name=live-web-1 -q | head -n1)"
|
||||
[ -n "$CID" ] || { echo "dormant-sweep: live-web-1 container not found" >&2; exit 1; }
|
||||
|
||||
# Forward only DORMANT_* vars into the container.
|
||||
DOCKER_ENV=""
|
||||
for v in $(env | sed -n 's/^\(DORMANT_[A-Z_]*\)=.*/\1/p'); do
|
||||
DOCKER_ENV="$DOCKER_ENV -e $v"
|
||||
done
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
docker exec -i $DOCKER_ENV "$CID" bin/rails runner - < "$HERE/dormant_sweep.rb"
|
||||
Reference in New Issue
Block a user