From 9f2e74616331191d8219209530c382dac73be988 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 20 Sep 2025 22:15:09 +0300 Subject: [PATCH] fix configs --- ipfs/init/001-config.sh | 3 +-- start.sh | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ipfs/init/001-config.sh b/ipfs/init/001-config.sh index 41a2b49..6813d79 100644 --- a/ipfs/init/001-config.sh +++ b/ipfs/init/001-config.sh @@ -18,11 +18,10 @@ ipfs config --json Reprovider '{ "Interval": "22h", "Strategy": "pinned+mfs" }' ipfs config --json Swarm.ConnMgr '{ "Type": "basic", "LowWater": 50, "HighWater": 200, "GracePeriod": "20s" }' # Disable public AutoConf when running with a private swarm key -ipfs config AutoConf.Enabled false +ipfs config --json AutoConf.Enabled false # CORS for RPC API (visible only in docker network) ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]' ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT","POST","GET"]' echo "IPFS init script applied" - diff --git a/start.sh b/start.sh index d404304..97febeb 100644 --- a/start.sh +++ b/start.sh @@ -36,6 +36,27 @@ if [[ "$NODE_PRIVACY" != "public" && "$NODE_PRIVACY" != "private" ]]; then NODE_PRIVACY=public fi +# Strip leading KEY= or export KEY= that users may paste +sanitize_assignment() { + local key="$1" value="$2" + + if [[ $value == export\ * ]]; then + value=${value#export } + fi + + local prefix="${key}=" + if [[ $value == "$prefix"* ]]; then + value=${value#$prefix} + fi + + value="${value#\"}" + value="${value%\"}" + value="${value#\'}" + value="${value%\'}" + + echo "$value" +} + # Helper to prompt only if missing in .env ask_or_keep() { local key="$1"; shift @@ -64,6 +85,7 @@ ask_or_keep() { else read -rp "$prompt: " val || true fi + val=$(sanitize_assignment "$key" "$val") eval "$key=\"$val\"" }