Simplify install web setup for maximum bash compatibility

Use POSIX [ ] tests instead of [[ ]], avoid case statement,
replace em-dash with ASCII, use simple if/then/fi structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-06 05:43:52 +02:00
parent 29948d454a
commit 0bce1bc194

View File

@@ -160,32 +160,27 @@ for example in target.conf.example remote.conf.example schedule.conf.example; do
done done
# ── Web dashboard setup ───────────────────────────────────── # ── Web dashboard setup ─────────────────────────────────────
read -rp "Enable web dashboard? (y/n) [n]: " enable_web enable_web="n"
case "${enable_web}" in read -rp "Enable web dashboard? (y/n) [n]: " enable_web || true
y|Y) if [ "$enable_web" = "y" ] || [ "$enable_web" = "Y" ]; then
# Update config # Update config
if grep -q "^WEB_ENABLED=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then grep -q "^WEB_ENABLED=" "$CONFIG_DIR/gniza.conf" 2>/dev/null \
sed -i "s|^WEB_ENABLED=.*|WEB_ENABLED=\"yes\"|" "$CONFIG_DIR/gniza.conf" && sed -i 's|^WEB_ENABLED=.*|WEB_ENABLED="yes"|' "$CONFIG_DIR/gniza.conf" \
else || echo 'WEB_ENABLED="yes"' >> "$CONFIG_DIR/gniza.conf"
echo 'WEB_ENABLED="yes"' >> "$CONFIG_DIR/gniza.conf" # Generate random API key
fi api_key="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
# Generate random API key grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null \
api_key=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))") && sed -i "s|^WEB_API_KEY=.*|WEB_API_KEY=\"${api_key}\"|" "$CONFIG_DIR/gniza.conf" \
if grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then || echo "WEB_API_KEY=\"${api_key}\"" >> "$CONFIG_DIR/gniza.conf"
sed -i "s|^WEB_API_KEY=.*|WEB_API_KEY=\"${api_key}\"|" "$CONFIG_DIR/gniza.conf" echo "Web API key: $api_key"
else echo "Save this key -- you will need it to log into the dashboard."
echo "WEB_API_KEY=\"${api_key}\"" >> "$CONFIG_DIR/gniza.conf" # Install systemd service (root only)
fi if [ "$MODE" = "root" ]; then
echo "Web API key: $api_key" "$INSTALL_DIR/bin/gniza" web install-service || warn "Failed to install web service"
echo "Save this key — you'll need it to log into the dashboard." else
# Install systemd service (root only) warn "Systemd service installation requires root. Start manually: gniza web start"
if [[ "$MODE" == "root" ]]; then fi
"$INSTALL_DIR/bin/gniza" web install-service || warn "Failed to install web service" fi
else
warn "Systemd service installation requires root. Start manually: gniza web start"
fi
;;
esac
# ── Done ───────────────────────────────────────────────────── # ── Done ─────────────────────────────────────────────────────
echo "" echo ""