Fix install script web setup to avoid bash compatibility issues
Replace nested if/fi with case statement and inline sed calls instead of helper function. Add error handling for service install. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -160,30 +160,32 @@ for example in target.conf.example remote.conf.example schedule.conf.example; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# ── Web dashboard setup ─────────────────────────────────────
|
# ── Web dashboard setup ─────────────────────────────────────
|
||||||
_update_conf_key() {
|
|
||||||
local file="$1" key="$2" val="$3"
|
|
||||||
if grep -q "^${key}=" "$file" 2>/dev/null; then
|
|
||||||
sed -i "s|^${key}=.*|${key}=\"${val}\"|" "$file"
|
|
||||||
else
|
|
||||||
echo "${key}=\"${val}\"" >> "$file"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
read -rp "Enable web dashboard? (y/n) [n]: " enable_web
|
read -rp "Enable web dashboard? (y/n) [n]: " enable_web
|
||||||
if [[ "${enable_web,,}" == "y" ]]; then
|
case "${enable_web}" in
|
||||||
_update_conf_key "$CONFIG_DIR/gniza.conf" "WEB_ENABLED" "yes"
|
y|Y)
|
||||||
# Generate random API key
|
# Update config
|
||||||
api_key=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
|
if grep -q "^WEB_ENABLED=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then
|
||||||
_update_conf_key "$CONFIG_DIR/gniza.conf" "WEB_API_KEY" "$api_key"
|
sed -i "s|^WEB_ENABLED=.*|WEB_ENABLED=\"yes\"|" "$CONFIG_DIR/gniza.conf"
|
||||||
echo "Web API key: $api_key"
|
else
|
||||||
echo "Save this key — you'll need it to log into the dashboard."
|
echo 'WEB_ENABLED="yes"' >> "$CONFIG_DIR/gniza.conf"
|
||||||
# Install systemd service
|
fi
|
||||||
if [[ "$MODE" == "root" ]]; then
|
# Generate random API key
|
||||||
"$INSTALL_DIR/bin/gniza" web install-service
|
api_key=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
|
||||||
else
|
if grep -q "^WEB_API_KEY=" "$CONFIG_DIR/gniza.conf" 2>/dev/null; then
|
||||||
warn "Systemd service installation requires root. Start manually: gniza web start"
|
sed -i "s|^WEB_API_KEY=.*|WEB_API_KEY=\"${api_key}\"|" "$CONFIG_DIR/gniza.conf"
|
||||||
fi
|
else
|
||||||
fi
|
echo "WEB_API_KEY=\"${api_key}\"" >> "$CONFIG_DIR/gniza.conf"
|
||||||
|
fi
|
||||||
|
echo "Web API key: $api_key"
|
||||||
|
echo "Save this key — you'll need it to log into the dashboard."
|
||||||
|
# Install systemd service (root only)
|
||||||
|
if [[ "$MODE" == "root" ]]; then
|
||||||
|
"$INSTALL_DIR/bin/gniza" web install-service || warn "Failed to install web service"
|
||||||
|
else
|
||||||
|
warn "Systemd service installation requires root. Start manually: gniza web start"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# ── Done ─────────────────────────────────────────────────────
|
# ── Done ─────────────────────────────────────────────────────
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user