Rewrite abra.sh for maximum utility.
This commit is contained in:
parent
4612fd9ab4
commit
cf051ec0a9
61
abra.sh
61
abra.sh
@ -1,32 +1,63 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# set -x
|
||||||
|
|
||||||
export ENTRYPOINT_CONF_VERSION=v12
|
export ENTRYPOINT_CONF_VERSION=v12
|
||||||
|
|
||||||
assets() {
|
file_env() {
|
||||||
set -a OTP_SECRET $(cat /run/secrets/otp_secret)
|
local var="$1"
|
||||||
set -a SECRET_KEY_BASE $(cat /run/secrets/secret_key_base)
|
local fileVar="${var}_FILE"
|
||||||
set -a DB_PASS $(cat /run/secrets/db_password)
|
local def="${2:-}"
|
||||||
|
|
||||||
RAILS_ENV=production bundle exec rails assets:precompile
|
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||||
|
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local val="$def"
|
||||||
|
if [ "${!var:-}" ]; then
|
||||||
|
val="${!var}"
|
||||||
|
elif [ "${!fileVar:-}" ]; then
|
||||||
|
val="$(< "${!fileVar}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare -x -g "$var"="$val"
|
||||||
|
unset "$fileVar"
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
environment() {
|
||||||
set -a OTP_SECRET $(cat /run/secrets/otp_secret)
|
# for sidekiq service bundle exec env var threading
|
||||||
set -a SECRET_KEY_BASE $(cat /run/secrets/secret_key_base)
|
file_env "OTP_SECRET"
|
||||||
set -a DB_PASS $(cat /run/secrets/db_password)
|
file_env "SECRET_KEY_BASE"
|
||||||
|
file_env "DB_PASS"
|
||||||
|
file_env "SMTP_PASSWORD"
|
||||||
|
file_env "VAPID_PRIVATE_KEY"
|
||||||
|
|
||||||
RAILS_ENV=production bundle exec rake db:setup
|
declare -x RAILS_ENV=production
|
||||||
}
|
}
|
||||||
|
|
||||||
admin() {
|
|
||||||
set -a OTP_SECRET $(cat /run/secrets/otp_secret)
|
|
||||||
set -a SECRET_KEY_BASE $(cat /run/secrets/secret_key_base)
|
|
||||||
set -a DB_PASS $(cat /run/secrets/db_password)
|
|
||||||
|
|
||||||
|
setup_assets() {
|
||||||
|
environment
|
||||||
|
bundle exec rails assets:precompile
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_db() {
|
||||||
|
environment
|
||||||
|
bundle exec rake db:setup
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_admin() {
|
||||||
|
environment
|
||||||
accounts create "$1" --email "$2" --confirmed --role admin
|
accounts create "$1" --email "$2" --confirmed --role admin
|
||||||
}
|
}
|
||||||
|
|
||||||
secrets() {
|
shell() {
|
||||||
|
environment
|
||||||
|
bash $@
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_secrets() {
|
||||||
|
## Run this 'local' to generate secrets
|
||||||
docker context use default > /dev/null 2>&1
|
docker context use default > /dev/null 2>&1
|
||||||
|
|
||||||
echo "Generating secrets for new Hometown deployment..."
|
echo "Generating secrets for new Hometown deployment..."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user