Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(files): Stack quick link follows the real install dir

Juan Denisc163d4357f74
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1547fd55..7d4d8bce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -286,7 +286,8 @@ awaiting a stable release:
(`SERVERKIT_INSTALL_DIR`, rendered into the service unit from the installer's
`SERVERKIT_DIR`), prefers the running tree over a stale `/opt/serverkit`, and
the Docker image now ships the `VERSION` file (containers previously showed
- the `1.0.0` fallback).
+ the `1.0.0` fallback). The File Manager's "Stack" quick link follows the same
+ resolved install directory instead of assuming `/opt/serverkit`.
- **Scripts reliability (round 2)** — swept the whole install/update/uninstall/CLI
shell surface for the "benign non-zero under `set -e`/`pipefail`" failure class
behind the July 2 update outage:
diff --git a/backend/app/api/system.py b/backend/app/api/system.py
index 8fd65345..baf87b08 100644
--- a/backend/app/api/system.py
+++ b/backend/app/api/system.py
@@ -9,7 +9,7 @@ from app.services.system_service import SystemService
from app.services.resource_tier_service import ResourceTierService
from app.services.site_domain_service import SiteDomainService
from app.utils.domain import is_valid_canonical_domain
-from app.utils.version import get_panel_version
+from app.utils.version import get_panel_version, get_install_dir
# Cache for update check (to avoid hitting GitHub API too often)
_update_cache = {
@@ -31,7 +31,10 @@ def get_version():
"""
return jsonify({
'version': get_panel_version(),
- 'name': 'ServerKit'
+ 'name': 'ServerKit',
+ # Where the panel is installed — consumers (e.g. the File Manager's
+ # "Stack" quick link) must not assume /opt/serverkit.
+ 'install_dir': get_install_dir()
}), 200
diff --git a/backend/app/utils/version.py b/backend/app/utils/version.py
index 9ff904fb..c765cfcf 100644
--- a/backend/app/utils/version.py
+++ b/backend/app/utils/version.py
@@ -52,6 +52,23 @@ def get_panel_version():
return version
+def get_install_dir():
+ """Best-effort panel install root (the tree holding backend/, frontend/,
+ VERSION). Same resolution contract as get_panel_version: explicit
+ SERVERKIT_INSTALL_DIR override, then the running code's own tree, then the
+ default install location. abspath (not realpath) on purpose — a blue/green
+ box should report the stable /opt/serverkit symlink, not a slot dir.
+ """
+ install_dir = os.environ.get('SERVERKIT_INSTALL_DIR')
+ if install_dir:
+ return install_dir
+ here = os.path.dirname(os.path.abspath(__file__)) # backend/app/utils
+ tree_root = os.path.abspath(os.path.join(here, '..', '..', '..'))
+ if os.path.exists(os.path.join(tree_root, 'VERSION')):
+ return tree_root
+ return '/opt/serverkit'
+
+
def _parse(v):
"""Best-effort parse into a comparable object. Uses packaging when possible,
falling back to a tuple of leading integer components."""
diff --git a/backend/tests/test_panel_version.py b/backend/tests/test_panel_version.py
index 582aeb99..ec40c37d 100644
--- a/backend/tests/test_panel_version.py
+++ b/backend/tests/test_panel_version.py
@@ -69,3 +69,20 @@ def test_version_endpoint_reports_resolved_version(client, auth_headers, tmp_pat
data = resp.get_json()
assert data['version'] == '8.8.8-endpoint'
assert data['name'] == 'ServerKit'
+ assert data['install_dir'] == str(tmp_path)
+
+
+def test_install_dir_override(tmp_path, monkeypatch):
+ """get_install_dir honors the explicit override (custom SERVERKIT_DIR)."""
+ monkeypatch.setenv('SERVERKIT_INSTALL_DIR', str(tmp_path))
+ assert version_mod.get_install_dir() == str(tmp_path)
+
+
+def test_install_dir_own_tree_without_override(monkeypatch):
+ """No override: the running code's own tree wins (it has a VERSION file
+ here and in the Docker image) — never a hardcoded /opt/serverkit."""
+ monkeypatch.delenv('SERVERKIT_INSTALL_DIR', raising=False)
+ tree_root = os.path.abspath(os.path.join(
+ os.path.dirname(os.path.abspath(version_mod.__file__)), '..', '..', '..'
+ ))
+ assert version_mod.get_install_dir() == tree_root
diff --git a/frontend/src/pages/FileManager.jsx b/frontend/src/pages/FileManager.jsx
index eef1e60f..45b939db 100644
--- a/frontend/src/pages/FileManager.jsx
+++ b/frontend/src/pages/FileManager.jsx
@@ -27,7 +27,9 @@ import TargetPicker from '../components/TargetPicker';
import { TREE_ROOTS, getFileType, formatBytes } from '../components/file-manager/fileTypes';
// Demo rail shortcuts (Quick access) — one-click jumps to the paths people
-// actually visit on a ServerKit host.
+// actually visit on a ServerKit host. "Stack" starts at the default install
+// location and is re-pointed from /system/version's install_dir, so a custom
+// SERVERKIT_DIR install jumps to the real tree.
const QUICK_ACCESS = [
{ label: 'Sites', path: '/var/www', icon: Globe },
{ label: 'Stack', path: '/opt/serverkit', icon: Boxes },
@@ -120,6 +122,22 @@ function FileManager() {
return () => { cancelled = true; };
}, []);
+ // The "Stack" quick link tracks the panel's real install dir (custom
+ // SERVERKIT_DIR installs aren't at /opt/serverkit).
+ const [quickAccess, setQuickAccess] = useState(QUICK_ACCESS);
+ useEffect(() => {
+ let cancelled = false;
+ api.getVersion()
+ .then((v) => {
+ if (cancelled || !v?.install_dir) return;
+ setQuickAccess((links) => links.map((q) =>
+ q.label === 'Stack' ? { ...q, path: v.install_dir } : q
+ ));
+ })
+ .catch(() => {});
+ return () => { cancelled = true; };
+ }, []);
+
// ─── core ────────────────────────────────────────────
const [currentPath, setCurrentPath] = useState(() => searchParams.get('path') || '/home');
const [entries, setEntries] = useState([]);
@@ -1004,7 +1022,7 @@ function FileManager() {
<span>Quick access</span>
</div>
<div className="sidebar-section-content quick-access-list">
- {QUICK_ACCESS.map(q => (
+ {quickAccess.map(q => (
<button type="button"
key={q.label}
className={`quick-access-item ${currentPath === q.path ? 'active' : ''}`}