whoogle-search/misc/heroku-regen.sh
Ben Busby b87619a133 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).
2021-04-05 11:00:56 -04:00

30 lines
839 B
Bash
Executable File

#!/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 <app_name>
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