diff --git a/bin/gniza b/bin/gniza index d32c3eb..b220e10 100755 --- a/bin/gniza +++ b/bin/gniza @@ -402,10 +402,10 @@ if [[ "$SUBCOMMAND" == "web" ]]; then _web_port="" _web_host="" _web_port=$(_parse_flag "--port" "${SUBCMD_ARGS[@]+"${SUBCMD_ARGS[@]}"}") || true _web_host=$(_parse_flag "--host" "${SUBCMD_ARGS[@]+"${SUBCMD_ARGS[@]}"}") || true - _web_args=() - [[ -n "$_web_port" ]] && _web_args+=(--port="$_web_port") - [[ -n "$_web_host" ]] && _web_args+=(--host="$_web_host") - PYTHONPATH="$GNIZA_DIR:${PYTHONPATH:-}" exec python3 -m web "${_web_args[@]}" + _web_args=(--web) + [[ -n "$_web_port" ]] && _web_args+=(--port "$_web_port") + [[ -n "$_web_host" ]] && _web_args+=(--host "$_web_host") + PYTHONPATH="$GNIZA_DIR:${PYTHONPATH:-}" exec python3 -m tui "${_web_args[@]}" ;; install-service) _service_src="$GNIZA_DIR/etc/gniza-web.service" @@ -416,7 +416,7 @@ if [[ "$SUBCOMMAND" == "web" ]]; then cp "$_service_src" "$_service_dst" systemctl daemon-reload systemctl enable gniza-web - systemctl start gniza-web + systemctl restart gniza-web echo "GNIZA web service installed and started." echo "Access the dashboard at http://$(hostname -I | awk '{print $1}'):8080" ;; diff --git a/etc/gniza-web.service b/etc/gniza-web.service index ef2b0bf..5b78bf4 100644 --- a/etc/gniza-web.service +++ b/etc/gniza-web.service @@ -4,11 +4,9 @@ After=network.target [Service] Type=simple -ExecStart=/usr/bin/python3 -m web +ExecStart=/usr/bin/python3 -m tui --web --host 0.0.0.0 --port 8080 WorkingDirectory=/usr/local/gniza Environment=GNIZA_DIR=/usr/local/gniza -Environment=GNIZA_CONFIG_DIR=/etc/gniza -Environment=LOG_DIR=/var/log/gniza Environment=PYTHONPATH=/usr/local/gniza Restart=on-failure RestartSec=5 diff --git a/scripts/install.sh b/scripts/install.sh index 07043e9..e101850 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -160,36 +160,14 @@ for example in target.conf.example remote.conf.example schedule.conf.example; do done # -- Web dashboard setup -- -setup_web_dashboard() { - local conf="$CONFIG_DIR/gniza.conf" - # Update config: WEB_ENABLED - if grep -q "^WEB_ENABLED=" "$conf" 2>/dev/null; then - sed -i 's|^WEB_ENABLED=.*|WEB_ENABLED="yes"|' "$conf" - else - echo 'WEB_ENABLED="yes"' >> "$conf" - fi - # Generate random API key - local api_key - api_key="$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')" - if grep -q "^WEB_API_KEY=" "$conf" 2>/dev/null; then - sed -i "s|^WEB_API_KEY=.*|WEB_API_KEY=\"${api_key}\"|" "$conf" - else - echo "WEB_API_KEY=\"${api_key}\"" >> "$conf" - fi - info "Web API key: $api_key" - echo "Save this key -- you will need it to log into the dashboard." - # Install systemd service (root only) +enable_web="n" +read -rp "Enable web dashboard (TUI in browser)? (y/n) [n]: " enable_web "AppSettings": @@ -228,10 +226,8 @@ class AppSettings: ssh_retries=data.get("SSH_RETRIES", "3"), rsync_extra_opts=data.get("RSYNC_EXTRA_OPTS", ""), work_dir=data.get("WORK_DIR", "/usr/local/gniza/workdir"), - web_enabled=data.get("WEB_ENABLED", "no"), web_port=data.get("WEB_PORT", "8080"), web_host=data.get("WEB_HOST", "0.0.0.0"), - web_api_key=data.get("WEB_API_KEY", ""), ) def to_conf(self) -> dict[str, str]: @@ -253,8 +249,6 @@ class AppSettings: "SSH_RETRIES": self.ssh_retries, "RSYNC_EXTRA_OPTS": self.rsync_extra_opts, "WORK_DIR": self.work_dir, - "WEB_ENABLED": self.web_enabled, "WEB_PORT": self.web_port, "WEB_HOST": self.web_host, - "WEB_API_KEY": self.web_api_key, } diff --git a/tui/screens/settings.py b/tui/screens/settings.py index 09ee6db..a4d8787 100644 --- a/tui/screens/settings.py +++ b/tui/screens/settings.py @@ -62,18 +62,10 @@ class SettingsScreen(Screen): yield Static("Work Directory:") yield Input(value=settings.work_dir, placeholder="/usr/local/gniza/workdir", id="set-workdir") yield Static("Web Dashboard", classes="section-label") - yield Static("Enabled:") - yield Select( - [("Yes", "yes"), ("No", "no")], - id="set-web-enabled", - value=settings.web_enabled, - ) yield Static("Port:") yield Input(value=settings.web_port, id="set-web-port") yield Static("Host:") yield Input(value=settings.web_host, id="set-web-host") - yield Static("API Key:") - yield Input(value=settings.web_api_key, password=True, id="set-web-key") with Horizontal(id="set-buttons"): yield Button("Save", variant="primary", id="btn-save") yield Button("Back", id="btn-back") @@ -107,10 +99,8 @@ class SettingsScreen(Screen): ssh_retries=self.query_one("#set-sshretries", Input).value.strip() or "3", rsync_extra_opts=self.query_one("#set-rsyncopts", Input).value.strip(), work_dir=self.query_one("#set-workdir", Input).value.strip() or "/usr/local/gniza/workdir", - web_enabled=self._get_select_val("#set-web-enabled", "no"), web_port=self.query_one("#set-web-port", Input).value.strip() or "8080", web_host=self.query_one("#set-web-host", Input).value.strip() or "0.0.0.0", - web_api_key=self.query_one("#set-web-key", Input).value, ) conf_path = CONFIG_DIR / "gniza.conf" write_conf(conf_path, settings.to_conf())