2019-09-16 09:38:33 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-08-24 07:42:53 +00:00
|
|
|
set -euo pipefail
|
2019-09-16 09:38:33 +00:00
|
|
|
|
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
|
|
|
|
|
|
|
# Settings & defaults
|
2021-08-24 07:42:53 +00:00
|
|
|
RPC_HOST="${RPC_HOST:-localhost}"
|
2019-09-16 09:38:33 +00:00
|
|
|
RPC_PORT="${RPC_PORT:-8545}"
|
2022-09-15 19:41:00 +00:00
|
|
|
LISTEN_PORT="${LISTEN_PORT:-30303}"
|
2021-08-13 13:53:24 +00:00
|
|
|
API_MODULES="${API_MODULES:-eth,web3,admin}"
|
2021-08-24 07:37:44 +00:00
|
|
|
MAX_PEERS="${MAX_PEERS:-50}"
|
2022-01-25 09:59:59 +00:00
|
|
|
DAYS_KEPT="${DAYS_KEPT-30}"
|
2020-01-08 12:19:09 +00:00
|
|
|
FLEET_NAME="${FLEET_NAME:-eth.prod}"
|
2019-09-16 09:38:33 +00:00
|
|
|
REGISTER_TOPIC="${REGISTER_TOPIC:-whispermail}"
|
|
|
|
MAIL_PASSWORD="${MAIL_PASSWORD:-status-offline-inbox}"
|
|
|
|
DATA_PATH="${DATA_PATH:-/var/tmp/status-go-mail}"
|
|
|
|
CONFIG_PATH="${CONFIG_PATH:-${DATA_PATH}/config.json}"
|
|
|
|
|
2019-12-20 13:09:39 +00:00
|
|
|
if ! [[ -x $(command -v jq) ]]; then
|
2021-08-17 17:15:40 +00:00
|
|
|
echo "Cannot generate config. jq utility is not installed." >&2
|
2019-12-20 13:09:39 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-09-16 09:38:33 +00:00
|
|
|
if [[ -e "${CONFIG_PATH}" ]]; then
|
2021-08-17 17:15:40 +00:00
|
|
|
echo "Config already exits: ${CONFIG_PATH}" >&2
|
|
|
|
echo "Remove it to generate a new one." >&2
|
2019-09-16 09:38:33 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Assemble the filter for changing the config JSON
|
|
|
|
JQ_FILTER_ARRAY=(
|
2020-04-08 11:24:02 +00:00
|
|
|
".ListenAddr = \"0.0.0.0:${LISTEN_PORT}\""
|
2019-09-16 09:38:33 +00:00
|
|
|
".HTTPEnabled = true"
|
2021-08-24 07:42:53 +00:00
|
|
|
".HTTPHost = \"${RPC_HOST}\""
|
2019-09-16 09:38:33 +00:00
|
|
|
".HTTPPort= ${RPC_PORT}"
|
2021-08-24 07:37:44 +00:00
|
|
|
".MaxPeers = ${MAX_PEERS}"
|
|
|
|
".DataDir = \"${DATA_PATH}\""
|
2019-09-16 09:38:33 +00:00
|
|
|
".APIModules = \"${API_MODULES}\""
|
|
|
|
".RegisterTopics = [\"${REGISTER_TOPIC}\"]"
|
2020-04-08 11:47:14 +00:00
|
|
|
".WakuConfig.Enabled = true"
|
|
|
|
".WakuConfig.EnableMailServer = true"
|
|
|
|
".WakuConfig.DataDir = \"${DATA_PATH}/waku\""
|
|
|
|
".WakuConfig.MailServerPassword = \"${MAIL_PASSWORD}\""
|
2022-01-25 09:59:59 +00:00
|
|
|
".WakuConfig.MailServerDataRetention = ${DAYS_KEPT}"
|
2019-09-16 09:38:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
JQ_FILTER=$(printf " | %s" "${JQ_FILTER_ARRAY[@]}")
|
|
|
|
|
2019-11-15 09:35:26 +00:00
|
|
|
# make sure config destination exists
|
|
|
|
mkdir -p "${DATA_PATH}"
|
|
|
|
|
2019-09-16 09:38:33 +00:00
|
|
|
echo "Generating config at: ${CONFIG_PATH}"
|
|
|
|
|
|
|
|
cat "${GIT_ROOT}/config/cli/fleet-${FLEET_NAME}.json" \
|
|
|
|
| jq "${JQ_FILTER:3}" > "${CONFIG_PATH}"
|