Verified Commit 37bef29a authored by aguestuser's avatar aguestuser

[146] for consistency, always use `env_file` instead of `env_path`

parent 1ca2ffeb
......@@ -233,7 +233,7 @@ See the [Using the Cli](#cli) section for instructions on installing and using i
Note that to use the `boost` cli tool against your local dev server, you will always have to pass `-e .env.dev` as an argument to all `boost` calls in order to tell boost to talk to your local server instead of prod.
If you find it annoying to type this over and over again, consider adding `export SIGNALBOOST_ENV_PATH=.env.dev` to your `~/.bashrc` (or equivalent file in your favorite shell program). This will set `.env.dev` as your default `.env` file, which you can still override by passing an explicit value to `-e` when invoking `boost`. (For example: `boost -e .env list-channels` would list all channels on prod.)
If you find it annoying to type this over and over again, consider adding `export SIGNALBOOST_ENV_FILE=.env.dev` to your `~/.bashrc` (or equivalent file in your favorite shell program). This will set `.env.dev` as your default `.env` file, which you can still override by passing an explicit value to `-e` when invoking `boost`. (For example: `boost -e .env list-channels` would list all channels on prod.)
Once you've got the CLI installed, you can use the following to create 2 twillio numbers and verifiy them with signal on a local dev server running signalboost:
......@@ -379,16 +379,16 @@ boost -e .env.arctic list-channels
### Setting default environments
You can set a default `.env` file for boost by declaring a value for `$SIGNALBOOST_ENV_PATH` somewhere in your `~/.bashrc` (or in another manner that ensures that `$SIGNALBOOST_ENV_PATH` is always in scope whenever you invoke boost.)
You can set a default `.env` file for boost by declaring a value for `$SIGNALBOOST_ENV_FILE` somewhere in your `~/.bashrc` (or in another manner that ensures that `$SIGNALBOOST_ENV_FILE` is always in scope whenever you invoke boost.)
To continue the above example, if you found that you always are trying to use `boost` with your Arctic instance and almost never want to use it with your Antarctic instance, you might find it annoying to always have to accompany every command with `-e .env.arctcic`. In that case, you could set `.env.arctic` as the default and list the channels on your Arctic server as follows:
```
export SIGNALBOOST_ENV_PATH=.env.arctic
export SIGNALBOOST_ENV_FILE=.env.arctic
boost list-channels
```
To avoid having to export `SIGNALBOOST_ENV_PATH` in every bash session, you could add the export statement to your `~/.bashrc` or `~/.bash_profile` file (or the equivalent for your favorite shell program).
To avoid having to export `SIGNALBOOST_ENV_FILE` in every bash session, you could add the export statement to your `~/.bashrc` or `~/.bash_profile` file (or the equivalent for your favorite shell program).
# Sysadmin Guide <a name="sysadmin-guide"></a>
......@@ -500,9 +500,11 @@ cd ansible
ansible-playbook -i inventory playbooks/main.yml
```
*Variation:*
*Variation with different .env files:*
By default the secrets needed to run signalboost (including ip addresses and hostnames) are read from `<PROJECT_ROOT>/.env>` If you would like to provide an alternate set of secrets (for example, for a staging server), you can configure the location where ansible will look for the `.env` file by setting the `env_file` ansible variable (specified with an `-e env_file=<some_path>` flag). For example, to read secrets from `/path/to/staging.env`, you would issue the following command:
By default the secrets needed to run signalboost (including ip addresses and hostnames) are read from `<PROJECT_ROOT>/.env>` If you would like to provide an alternate set of secrets (for example, for a staging server), you can configure the location where ansible will look for the `.env` file by setting the `env_file` ansible variable (specified with an `-e env_file=<some_path>` flag).
For example, to read secrets from `/path/to/staging.env`, you would issue the following command:
``` shell
cd ansible
......
......@@ -5,48 +5,48 @@ set -e
check-env(){
echo "--- checking environment.."
env_path=$1
env_file=$1
if [[ -z $(which jq) ]];then
echo "--- ERROR: you need the jq program installed to run this command!"
exit 1
fi
if [[ -z ${env_path} ]];then
if [[ -z ${SIGNALBOOST_ENV_PATH} ]];then
if [[ -z ${env_file} ]];then
if [[ -z ${SIGNALBOOST_ENV_FILE} ]];then
echo "--- ERROR: no .env path provided."
echo ""
echo " To use the boost utility, you must:"
echo " -> define credentials in an .env file in the signalboost project root folder"
echo " -> provide a path to the .env file (relative to signalboost project root folder) by either:"
echo " -> passing it as an argument to the -e flag"
echo " -> assigning it to the \$SIGNALBOOST_ENV_PATH env var"
echo " -> assigning it to the \$SIGNALBOOST_ENV_FILE env var"
echo ""
exit 1
else
env_path=${SIGNALBOOST_ENV_PATH}
env_file=${SIGNALBOOST_ENV_FILE}
fi
fi
source ../../${env_path}
source ../../${env_file}
if [[ -z ${SIGNALBOOST_API_TOKEN} ]];then
echo "--- ERROR: no SIGNALBOOST_API_TOKEN found in the .env file in ${env_path}"
echo "--- ERROR: no SIGNALBOOST_API_TOKEN found in the .env file in ${env_file}"
exit 1
fi
if [[ -z ${SIGNALBOOST_HOST_URL} ]];then
echo "--- ERROR: no SIGNALBOOST_HOST_URL found in the .env file in ${env_path}"
echo "--- ERROR: no SIGNALBOOST_HOST_URL found in the .env file in ${env_file}"
exit 1
fi
if [[ -z ${TWILIO_ACCOUNT_SID} ]];then
echo "--- ERROR: no TWILIO_ACCOUNT_SID found in the .env file in ${env_path}"
echo "--- ERROR: no TWILIO_ACCOUNT_SID found in the .env file in ${env_file}"
exit 1
fi
if [[ -z ${TWILIO_AUTH_TOKEN} ]];then
echo "--- ERROR: no TWILIO_AUTH_TOKEN found in the .env file in ${env_path}"
echo "--- ERROR: no TWILIO_AUTH_TOKEN found in the .env file in ${env_file}"
exit 1
fi
}
......@@ -22,14 +22,14 @@ while getopts ":c:a:e:" opt; do
admin_phone_number="$OPTARG"
;;
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
if [[ ! ${channel_phone_number} =~ ^\+(1|52)[0-9]{10}$ ]];then
echo "> ERROR: -c must be a 10 digit phone number prefixed by a country code (+1 or +52)"
......
......@@ -26,14 +26,14 @@ while getopts ":p:n:a:e:" opt; do
admins="$OPTARG"
;;
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
if [[ ! $phone_number =~ ^\+[0-9]{9,15}$ ]];then
echo "> ERROR: -p must be a valid phone number prefixed by a country code"
......
......@@ -21,14 +21,14 @@ while getopts ":a:n:e:" opt; do
num="$OPTARG"
;;
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
if [[ -z ${num} ]];then num=1; fi
if [[ ! ${num} =~ ^[0-9]*$ ]];then
......
......@@ -22,14 +22,14 @@ while getopts ":p:e:" opt; do
phone_number="$OPTARG"
;;
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
if [[ -z ${phone_number} ]]
then
......
......@@ -16,14 +16,14 @@ cd `dirname "$0"` # cd to script path
while getopts ":e:" opt; do
case "$opt" in
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
echo "--- fetching numbers..."
......
......@@ -24,14 +24,14 @@ cd `dirname "$0"` # cd to script path
while getopts ":e:" opt; do
case "$opt" in
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
if [[ $1 == "--active" ]] || [[ $2 == "--active" ]];then
filter="ACTIVE"
......
......@@ -22,14 +22,14 @@ while getopts ":p:e:" opt; do
phone_numbers="$OPTARG"
;;
e)
env_path="$OPTARG"
env_file="$OPTARG"
;;
esac
done
# check env vars are properly defined
source ./_check-env
check-env ${env_path}
check-env ${env_file}
if [[ -z "$phone_numbers" ]]
then
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment