Fix install web setup: use if/else instead of grep&&sed||echo chain

The && || chain with set -e caused syntax errors on some systems.

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

View File

@@ -164,14 +164,18 @@ enable_web="n"
read -rp "Enable web dashboard? (y/n) [n]: " enable_web || true read -rp "Enable web dashboard? (y/n) [n]: " enable_web || true
if [ "$enable_web" = "y" ] || [ "$enable_web" = "Y" ]; then if [ "$enable_web" = "y" ] || [ "$enable_web" = "Y" ]; then
# Update config # Update config
grep -q "^WEB_ENABLED=" "$CONFIG_DIR/gniza.conf" 2>/dev/null \ if grep -q "^WEB_ENABLED=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then
&& sed -i 's|^WEB_ENABLED=.*|WEB_ENABLED="yes"|' "$CONFIG_DIR/gniza.conf" \ sed -i 's|^WEB_ENABLED=.*|WEB_ENABLED="yes"|' "$CONFIG_DIR/gniza.conf"
|| echo 'WEB_ENABLED="yes"' >> "$CONFIG_DIR/gniza.conf" else
echo 'WEB_ENABLED="yes"' >> "$CONFIG_DIR/gniza.conf"
fi
# Generate random API key # Generate random API key
api_key="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')" api_key="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')"
grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null \ if grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then
&& sed -i "s|^WEB_API_KEY=.*|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}\"" >> "$CONFIG_DIR/gniza.conf" else
echo "WEB_API_KEY=\"${api_key}\"" >> "$CONFIG_DIR/gniza.conf"
fi
echo "Web API key: $api_key" echo "Web API key: $api_key"
echo "Save this key -- you will need it to log into the dashboard." echo "Save this key -- you will need it to log into the dashboard."
# Install systemd service (root only) # Install systemd service (root only)