some shit

This commit is contained in:
root 2025-10-06 03:21:08 +00:00
parent bb64acab09
commit dbc460f0bb
1 changed files with 25 additions and 0 deletions

View File

@ -68,6 +68,28 @@ trim() {
printf '%s' "$val"
}
strip_assignment_prefix() {
local key="$1"
local val="$2"
val=$(trim "$val")
if [[ $val == export\ * ]]; then
val=${val#export }
fi
local prefix="${key}="
if [[ $val == "$prefix"* ]]; then
val=${val#$prefix}
fi
local upper_prefix="$(echo "$key" | tr '[:lower:]' '[:upper:]')="
if [[ $val == "$upper_prefix"* ]]; then
val=${val#$upper_prefix}
fi
val="${val#\"}"
val="${val%\"}"
val="${val#\'}"
val="${val%\'}"
printf '%s' "$val"
}
ini_val() {
local key="$1"
if [[ -f "$ENV_FILE" ]]; then
@ -135,6 +157,7 @@ prompt_required() {
read -r -p "$label: " value || true
fi
value=$(trim "$value")
value=$(strip_assignment_prefix "$var" "$value")
if [[ -n "$value" ]]; then
printf -v "$var" '%s' "$value"
return
@ -155,6 +178,7 @@ prompt_optional() {
read -r -p "$label: " value || true
fi
value=$(trim "$value")
value=$(strip_assignment_prefix "$var" "$value")
printf -v "$var" '%s' "$value"
}
@ -328,6 +352,7 @@ cat <<EOF_SWARM >"$CONFIGS_DIR/ipfs/swarm.key"
/base16/
$SWARM_KEY_HEX
EOF_SWARM
chown 1000:1000 "$CONFIGS_DIR/ipfs/swarm.key" || true
chmod 600 "$CONFIGS_DIR/ipfs/swarm.key"
update_env IPFS_SWARM_KEY_FILE "$CONFIGS_DIR/ipfs/swarm.key"