easy-devops 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -23
- package/install.sh +27 -4
- package/package.json +10 -13
- package/{cli → src/cli}/index.js +1 -1
- package/{cli → src/cli}/managers/domain-manager.js +13 -9
- package/{cli → src/cli}/managers/nginx-manager.js +90 -40
- package/{cli → src/cli}/managers/ssl-manager.js +16 -2
- package/{cli → src/cli}/menus/dashboard.js +1 -1
- package/{cli → src/cli}/menus/settings.js +23 -0
- package/{cli → src/cli}/menus/update.js +1 -1
- package/{core → src/core}/db.js +1 -1
- package/src/core/permissions.js +71 -0
- package/{core → src/core}/platform.js +16 -0
- package/{core → src/core}/shell.js +36 -0
- package/{dashboard → src/dashboard}/lib/nginx-service.js +72 -27
- package/{dashboard → src/dashboard}/public/js/app.js +37 -2
- package/{dashboard → src/dashboard}/routes/domains.js +42 -17
- package/src/dashboard/routes/settings.js +194 -0
- package/{dashboard → src/dashboard}/views/index.ejs +111 -7
- package/{dashboard → src/dashboard}/views/partials/domain-form.ejs +30 -7
- package/{dashboard → src/dashboard}/views/partials/domains-panel.ejs +0 -3
- package/{dashboard → src/dashboard}/views/partials/nginx-panel.ejs +25 -4
- package/{dashboard → src/dashboard}/views/partials/settings-panel.ejs +34 -1
- package/{lib → src/lib}/installer/picker.sh +4 -4
- package/dashboard/routes/settings.js +0 -86
- /package/{cli → src/cli}/managers/node-manager.js +0 -0
- /package/{cli → src/cli}/menus/.gitkeep +0 -0
- /package/{cli → src/cli}/menus/domains.js +0 -0
- /package/{cli → src/cli}/menus/nginx.js +0 -0
- /package/{cli → src/cli}/menus/nodejs.js +0 -0
- /package/{cli → src/cli}/menus/ssl.js +0 -0
- /package/{core → src/core}/config.js +0 -0
- /package/{core → src/core}/detector.js +0 -0
- /package/{core → src/core}/nginx-conf-generator.js +0 -0
- /package/{core → src/core}/validators.js +0 -0
- /package/{dashboard → src/dashboard}/lib/.gitkeep +0 -0
- /package/{dashboard → src/dashboard}/lib/cert-reader.js +0 -0
- /package/{dashboard → src/dashboard}/lib/domains-db.js +0 -0
- /package/{dashboard → src/dashboard}/lib/nginx-conf-generator.js +0 -0
- /package/{dashboard → src/dashboard}/public/img/icon.png +0 -0
- /package/{dashboard → src/dashboard}/public/img/icon_b.png +0 -0
- /package/{dashboard → src/dashboard}/routes/.gitkeep +0 -0
- /package/{dashboard → src/dashboard}/routes/auth.js +0 -0
- /package/{dashboard → src/dashboard}/routes/nginx.js +0 -0
- /package/{dashboard → src/dashboard}/routes/ssl.js +0 -0
- /package/{dashboard → src/dashboard}/server.js +0 -0
- /package/{dashboard → src/dashboard}/views/partials/login.ejs +0 -0
- /package/{dashboard → src/dashboard}/views/partials/overview.ejs +0 -0
- /package/{dashboard → src/dashboard}/views/partials/sidebar.ejs +0 -0
- /package/{dashboard → src/dashboard}/views/partials/ssl-panel.ejs +0 -0
- /package/{lib → src/lib}/installer/.gitkeep +0 -0
- /package/{lib → src/lib}/installer/detect.sh +0 -0
- /package/{lib → src/lib}/installer/node-versions.sh +0 -0
- /package/{lib → src/lib}/installer/nvm-bootstrap.sh +0 -0
- /package/{lib → src/lib}/installer/progress.sh +0 -0
- /package/{lib → src/lib}/installer/winget-install.ps1 +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
import { loadConfig, saveConfig } from '../../core/config.js';
|
|
7
|
+
import { validatePort, validateEmail } from '../../core/validators.js';
|
|
8
|
+
import { run } from '../../core/shell.js';
|
|
9
|
+
import { checkPermissionsConfigured } from '../../core/permissions.js';
|
|
10
|
+
|
|
11
|
+
// Run a bash command with sudo -S (password read from stdin — no terminal needed)
|
|
12
|
+
function runSudoS(bashCmd, password) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
const child = spawn('sudo', ['-S', 'bash', '-c', bashCmd], {
|
|
15
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
16
|
+
});
|
|
17
|
+
let stdout = '', stderr = '';
|
|
18
|
+
child.stdout.on('data', d => { stdout += d; });
|
|
19
|
+
child.stderr.on('data', d => { stderr += d; });
|
|
20
|
+
child.stdin.write(password + '\n');
|
|
21
|
+
child.stdin.end();
|
|
22
|
+
child.on('close', code => resolve({ success: code === 0, stdout: stdout.trim(), stderr: stderr.trim() }));
|
|
23
|
+
child.on('error', err => resolve({ success: false, stdout: '', stderr: err.message }));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const router = express.Router();
|
|
28
|
+
|
|
29
|
+
// ─── GET /api/settings ─────────────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
router.get('/settings', (req, res) => {
|
|
32
|
+
try {
|
|
33
|
+
const config = loadConfig();
|
|
34
|
+
// Never return the password (write-only field)
|
|
35
|
+
const { dashboardPort, nginxDir, sslDir, acmeEmail } = config;
|
|
36
|
+
res.json({
|
|
37
|
+
dashboardPort,
|
|
38
|
+
nginxDir,
|
|
39
|
+
sslDir,
|
|
40
|
+
acmeEmail,
|
|
41
|
+
platform: process.platform === 'win32' ? 'win32' : 'linux',
|
|
42
|
+
});
|
|
43
|
+
} catch (err) {
|
|
44
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// ─── POST /api/settings ────────────────────────────────────────────────────
|
|
49
|
+
|
|
50
|
+
router.post('/settings', (req, res) => {
|
|
51
|
+
try {
|
|
52
|
+
const { dashboardPort, dashboardPassword, nginxDir, sslDir, acmeEmail } = req.body;
|
|
53
|
+
|
|
54
|
+
// Validate port if provided
|
|
55
|
+
if (dashboardPort !== undefined) {
|
|
56
|
+
const portError = validatePort(parseInt(dashboardPort, 10));
|
|
57
|
+
if (portError) return res.status(400).json({ error: portError });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Validate password if provided
|
|
61
|
+
if (dashboardPassword !== undefined && typeof dashboardPassword !== 'string') {
|
|
62
|
+
return res.status(400).json({ error: 'Password must be a string' });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Validate directories if provided
|
|
66
|
+
if (nginxDir !== undefined && (typeof nginxDir !== 'string' || nginxDir.trim() === '')) {
|
|
67
|
+
return res.status(400).json({ error: 'Nginx directory must be a non-empty string' });
|
|
68
|
+
}
|
|
69
|
+
if (sslDir !== undefined && (typeof sslDir !== 'string' || sslDir.trim() === '')) {
|
|
70
|
+
return res.status(400).json({ error: 'SSL directory must be a non-empty string' });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Validate email if provided
|
|
74
|
+
if (acmeEmail !== undefined) {
|
|
75
|
+
const emailError = validateEmail(acmeEmail);
|
|
76
|
+
if (emailError) return res.status(400).json({ error: emailError });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Load current config and merge updates
|
|
80
|
+
const currentConfig = loadConfig();
|
|
81
|
+
const updates = {};
|
|
82
|
+
|
|
83
|
+
if (dashboardPort !== undefined) {
|
|
84
|
+
updates.dashboardPort = parseInt(dashboardPort, 10);
|
|
85
|
+
}
|
|
86
|
+
if (dashboardPassword !== undefined) {
|
|
87
|
+
updates.dashboardPassword = dashboardPassword;
|
|
88
|
+
}
|
|
89
|
+
if (nginxDir !== undefined) {
|
|
90
|
+
updates.nginxDir = nginxDir.trim();
|
|
91
|
+
}
|
|
92
|
+
if (sslDir !== undefined) {
|
|
93
|
+
updates.sslDir = sslDir.trim();
|
|
94
|
+
}
|
|
95
|
+
if (acmeEmail !== undefined) {
|
|
96
|
+
updates.acmeEmail = acmeEmail.trim();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const newConfig = { ...currentConfig, ...updates };
|
|
100
|
+
saveConfig(newConfig);
|
|
101
|
+
|
|
102
|
+
res.json({ success: true });
|
|
103
|
+
} catch (err) {
|
|
104
|
+
res.status(500).json({ error: 'Internal server error' });
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// ─── GET /api/settings/permissions ────────────────────────────────────────────
|
|
109
|
+
|
|
110
|
+
router.get('/settings/permissions', async (req, res) => {
|
|
111
|
+
if (process.platform === 'win32') return res.json({ configured: true });
|
|
112
|
+
try {
|
|
113
|
+
const configured = await checkPermissionsConfigured();
|
|
114
|
+
res.json({ configured });
|
|
115
|
+
} catch {
|
|
116
|
+
res.json({ configured: false });
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// ─── POST /api/settings/permissions/setup ─────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
router.post('/settings/permissions/setup', async (req, res) => {
|
|
123
|
+
if (process.platform === 'win32') {
|
|
124
|
+
return res.status(400).json({ error: 'Not applicable on Windows' });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const { password } = req.body ?? {};
|
|
128
|
+
if (!password || typeof password !== 'string') {
|
|
129
|
+
return res.status(400).json({ error: 'Password is required' });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Resolve nginx binary path
|
|
133
|
+
const whichResult = await run('which nginx');
|
|
134
|
+
if (!whichResult.success || !whichResult.stdout.trim()) {
|
|
135
|
+
return res.status(500).json({ error: 'nginx not found. Is nginx installed?' });
|
|
136
|
+
}
|
|
137
|
+
const nginxPath = whichResult.stdout.trim().split('\n')[0].trim();
|
|
138
|
+
const user = os.userInfo().username;
|
|
139
|
+
|
|
140
|
+
// Build sudoers rules with the detected nginx path
|
|
141
|
+
const sudoRules = [
|
|
142
|
+
'/usr/bin/systemctl start nginx',
|
|
143
|
+
'/usr/bin/systemctl stop nginx',
|
|
144
|
+
'/usr/bin/systemctl reload nginx',
|
|
145
|
+
'/usr/bin/systemctl restart nginx',
|
|
146
|
+
'/usr/bin/systemctl',
|
|
147
|
+
nginxPath,
|
|
148
|
+
`${nginxPath} -t`,
|
|
149
|
+
`${nginxPath} -s reload`,
|
|
150
|
+
`${nginxPath} -s stop`,
|
|
151
|
+
`${nginxPath} -s quit`,
|
|
152
|
+
'/usr/bin/certbot',
|
|
153
|
+
'/usr/bin/mkdir',
|
|
154
|
+
'/usr/bin/cp',
|
|
155
|
+
'/usr/bin/chmod',
|
|
156
|
+
'/usr/bin/chown',
|
|
157
|
+
'/usr/bin/tee',
|
|
158
|
+
].join(', ');
|
|
159
|
+
|
|
160
|
+
const sudoersContent = `${user} ALL=(ALL) NOPASSWD: ${sudoRules}\n`;
|
|
161
|
+
|
|
162
|
+
// Write content to a temp file (no sudo needed for /tmp)
|
|
163
|
+
const tmpFile = path.join('/tmp', `easy-devops-sudoers-${Date.now()}`);
|
|
164
|
+
try {
|
|
165
|
+
await fs.writeFile(tmpFile, sudoersContent, { mode: 0o600 });
|
|
166
|
+
} catch (err) {
|
|
167
|
+
return res.status(500).json({ error: 'Failed to write temp file', output: err.message });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Run all setup steps in a single sudo -S invocation
|
|
171
|
+
const setupCmd = [
|
|
172
|
+
`mkdir -p /etc/easy-devops /var/log/easy-devops`,
|
|
173
|
+
`chown ${user}:${user} /etc/easy-devops /var/log/easy-devops`,
|
|
174
|
+
`chown -R ${user}:${user} /etc/nginx/conf.d 2>/dev/null || true`,
|
|
175
|
+
`cp '${tmpFile}' /etc/sudoers.d/easy-devops`,
|
|
176
|
+
`chmod 440 /etc/sudoers.d/easy-devops`,
|
|
177
|
+
].join(' && ');
|
|
178
|
+
|
|
179
|
+
const result = await runSudoS(setupCmd, password);
|
|
180
|
+
await fs.unlink(tmpFile).catch(() => {});
|
|
181
|
+
|
|
182
|
+
if (!result.success) {
|
|
183
|
+
const output = result.stderr || result.stdout;
|
|
184
|
+
const wrongPassword = output.includes('incorrect password') || output.includes('Sorry, try again') || output.includes('3 incorrect');
|
|
185
|
+
return res.status(wrongPassword ? 401 : 500).json({
|
|
186
|
+
error: wrongPassword ? 'Incorrect password' : 'Setup failed',
|
|
187
|
+
output,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
res.json({ success: true });
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
export default router;
|
|
@@ -119,18 +119,119 @@ border-radius: 10px;
|
|
|
119
119
|
transition: border-color 200ms, box-shadow 200ms, background 200ms;
|
|
120
120
|
outline: none;
|
|
121
121
|
}
|
|
122
|
+
.form-input::placeholder {
|
|
123
|
+
color: var(--color-muted);
|
|
124
|
+
opacity: 0.55;
|
|
125
|
+
}
|
|
126
|
+
.form-input:hover:not(:focus):not(:disabled) {
|
|
127
|
+
border-color: rgba(var(--color-primary-rgb), 0.35);
|
|
128
|
+
}
|
|
122
129
|
.form-input:focus {
|
|
123
130
|
background: rgba(var(--color-primary-rgb), 0.05);
|
|
124
131
|
border-color: var(--color-primary);
|
|
125
132
|
box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
|
|
126
133
|
}
|
|
134
|
+
.form-input:disabled {
|
|
135
|
+
opacity: 0.45;
|
|
136
|
+
cursor: not-allowed;
|
|
137
|
+
}
|
|
127
138
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
/* ── Custom Select (cselect) ── */
|
|
140
|
+
.cselect {
|
|
141
|
+
position: relative;
|
|
142
|
+
min-width: 200px;
|
|
143
|
+
user-select: none;
|
|
144
|
+
}
|
|
145
|
+
.cselect__trigger {
|
|
146
|
+
width: 100%;
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: center;
|
|
149
|
+
justify-content: space-between;
|
|
150
|
+
gap: 10px;
|
|
151
|
+
padding: 9px 12px;
|
|
152
|
+
background: var(--color-input);
|
|
153
|
+
border: 1px solid var(--color-border);
|
|
154
|
+
border-radius: 10px;
|
|
155
|
+
color: var(--color-text);
|
|
156
|
+
font-size: 13px;
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
text-align: left;
|
|
159
|
+
transition: border-color 150ms, box-shadow 150ms, background 150ms;
|
|
160
|
+
outline: none;
|
|
161
|
+
}
|
|
162
|
+
.cselect__trigger:hover {
|
|
163
|
+
border-color: rgba(var(--color-primary-rgb), 0.45);
|
|
164
|
+
}
|
|
165
|
+
.cselect--open .cselect__trigger {
|
|
166
|
+
border-color: var(--color-primary);
|
|
167
|
+
background: rgba(var(--color-primary-rgb), 0.04);
|
|
168
|
+
box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.15);
|
|
169
|
+
}
|
|
170
|
+
.cselect__arrow {
|
|
171
|
+
width: 15px;
|
|
172
|
+
height: 15px;
|
|
173
|
+
flex-shrink: 0;
|
|
174
|
+
color: var(--color-muted);
|
|
175
|
+
transition: transform 200ms ease, color 200ms ease;
|
|
176
|
+
}
|
|
177
|
+
.cselect--open .cselect__arrow {
|
|
178
|
+
transform: rotate(180deg);
|
|
179
|
+
color: var(--color-primary);
|
|
180
|
+
}
|
|
181
|
+
.cselect__panel {
|
|
182
|
+
position: absolute;
|
|
183
|
+
top: calc(100% + 6px);
|
|
184
|
+
left: 0;
|
|
185
|
+
right: 0;
|
|
186
|
+
background: var(--color-surface);
|
|
187
|
+
border: 1px solid var(--color-border);
|
|
188
|
+
border-radius: 12px;
|
|
189
|
+
box-shadow: 0 12px 32px rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.15);
|
|
190
|
+
z-index: 200;
|
|
191
|
+
overflow: hidden;
|
|
192
|
+
padding: 5px;
|
|
193
|
+
max-height: 240px;
|
|
194
|
+
overflow-y: auto;
|
|
195
|
+
}
|
|
196
|
+
.cselect__panel::-webkit-scrollbar { width: 4px; }
|
|
197
|
+
.cselect__panel::-webkit-scrollbar-track { background: transparent; }
|
|
198
|
+
.cselect__panel::-webkit-scrollbar-thumb { background: rgba(var(--color-primary-rgb), 0.3); border-radius: 9999px; }
|
|
199
|
+
.cselect__option {
|
|
200
|
+
width: 100%;
|
|
201
|
+
display: flex;
|
|
202
|
+
align-items: center;
|
|
203
|
+
gap: 8px;
|
|
204
|
+
padding: 8px 10px;
|
|
205
|
+
border-radius: 8px;
|
|
206
|
+
color: var(--color-muted);
|
|
207
|
+
font-size: 13px;
|
|
208
|
+
cursor: pointer;
|
|
209
|
+
background: none;
|
|
210
|
+
border: none;
|
|
211
|
+
text-align: left;
|
|
212
|
+
transition: background 100ms, color 100ms;
|
|
213
|
+
}
|
|
214
|
+
.cselect__option:hover {
|
|
215
|
+
background: rgba(var(--color-primary-rgb), 0.08);
|
|
216
|
+
color: var(--color-text);
|
|
217
|
+
}
|
|
218
|
+
.cselect__option--active {
|
|
219
|
+
color: var(--color-primary);
|
|
220
|
+
background: rgba(var(--color-primary-rgb), 0.07);
|
|
221
|
+
font-weight: 600;
|
|
222
|
+
}
|
|
223
|
+
.cselect__empty {
|
|
224
|
+
padding: 12px 10px;
|
|
225
|
+
font-size: 12px;
|
|
226
|
+
color: var(--color-muted);
|
|
227
|
+
text-align: center;
|
|
228
|
+
font-style: italic;
|
|
229
|
+
}
|
|
230
|
+
.cselect__dot {
|
|
231
|
+
width: 7px;
|
|
232
|
+
height: 7px;
|
|
233
|
+
border-radius: 50%;
|
|
234
|
+
flex-shrink: 0;
|
|
134
235
|
}
|
|
135
236
|
|
|
136
237
|
/* Buttons */
|
|
@@ -210,7 +311,7 @@ border-radius: 20px;
|
|
|
210
311
|
overflow: hidden;
|
|
211
312
|
border: 1px solid var(--color-border);
|
|
212
313
|
box-shadow: 0 40px 100px rgba(0,0,0,0.5), 0 16px 40px rgba(0,0,0,0.3);
|
|
213
|
-
max-height: 90vh;
|
|
314
|
+
max-height: min(90vh, calc(100dvh - 3rem));
|
|
214
315
|
position: relative;
|
|
215
316
|
background: var(--color-surface);
|
|
216
317
|
}
|
|
@@ -482,6 +583,9 @@ box-shadow: 0 0 0 2px var(--color-bg), 0 0 0 4px currentColor;
|
|
|
482
583
|
<body class="font-sans antialiased text-[14px]">
|
|
483
584
|
|
|
484
585
|
<div id="app" v-cloak class="min-h-screen flex text-foreground bg-background relative z-0">
|
|
586
|
+
<!-- Domain Form Modal — mounted at app root to avoid stacking context / overflow clipping issues -->
|
|
587
|
+
<%- include('partials/domain-form.ejs') %>
|
|
588
|
+
|
|
485
589
|
<!-- Login partial -->
|
|
486
590
|
<%- include('partials/login.ejs') %>
|
|
487
591
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div v-if="domains.showForm" class="fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6 modal-overlay">
|
|
4
4
|
|
|
5
5
|
<!-- Modal Card -->
|
|
6
|
-
<div class="relative w-full max-w-4xl
|
|
6
|
+
<div class="relative w-full max-w-4xl flex flex-col modal-card">
|
|
7
7
|
|
|
8
8
|
<!-- Modal Header -->
|
|
9
9
|
<div class="flex items-center justify-between p-5 border-b border-border shrink-0" style="background: rgba(0,0,0,0.1)">
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
85
|
<!-- Modal Body (Scrollable) -->
|
|
86
|
-
<div class="flex-1 overflow-y-auto w-full flex flex-col pb-6 rounded-b-[20px] bg-transparent">
|
|
86
|
+
<div class="flex-1 min-h-0 overflow-y-auto w-full flex flex-col pb-6 rounded-b-[20px] bg-transparent">
|
|
87
87
|
|
|
88
88
|
<!-- Accordion Section: Basic -->
|
|
89
89
|
<div class="border-b border-border">
|
|
@@ -111,11 +111,34 @@
|
|
|
111
111
|
|
|
112
112
|
<div class="w-full">
|
|
113
113
|
<label class="form-label">Upstream Type</label>
|
|
114
|
-
<
|
|
115
|
-
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
<div class="cselect" :class="{ 'cselect--open': domains.upstreamTypeOpen }"
|
|
115
|
+
v-click-outside="() => domains.upstreamTypeOpen = false">
|
|
116
|
+
<button type="button" class="cselect__trigger"
|
|
117
|
+
@click="domains.upstreamTypeOpen = !domains.upstreamTypeOpen">
|
|
118
|
+
<span class="flex items-center gap-2">
|
|
119
|
+
<span class="cselect__dot"
|
|
120
|
+
:style="{ background: domains.form.upstreamType === 'http' ? '#3b82f6' : domains.form.upstreamType === 'https' ? '#22c55e' : '#a855f7' }">
|
|
121
|
+
</span>
|
|
122
|
+
{{ domains.form.upstreamType === 'http' ? 'HTTP' : domains.form.upstreamType === 'https' ? 'HTTPS' : 'WebSocket' }}
|
|
123
|
+
</span>
|
|
124
|
+
<svg class="cselect__arrow" viewBox="0 0 20 20" fill="currentColor">
|
|
125
|
+
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
|
|
126
|
+
</svg>
|
|
127
|
+
</button>
|
|
128
|
+
<div class="cselect__panel" v-show="domains.upstreamTypeOpen">
|
|
129
|
+
<button v-for="opt in [{v:'http',l:'HTTP',c:'#3b82f6'},{v:'https',l:'HTTPS',c:'#22c55e'},{v:'ws',l:'WebSocket',c:'#a855f7'}]"
|
|
130
|
+
:key="opt.v" type="button"
|
|
131
|
+
class="cselect__option"
|
|
132
|
+
:class="{ 'cselect__option--active': domains.form.upstreamType === opt.v }"
|
|
133
|
+
@mousedown.prevent="domains.form.upstreamType = opt.v; domains.upstreamTypeOpen = false">
|
|
134
|
+
<span class="cselect__dot" :style="{ background: opt.c }"></span>
|
|
135
|
+
<span>{{ opt.l }}</span>
|
|
136
|
+
<svg v-if="domains.form.upstreamType === opt.v" class="w-3.5 h-3.5 shrink-0 ml-auto" fill="currentColor" viewBox="0 0 20 20">
|
|
137
|
+
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
|
|
138
|
+
</svg>
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
119
142
|
</div>
|
|
120
143
|
|
|
121
144
|
<div class="flex items-center justify-between p-4 bg-black/10 dark:bg-black/20 border border-border w-full md:col-span-2 rounded-[12px]">
|
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
</button>
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
|
-
<!-- Domain Form Modal / Drawer Equivalent -->
|
|
15
|
-
<%- include('domain-form.ejs') %>
|
|
16
|
-
|
|
17
14
|
<!-- Data Display -->
|
|
18
15
|
<div v-if="domains.loading" class="text-muted text-sm flex items-center gap-2">
|
|
19
16
|
<!-- Skeleton loader instead of spinner -->
|
|
@@ -57,10 +57,31 @@ Start
|
|
|
57
57
|
<div class="flex flex-col sm:flex-row sm:items-center justify-between p-5 border-b border-border bg-black/5 dark:bg-white/5 gap-4">
|
|
58
58
|
<h3 class="form-label !mb-0 font-bold">Config Editor</h3>
|
|
59
59
|
<div class="flex gap-3">
|
|
60
|
-
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
<!-- Custom Config File Dropdown -->
|
|
61
|
+
<div class="cselect" :class="{ 'cselect--open': nginx.configDropdownOpen }"
|
|
62
|
+
v-click-outside="() => nginx.configDropdownOpen = false">
|
|
63
|
+
<button type="button" class="cselect__trigger font-mono text-[12px]"
|
|
64
|
+
@click="nginx.configDropdownOpen = !nginx.configDropdownOpen">
|
|
65
|
+
<span :class="nginx.selectedConfig ? 'text-foreground' : 'text-muted'">
|
|
66
|
+
{{ nginx.selectedConfig || 'Select config file…' }}
|
|
67
|
+
</span>
|
|
68
|
+
<svg class="cselect__arrow" viewBox="0 0 20 20" fill="currentColor">
|
|
69
|
+
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd"/>
|
|
70
|
+
</svg>
|
|
71
|
+
</button>
|
|
72
|
+
<div class="cselect__panel" v-show="nginx.configDropdownOpen">
|
|
73
|
+
<div v-if="nginx.configs.length === 0" class="cselect__empty">No config files found</div>
|
|
74
|
+
<button v-for="c in nginx.configs" :key="c" type="button"
|
|
75
|
+
class="cselect__option font-mono text-[12px]"
|
|
76
|
+
:class="{ 'cselect__option--active': nginx.selectedConfig === c }"
|
|
77
|
+
@mousedown.prevent="nginx.selectedConfig = c; selectConfig(c); nginx.configDropdownOpen = false">
|
|
78
|
+
<span class="truncate">{{ c }}</span>
|
|
79
|
+
<svg v-if="nginx.selectedConfig === c" class="w-3.5 h-3.5 shrink-0 ml-auto" fill="currentColor" viewBox="0 0 20 20">
|
|
80
|
+
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
|
|
81
|
+
</svg>
|
|
82
|
+
</button>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
64
85
|
<button @click="saveNginxConfig" :disabled="!nginx.selectedConfig || nginx.configSaving" class="btn btn-primary min-w-[80px]">
|
|
65
86
|
<svg v-if="nginx.configSaving" class="w-3 h-3 animate-spin mr-1.5 inline-block" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>
|
|
66
87
|
{{ nginx.configSaving ? 'Wait...' : 'Save' }}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
<div class="w-full">
|
|
20
20
|
<label class="form-label">Dashboard Port</label>
|
|
21
|
-
<input v-model.number="settings.dashboardPort" type="number" class="form-input" placeholder="
|
|
21
|
+
<input v-model.number="settings.dashboardPort" type="number" class="form-input" placeholder="6443" />
|
|
22
22
|
<p class="text-[11px] text-muted mt-2 font-bold tracking-wide uppercase opacity-70">Restart dashboard after changing</p>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
@@ -65,4 +65,37 @@
|
|
|
65
65
|
</div>
|
|
66
66
|
</div>
|
|
67
67
|
</div>
|
|
68
|
+
|
|
69
|
+
<!-- Linux Permissions card (hidden on Windows) -->
|
|
70
|
+
<div v-if="settings.platform !== 'win32'" class="stat-card overflow-hidden relative mt-6">
|
|
71
|
+
<div class="absolute top-0 left-0 w-full h-1" :class="permissions.configured ? 'bg-green-500/40' : 'bg-yellow-500/40'"></div>
|
|
72
|
+
<div class="p-6 border-b border-border/50 bg-black/5 dark:bg-white/5 flex items-center justify-between">
|
|
73
|
+
<div>
|
|
74
|
+
<h3 class="form-label !mb-0 font-bold">Linux Permissions</h3>
|
|
75
|
+
<p class="text-[11px] text-muted mt-1 font-bold tracking-wide uppercase opacity-70">Passwordless sudo for nginx and systemctl</p>
|
|
76
|
+
</div>
|
|
77
|
+
<span v-if="permissions.configured" class="text-green-500 text-xs font-bold px-2.5 py-1 rounded-lg bg-green-500/10 border border-green-500/20">✓ Configured</span>
|
|
78
|
+
<span v-else class="text-yellow-500 text-xs font-bold px-2.5 py-1 rounded-lg bg-yellow-500/10 border border-yellow-500/20">⚠ Required</span>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="p-8 bg-background">
|
|
81
|
+
<p v-if="permissions.configured" class="text-sm text-muted">Passwordless sudo is configured. The dashboard can manage nginx and systemctl without prompting for a password.</p>
|
|
82
|
+
<div v-else>
|
|
83
|
+
<p class="text-sm text-muted mb-6">The dashboard needs passwordless sudo to control nginx and systemctl. Enter your sudo password once to configure it.</p>
|
|
84
|
+
<div class="w-full max-w-md">
|
|
85
|
+
<label class="form-label">Sudo Password</label>
|
|
86
|
+
<input v-model="permissions.password" type="password" class="form-input" placeholder="Enter your sudo password" @keyup.enter="setupPermissions" />
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<div v-if="!permissions.configured" class="p-5 border-t border-border bg-black/5 dark:bg-white/5 flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
|
91
|
+
<button @click="setupPermissions" :disabled="permissions.loading || !permissions.password" class="btn btn-primary min-w-[180px] shadow-sm">
|
|
92
|
+
<svg v-if="permissions.loading" class="w-4 h-4 animate-spin -ml-1 mr-2 inline-block" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"></path></svg>
|
|
93
|
+
{{ permissions.loading ? 'Setting up...' : 'Setup Permissions' }}
|
|
94
|
+
</button>
|
|
95
|
+
<div>
|
|
96
|
+
<span v-if="permissions.msg" class="text-green-500 text-[13px] font-bold px-3 py-1.5 rounded-[10px] bg-green-500/10 border border-green-500/20">{{ permissions.msg }}</span>
|
|
97
|
+
<span v-if="permissions.error" class="text-red-500 text-[13px] font-bold px-3 py-1.5 rounded-[10px] bg-red-500/10 border border-red-500/20">{{ permissions.error }}</span>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
68
101
|
</div>
|
|
@@ -101,7 +101,7 @@ _pick_tty() {
|
|
|
101
101
|
fi
|
|
102
102
|
|
|
103
103
|
local ch seq1 seq2
|
|
104
|
-
IFS= read -r -n1 ch 2>/dev/null || ch=""
|
|
104
|
+
IFS= read -r -n1 ch < /dev/tty 2>/dev/null || ch=""
|
|
105
105
|
|
|
106
106
|
# Check flag again after read (signal may have arrived during read)
|
|
107
107
|
if [ "$_cancelled" = "true" ]; then
|
|
@@ -109,8 +109,8 @@ _pick_tty() {
|
|
|
109
109
|
fi
|
|
110
110
|
|
|
111
111
|
if [ "$ch" = $'\x1b' ]; then
|
|
112
|
-
IFS= read -r -n1 -t 0.1 seq1 2>/dev/null || seq1=""
|
|
113
|
-
IFS= read -r -n1 -t 0.1 seq2 2>/dev/null || seq2=""
|
|
112
|
+
IFS= read -r -n1 -t 0.1 seq1 < /dev/tty 2>/dev/null || seq1=""
|
|
113
|
+
IFS= read -r -n1 -t 0.1 seq2 < /dev/tty 2>/dev/null || seq2=""
|
|
114
114
|
if [ "$seq1" = "[" ]; then
|
|
115
115
|
case "$seq2" in
|
|
116
116
|
A) [ "$selected" -gt 0 ] && selected=$(( selected - 1 )) ;;
|
|
@@ -164,7 +164,7 @@ _pick_numbered() {
|
|
|
164
164
|
local choice
|
|
165
165
|
while true; do
|
|
166
166
|
printf 'Enter number (1-%d), or q to quit: ' "$count"
|
|
167
|
-
IFS= read -r choice
|
|
167
|
+
IFS= read -r choice < /dev/tty
|
|
168
168
|
if [ "$choice" = "q" ] || [ "$choice" = "Q" ]; then
|
|
169
169
|
return 2
|
|
170
170
|
fi
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { loadConfig, saveConfig } from '../../core/config.js';
|
|
3
|
-
import { validatePort, validateEmail } from '../../core/validators.js';
|
|
4
|
-
|
|
5
|
-
const router = express.Router();
|
|
6
|
-
|
|
7
|
-
// ─── GET /api/settings ─────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
router.get('/settings', (req, res) => {
|
|
10
|
-
try {
|
|
11
|
-
const config = loadConfig();
|
|
12
|
-
// Never return the password (write-only field)
|
|
13
|
-
const { dashboardPort, nginxDir, sslDir, acmeEmail } = config;
|
|
14
|
-
res.json({
|
|
15
|
-
dashboardPort,
|
|
16
|
-
nginxDir,
|
|
17
|
-
sslDir,
|
|
18
|
-
acmeEmail,
|
|
19
|
-
platform: process.platform === 'win32' ? 'win32' : 'linux',
|
|
20
|
-
});
|
|
21
|
-
} catch (err) {
|
|
22
|
-
res.status(500).json({ error: 'Internal server error' });
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// ─── POST /api/settings ────────────────────────────────────────────────────
|
|
27
|
-
|
|
28
|
-
router.post('/settings', (req, res) => {
|
|
29
|
-
try {
|
|
30
|
-
const { dashboardPort, dashboardPassword, nginxDir, sslDir, acmeEmail } = req.body;
|
|
31
|
-
|
|
32
|
-
// Validate port if provided
|
|
33
|
-
if (dashboardPort !== undefined) {
|
|
34
|
-
const portError = validatePort(parseInt(dashboardPort, 10));
|
|
35
|
-
if (portError) return res.status(400).json({ error: portError });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Validate password if provided
|
|
39
|
-
if (dashboardPassword !== undefined && typeof dashboardPassword !== 'string') {
|
|
40
|
-
return res.status(400).json({ error: 'Password must be a string' });
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Validate directories if provided
|
|
44
|
-
if (nginxDir !== undefined && (typeof nginxDir !== 'string' || nginxDir.trim() === '')) {
|
|
45
|
-
return res.status(400).json({ error: 'Nginx directory must be a non-empty string' });
|
|
46
|
-
}
|
|
47
|
-
if (sslDir !== undefined && (typeof sslDir !== 'string' || sslDir.trim() === '')) {
|
|
48
|
-
return res.status(400).json({ error: 'SSL directory must be a non-empty string' });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Validate email if provided
|
|
52
|
-
if (acmeEmail !== undefined) {
|
|
53
|
-
const emailError = validateEmail(acmeEmail);
|
|
54
|
-
if (emailError) return res.status(400).json({ error: emailError });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Load current config and merge updates
|
|
58
|
-
const currentConfig = loadConfig();
|
|
59
|
-
const updates = {};
|
|
60
|
-
|
|
61
|
-
if (dashboardPort !== undefined) {
|
|
62
|
-
updates.dashboardPort = parseInt(dashboardPort, 10);
|
|
63
|
-
}
|
|
64
|
-
if (dashboardPassword !== undefined) {
|
|
65
|
-
updates.dashboardPassword = dashboardPassword;
|
|
66
|
-
}
|
|
67
|
-
if (nginxDir !== undefined) {
|
|
68
|
-
updates.nginxDir = nginxDir.trim();
|
|
69
|
-
}
|
|
70
|
-
if (sslDir !== undefined) {
|
|
71
|
-
updates.sslDir = sslDir.trim();
|
|
72
|
-
}
|
|
73
|
-
if (acmeEmail !== undefined) {
|
|
74
|
-
updates.acmeEmail = acmeEmail.trim();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const newConfig = { ...currentConfig, ...updates };
|
|
78
|
-
saveConfig(newConfig);
|
|
79
|
-
|
|
80
|
-
res.json({ success: true });
|
|
81
|
-
} catch (err) {
|
|
82
|
-
res.status(500).json({ error: 'Internal server error' });
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
export default router;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|