Merge pull request #15 from balena-io/pass-superuser-creds-in-env

env: Pass superuser credentials in the environment
This commit is contained in:
Rich Bayliss 2018-11-07 10:23:39 +00:00 committed by GitHub
commit 8c68f2c01d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 5 deletions

View File

@ -53,6 +53,8 @@ services:
VPN_HOST: vpn.${OPENBALENA_HOST_NAME} VPN_HOST: vpn.${OPENBALENA_HOST_NAME}
VPN_PORT: 443 VPN_PORT: 443
VPN_SERVICE_API_KEY: ${OPENBALENA_VPN_SERVICE_API_KEY} VPN_SERVICE_API_KEY: ${OPENBALENA_VPN_SERVICE_API_KEY}
SUPERUSER_EMAIL: ${OPENBALENA_SUPERUSER_EMAIL}
SUPERUSER_PASSWORD: ${OPENBALENA_SUPERUSER_PASSWORD}
registry: registry:
extends: extends:

View File

@ -19,7 +19,7 @@ usage() {
echo echo
} }
for var in DOMAIN ROOT_CA ROOT_CRT ROOT_KEY JWT_CRT JWT_KEY JWT_KID VPN_CA VPN_CRT VPN_KEY VPN_DH; do for var in DOMAIN ROOT_CA ROOT_CRT ROOT_KEY JWT_CRT JWT_KEY JWT_KID VPN_CA VPN_CRT VPN_KEY VPN_DH SUPERUSER_EMAIL SUPERUSER_PASSWORD; do
if [ -z "${!var-}" ]; then if [ -z "${!var-}" ]; then
usage usage
exit 1 exit 1
@ -85,4 +85,6 @@ export OPENBALENA_API_VPN_SERVICE_API_KEY=$(randstr 32)
export OPENBALENA_REGISTRY_SECRET_KEY=$(randstr 32) export OPENBALENA_REGISTRY_SECRET_KEY=$(randstr 32)
export OPENBALENA_SSH_AUTHORIZED_KEYS= export OPENBALENA_SSH_AUTHORIZED_KEYS=
export NODE_EXTRA_CA_CERTS="$ROOT_CA" export NODE_EXTRA_CA_CERTS="$ROOT_CA"
export OPENBALENA_SUPERUSER_EMAIL=$SUPERUSER_EMAIL
export OPENBALENA_SUPERUSER_PASSWORD=$SUPERUSER_PASSWORD
STR STR

View File

@ -9,20 +9,24 @@ CERTS_DIR="${CONFIG_DIR}/certs"
DOMAIN=openbalena.local DOMAIN=openbalena.local
usage() { usage() {
echo "usage: $0 [-h] [-p] [-d DOMAIN]" echo "usage: $0 [-h] [-p] [-d DOMAIN] -U EMAIL -P PASSWORD"
echo echo
echo " -p patch hosts - patch the host /etc/hosts file" echo " -p patch hosts - patch the host /etc/hosts file"
echo " -d DOMAIN the domain name this deployment will run as, eg. example.com. Default is 'openbalena.local'" echo " -d DOMAIN the domain name this deployment will run as, eg. example.com. Default is 'openbalena.local'"
echo " -U EMAIL the email address of the superuser account, used to login to your install from the Balena CLI"
echo " -P PASSWORD the password to use for the superuser account."
echo echo
} }
show_help=false show_help=false
patch_hosts=false patch_hosts=false
while getopts ":hpd:" opt; do while getopts ":hpd:U:P:" opt; do
case "${opt}" in case "${opt}" in
h) show_help=true;; h) show_help=true;;
p) patch_hosts=true;; p) patch_hosts=true;;
d) DOMAIN="${OPTARG}";; d) DOMAIN="${OPTARG}";;
U) SUPERUSER_EMAIL="${OPTARG}";;
P) SUPERUSER_PASSWORD="${OPTARG}";;
*) *)
echo "Invalid argument: -${OPTARG}" echo "Invalid argument: -${OPTARG}"
usage usage
@ -32,6 +36,11 @@ while getopts ":hpd:" opt; do
done done
shift $((OPTIND-1)) shift $((OPTIND-1))
if [ -z "${SUPERUSER_EMAIL}" ] || [ -z "${SUPERUSER_PASSWORD}" ]; then
usage
exit 1
fi
if [ "$show_help" = "true" ]; then if [ "$show_help" = "true" ]; then
usage usage
exit 1 exit 1