fix start sh
This commit is contained in:
parent
37331e7d97
commit
f7c5b4ea8c
56
start.sh
56
start.sh
|
|
@ -17,6 +17,14 @@ if [[ ! -f "$ENV_FILE" ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Safe reader for existing values (does not fail under set -e -o pipefail)
|
||||||
|
ini_val() {
|
||||||
|
local key="$1"
|
||||||
|
local val
|
||||||
|
val=$(awk -F'=' -v k="$key" 'BEGIN{found=0} $1==k{print substr($0, index($0,$2)); found=1} END{ if(!found){} }' "$ENV_FILE" 2>/dev/null || true)
|
||||||
|
echo -n "$val"
|
||||||
|
}
|
||||||
|
|
||||||
read -rp "Node privacy (public/private) [public]: " NODE_PRIVACY
|
read -rp "Node privacy (public/private) [public]: " NODE_PRIVACY
|
||||||
NODE_PRIVACY=${NODE_PRIVACY:-public}
|
NODE_PRIVACY=${NODE_PRIVACY:-public}
|
||||||
if [[ "$NODE_PRIVACY" != "public" && "$NODE_PRIVACY" != "private" ]]; then
|
if [[ "$NODE_PRIVACY" != "public" && "$NODE_PRIVACY" != "private" ]]; then
|
||||||
|
|
@ -24,30 +32,36 @@ if [[ "$NODE_PRIVACY" != "public" && "$NODE_PRIVACY" != "private" ]]; then
|
||||||
NODE_PRIVACY=public
|
NODE_PRIVACY=public
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$NODE_PRIVACY" == "private" ]]; then
|
# Helper to prompt only if missing in .env
|
||||||
read -rp "Public host URL (leave empty for private): " PUBLIC_HOST || true
|
ask_or_keep() {
|
||||||
|
local key="$1"; shift
|
||||||
|
local prompt="$1"; shift
|
||||||
|
local def="$1"; shift || true
|
||||||
|
local cur
|
||||||
|
cur=$(ini_val "$key")
|
||||||
|
if [[ -n "$cur" ]]; then
|
||||||
|
echo "$key is set in .env; keeping existing value"
|
||||||
|
eval "$key=\"$cur\""
|
||||||
else
|
else
|
||||||
read -rp "Public host URL (e.g., https://node.example.com) [$(grep -E '^PUBLIC_HOST=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " PUBLIC_HOST || true
|
read -rp "$prompt [${def}]: " val || true
|
||||||
PUBLIC_HOST=${PUBLIC_HOST:-$(grep -E '^PUBLIC_HOST=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
val=${val:-$def}
|
||||||
|
eval "$key=\"$val\""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$NODE_PRIVACY" == "private" ]]; then
|
||||||
|
# For private nodes, PUBLIC_HOST optional; only ask if missing
|
||||||
|
ask_or_keep PUBLIC_HOST "Public host URL (leave empty for private)" ""
|
||||||
|
else
|
||||||
|
ask_or_keep PUBLIC_HOST "Public host URL (e.g., https://node.example.com)" "$(ini_val PUBLIC_HOST)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
read -rp "Internal app port (SANIC_PORT) [$(grep -E '^SANIC_PORT=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " SANIC_PORT || true
|
ask_or_keep SANIC_PORT "Internal app port (SANIC_PORT)" "$(ini_val SANIC_PORT)"
|
||||||
SANIC_PORT=${SANIC_PORT:-$(grep -E '^SANIC_PORT=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
ask_or_keep BACKEND_HTTP_PORT "Published backend port on host (BACKEND_HTTP_PORT)" "$(ini_val BACKEND_HTTP_PORT)"
|
||||||
|
ask_or_keep BOOTSTRAP_SEEDS "Bootstrap seeds (comma-separated URLs)" "$(ini_val BOOTSTRAP_SEEDS)"
|
||||||
read -rp "Published backend port on host (BACKEND_HTTP_PORT) [$(grep -E '^BACKEND_HTTP_PORT=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " BACKEND_HTTP_PORT || true
|
ask_or_keep HANDSHAKE_INTERVAL_SEC "Handshake interval seconds" "$(ini_val HANDSHAKE_INTERVAL_SEC)"
|
||||||
BACKEND_HTTP_PORT=${BACKEND_HTTP_PORT:-$(grep -E '^BACKEND_HTTP_PORT=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
ask_or_keep TELEGRAM_API_KEY "Telegram uploader bot token (TELEGRAM_API_KEY)" "$(ini_val TELEGRAM_API_KEY)"
|
||||||
|
ask_or_keep CLIENT_TELEGRAM_API_KEY "Telegram client bot token (CLIENT_TELEGRAM_API_KEY)" "$(ini_val CLIENT_TELEGRAM_API_KEY)"
|
||||||
read -rp "Bootstrap seeds (comma-separated URLs) [$(grep -E '^BOOTSTRAP_SEEDS=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " BOOTSTRAP_SEEDS || true
|
|
||||||
BOOTSTRAP_SEEDS=${BOOTSTRAP_SEEDS:-$(grep -E '^BOOTSTRAP_SEEDS=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
|
||||||
|
|
||||||
read -rp "Handshake interval seconds [$(grep -E '^HANDSHAKE_INTERVAL_SEC=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " HANDSHAKE_INTERVAL_SEC || true
|
|
||||||
HANDSHAKE_INTERVAL_SEC=${HANDSHAKE_INTERVAL_SEC:-$(grep -E '^HANDSHAKE_INTERVAL_SEC=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
|
||||||
|
|
||||||
read -rp "Telegram uploader bot token (TELEGRAM_API_KEY) [$(grep -E '^TELEGRAM_API_KEY=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " TELEGRAM_API_KEY || true
|
|
||||||
TELEGRAM_API_KEY=${TELEGRAM_API_KEY:-$(grep -E '^TELEGRAM_API_KEY=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
|
||||||
|
|
||||||
read -rp "Telegram client bot token (CLIENT_TELEGRAM_API_KEY) [$(grep -E '^CLIENT_TELEGRAM_API_KEY=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)]: " CLIENT_TELEGRAM_API_KEY || true
|
|
||||||
CLIENT_TELEGRAM_API_KEY=${CLIENT_TELEGRAM_API_KEY:-$(grep -E '^CLIENT_TELEGRAM_API_KEY=' "$ENV_FILE" 2>/dev/null | cut -d'=' -f2)}
|
|
||||||
|
|
||||||
echo "Applying configuration to $ENV_FILE ..."
|
echo "Applying configuration to $ENV_FILE ..."
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue