Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16e69a2bd6 | ||
|
|
bc4cf2b7a3 | ||
|
|
35bdefba59 |
@@ -30,17 +30,37 @@ _BLOCK_START = "<!-- server-manager:start -->"
|
||||
_BLOCK_END = "<!-- server-manager:end -->"
|
||||
|
||||
GLOBAL_CLAUDE_MD_BLOCK = f"""{_BLOCK_START}
|
||||
## Server Manager — управление серверами
|
||||
## Серверы — ТОЛЬКО через /ssh
|
||||
|
||||
**ВСЕГДА** используй server manager для подключения к серверам. Никогда не используй `ssh`, `sshpass` или прямые подключения.
|
||||
**НИКОГДА не используй raw `ssh` команды.** НИКОГДА не читай `~/.ssh/config` для поиска серверов.
|
||||
Все операции с серверами — **ТОЛЬКО через скилл `/ssh`** или напрямую через `ssh.py`:
|
||||
|
||||
- Скилл: `/ssh ALIAS "command"` — выполнить команду на сервере
|
||||
- Список серверов: `python3 ~/.server-connections/ssh.py --list`
|
||||
- Документация: `~/.claude/commands/ssh.md`
|
||||
- Memory bank: проект `global-infrastructure` → `techContext.md`
|
||||
- Инфраструктура: https://git.sensey24.ru/aibot777/infrastructure-docs
|
||||
```bash
|
||||
python ~/.server-connections/ssh.py --list # список серверов (alias, тип, заметки)
|
||||
python ~/.server-connections/ssh.py --info ALIAS # инфо (без creds)
|
||||
python ~/.server-connections/ssh.py --status # online/offline
|
||||
```
|
||||
|
||||
**Запрещено:** использовать `ssh`, `sshpass`, читать `~/.server-connections/` напрямую, раскрывать IP/пароли/порты.
|
||||
При вопросе о сервере — **СНАЧАЛА `--list`**, найди нужный алиас по заметкам и **ПРОВЕРЬ ТИП**.
|
||||
Скрипт `ssh.py` сам читает credentials из зашифрованного хранилища. Claude НЕ видит IP, логины, пароли.
|
||||
|
||||
### КРИТИЧНО — команды зависят от типа сервера
|
||||
|
||||
**`ALIAS "command"` (shell) — ТОЛЬКО для типов `ssh` и `telnet`!**
|
||||
|
||||
| Тип | Команды |
|
||||
|-----|---------|
|
||||
| `ssh`/`telnet` | `ALIAS "cmd"`, `--upload ALIAS local remote`, `--download ALIAS remote local` |
|
||||
| `s3` (MinIO и др.) | `--s3-buckets ALIAS`, `--s3-ls ALIAS bucket/prefix`, `--s3-upload ALIAS local bucket/key`, `--s3-download ALIAS bucket/key local`, `--s3-delete ALIAS bucket/key`, `--s3-url ALIAS bucket/key [SEC]` |
|
||||
| `mariadb`/`mssql`/`postgresql` | `--sql ALIAS "SELECT ..."`, `--sql-databases ALIAS`, `--sql-tables ALIAS [db]` |
|
||||
| `redis` | `--redis ALIAS "GET key"`, `--redis-info ALIAS`, `--redis-keys ALIAS "pattern"` |
|
||||
| `grafana` | `--grafana-dashboards ALIAS`, `--grafana-alerts ALIAS` |
|
||||
| `prometheus` | `--prom-query ALIAS "up"`, `--prom-targets ALIAS`, `--prom-alerts ALIAS` |
|
||||
| `winrm` | `--ps ALIAS "Get-Process"`, `--cmd ALIAS "dir"` |
|
||||
|
||||
**Формат: `python ~/.server-connections/ssh.py КОМАНДА АЛИАС АРГУМЕНТЫ`** — алиас ВСЕГДА второй после команды.
|
||||
|
||||
**Запрещено:** использовать `ssh`/`sshpass`, читать `~/.server-connections/` напрямую, раскрывать IP/пароли/порты.
|
||||
{_BLOCK_END}
|
||||
"""
|
||||
|
||||
|
||||
52
gui/app.py
52
gui/app.py
@@ -2,6 +2,7 @@
|
||||
Main application window — sidebar + tabview layout.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import tkinter
|
||||
import customtkinter as ctk
|
||||
from tkinter import messagebox
|
||||
@@ -91,7 +92,7 @@ class App(ctk.CTk):
|
||||
|
||||
# Restore saved window geometry or use default
|
||||
saved_geo = self.store._window_geometry
|
||||
if saved_geo:
|
||||
if saved_geo and self._is_valid_geometry(saved_geo):
|
||||
self.geometry(saved_geo)
|
||||
else:
|
||||
self.geometry("1100x700")
|
||||
@@ -118,6 +119,32 @@ class App(ctk.CTk):
|
||||
# Cleanup on close
|
||||
self.protocol("WM_DELETE_WINDOW", self._on_close)
|
||||
|
||||
# Win32: restore window when stuck minimized after Win+D
|
||||
self._restore_check_id = None
|
||||
if sys.platform == "win32":
|
||||
self.after(3000, self._start_restore_watchdog)
|
||||
|
||||
def _start_restore_watchdog(self):
|
||||
"""Start periodic check for stuck minimized state (Windows only)."""
|
||||
try:
|
||||
import ctypes
|
||||
self._user32 = ctypes.windll.user32
|
||||
self._hwnd = int(self.wm_frame(), 16)
|
||||
self._check_restore()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def _check_restore(self):
|
||||
"""If window is iconic but user clicked taskbar, force restore."""
|
||||
try:
|
||||
if self._user32.IsIconic(self._hwnd):
|
||||
fg = self._user32.GetForegroundWindow()
|
||||
if fg == self._hwnd:
|
||||
self._user32.ShowWindow(self._hwnd, 9) # SW_RESTORE
|
||||
except Exception:
|
||||
pass
|
||||
self._restore_check_id = self.after(500, self._check_restore)
|
||||
|
||||
def _build_layout(self):
|
||||
# PanedWindow — resizable sidebar | main area
|
||||
self._paned = tkinter.PanedWindow(
|
||||
@@ -667,10 +694,31 @@ class App(ctk.CTk):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def _is_valid_geometry(geo: str) -> bool:
|
||||
"""Reject geometry with offscreen coordinates (e.g. minimized -32000)."""
|
||||
try:
|
||||
# format: WxH+X+Y or WxH-X-Y
|
||||
import re
|
||||
m = re.match(r"(\d+)x(\d+)([+-]\d+)([+-]\d+)", geo)
|
||||
if not m:
|
||||
return False
|
||||
x, y = int(m.group(3)), int(m.group(4))
|
||||
return -100 < x < 10000 and -100 < y < 10000
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def _on_close(self):
|
||||
# Cancel restore watchdog
|
||||
try:
|
||||
if self._restore_check_id:
|
||||
self.after_cancel(self._restore_check_id)
|
||||
except Exception:
|
||||
pass
|
||||
# Save window geometry (size + position) and sidebar width
|
||||
try:
|
||||
self.store._window_geometry = self.geometry()
|
||||
geo = self.geometry()
|
||||
self.store._window_geometry = geo if self._is_valid_geometry(geo) else None
|
||||
# Save sidebar width from PanedWindow sash position
|
||||
try:
|
||||
sash_pos = self._paned.sash_coord(0)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
"""Version info for ServerManager."""
|
||||
|
||||
__version__ = "1.9.18"
|
||||
__version__ = "1.9.21"
|
||||
__app_name__ = "ServerManager"
|
||||
__author__ = "aibot777"
|
||||
__description__ = "Desktop GUI for managing remote servers"
|
||||
|
||||
Reference in New Issue
Block a user