From b87619a13352ac2fe031945907c27119e306991d Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Wed, 17 Mar 2021 12:27:08 -0400 Subject: [PATCH] Add heroku-regen script, rename config/ -> misc/ Introduces a new script for quickly regenerating a Heroku instance (typically with a new IP) to handle the rare circumstances where an instance is flagged by Google and prompted for a captcha. The config/ dir was renamed to misc/ to avoid confusion with the Docker mounted config volume, and to more closely match its intended purpose (which is to contain all miscellaneous features/scripts/etc that add functionality to Whoogle, but are not critical for general use). --- Dockerfile | 6 +++--- misc/heroku-regen.sh | 29 +++++++++++++++++++++++++++++ {config => misc}/tor/start-tor.sh | 0 {config => misc}/tor/torrc | 0 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100755 misc/heroku-regen.sh rename {config => misc}/tor/start-tor.sh (100%) rename {config => misc}/tor/torrc (100%) diff --git a/Dockerfile b/Dockerfile index 981512b..4a2e884 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,8 +55,8 @@ ENV WHOOGLE_ALT_RD=$reddit_alt WORKDIR /whoogle COPY --from=builder /install /usr/local -COPY config/tor/torrc /etc/tor/torrc -COPY config/tor/start-tor.sh config/tor/start-tor.sh +COPY misc/tor/torrc /etc/tor/torrc +COPY misc/tor/start-tor.sh misc/tor/start-tor.sh COPY app/ app/ COPY run . @@ -65,4 +65,4 @@ EXPOSE $EXPOSE_PORT HEALTHCHECK --interval=5m --timeout=5s \ CMD wget --no-verbose --tries=1 http://localhost:${EXPOSE_PORT}/ || exit 1 -CMD config/tor/start-tor.sh & ./run +CMD misc/tor/start-tor.sh & ./run diff --git a/misc/heroku-regen.sh b/misc/heroku-regen.sh new file mode 100755 index 0000000..45af8f0 --- /dev/null +++ b/misc/heroku-regen.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Assumes this is being executed from a session that has already logged +# into Heroku with "heroku login -i" beforehand. +# +# You can set this up to run every night when you aren't using the +# instance with a cronjob. For example: +# 0 3 * * * /home/pi/whoogle-search/config/heroku-regen.sh + +HEROKU_CLI_SITE="https://devcenter.heroku.com/articles/heroku-cli" + +if ! type "heroku" > /dev/null; then + echo "Must have heroku cli installed: $HEROKU_CLI_SITE" + exit 1 +fi + +cd "$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/../" + +if [ $# -ne 1 ]; then + echo "Must provide the name of the Whoogle instance to regenerate" + exit 1 +fi + +APP_NAME="$1" + +heroku apps:destroy $APP_NAME --confirm $APP_NAME +heroku apps:create $APP_NAME +heroku container:login +heroku container:push web +heroku container:release web diff --git a/config/tor/start-tor.sh b/misc/tor/start-tor.sh similarity index 100% rename from config/tor/start-tor.sh rename to misc/tor/start-tor.sh diff --git a/config/tor/torrc b/misc/tor/torrc similarity index 100% rename from config/tor/torrc rename to misc/tor/torrc