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
package/README.md
CHANGED
|
@@ -45,13 +45,13 @@ If you **don't have Node.js** yet, use the bootstrap installer:
|
|
|
45
45
|
#### Linux / macOS
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
|
-
curl -fsSL https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/install.sh
|
|
48
|
+
curl -fsSL https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/install.sh -o install.sh && bash install.sh
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
Or with wget:
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
|
-
wget -qO
|
|
54
|
+
wget -qO install.sh https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/install.sh && bash install.sh
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
#### Windows (PowerShell)
|
|
@@ -284,7 +284,7 @@ All configuration is stored in `data/easy-devops.sqlite`:
|
|
|
284
284
|
|
|
285
285
|
| Field | Default (Linux) | Default (Windows) | Description |
|
|
286
286
|
|-------|-----------------|-------------------|-------------|
|
|
287
|
-
| `dashboardPort` | `
|
|
287
|
+
| `dashboardPort` | `6443` | `6443` | Dashboard HTTP port |
|
|
288
288
|
| `dashboardPassword` | `admin` | `admin` | Dashboard login password |
|
|
289
289
|
| `nginxDir` | `/etc/nginx` | `C:\nginx` | Nginx installation directory |
|
|
290
290
|
| `sslDir` | `/etc/easy-devops/ssl` | `C:\easy-devops\ssl` | SSL certificate storage root |
|
|
@@ -296,28 +296,29 @@ All configuration is stored in `data/easy-devops.sqlite`:
|
|
|
296
296
|
|
|
297
297
|
```
|
|
298
298
|
easy-devops/
|
|
299
|
-
├──
|
|
300
|
-
│ ├──
|
|
301
|
-
│ ├──
|
|
302
|
-
│
|
|
303
|
-
|
|
304
|
-
│ ├──
|
|
305
|
-
│ ├──
|
|
306
|
-
│ ├──
|
|
307
|
-
│ ├──
|
|
308
|
-
│ ├──
|
|
309
|
-
│ ├──
|
|
310
|
-
│
|
|
311
|
-
|
|
312
|
-
│ ├──
|
|
313
|
-
│ ├──
|
|
314
|
-
│ ├──
|
|
315
|
-
│ ├──
|
|
316
|
-
│
|
|
299
|
+
├── src/
|
|
300
|
+
│ ├── cli/
|
|
301
|
+
│ │ ├── index.js # CLI entry point
|
|
302
|
+
│ │ ├── managers/ # Domain, Nginx, SSL, Node.js logic
|
|
303
|
+
│ │ └── menus/ # Thin menu dispatcher wrappers
|
|
304
|
+
│ ├── core/
|
|
305
|
+
│ │ ├── config.js # Configuration load/save
|
|
306
|
+
│ │ ├── db.js # SQLite helpers (good.db)
|
|
307
|
+
│ │ ├── detector.js # System environment detection
|
|
308
|
+
│ │ ├── nginx-conf-generator.js # Nginx conf builder (shared)
|
|
309
|
+
│ │ ├── platform.js # isWindows, nginx cmd helpers, combineOutput
|
|
310
|
+
│ │ ├── shell.js # Cross-platform shell executor
|
|
311
|
+
│ │ └── validators.js # Shared input validation helpers
|
|
312
|
+
│ ├── dashboard/
|
|
313
|
+
│ │ ├── server.js # Express + Socket.io server
|
|
314
|
+
│ │ ├── routes/ # auth, domains, nginx, settings, ssl
|
|
315
|
+
│ │ ├── lib/ # cert-reader, domains-db, nginx-service
|
|
316
|
+
│ │ ├── views/ # EJS templates + partials
|
|
317
|
+
│ │ └── public/ # Static assets (Vue 3 app)
|
|
318
|
+
│ └── lib/
|
|
319
|
+
│ └── installer/ # Bash helper modules for install.sh
|
|
317
320
|
├── data/
|
|
318
321
|
│ └── easy-devops.sqlite
|
|
319
|
-
├── lib/
|
|
320
|
-
│ └── installer/ # Bash helper modules for install.sh
|
|
321
322
|
├── install.sh # Linux/macOS bootstrap installer
|
|
322
323
|
└── install.ps1 # Windows PowerShell installer
|
|
323
324
|
```
|
package/install.sh
CHANGED
|
@@ -19,7 +19,7 @@ set -euo pipefail
|
|
|
19
19
|
# ---------------------------------------------------------------------------
|
|
20
20
|
# Resolve script and project directory
|
|
21
21
|
# ---------------------------------------------------------------------------
|
|
22
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
|
|
23
23
|
EASYDEVOPS_DIR="${EASYDEVOPS_DIR:-$SCRIPT_DIR}"
|
|
24
24
|
|
|
25
25
|
# ---------------------------------------------------------------------------
|
|
@@ -303,7 +303,7 @@ else
|
|
|
303
303
|
local_choice=""
|
|
304
304
|
while true; do
|
|
305
305
|
printf 'Enter 1, 2, or 3 (q to quit): '
|
|
306
|
-
IFS= read -r local_choice
|
|
306
|
+
IFS= read -r local_choice < /dev/tty
|
|
307
307
|
case "$local_choice" in
|
|
308
308
|
1)
|
|
309
309
|
NODE_ACTION="keep"
|
|
@@ -487,12 +487,35 @@ printf '\n'
|
|
|
487
487
|
|
|
488
488
|
if [ "$_allOK" = "true" ]; then
|
|
489
489
|
printf ' All steps completed successfully!\n\n'
|
|
490
|
-
printf '
|
|
491
|
-
printf '
|
|
490
|
+
printf ' To use immediately in this terminal, run:\n'
|
|
491
|
+
printf ' source ~/.bashrc\n\n'
|
|
492
|
+
printf ' Or open a new terminal, then run:\n'
|
|
493
|
+
printf ' easy-devops\n or ezz\n'
|
|
492
494
|
else
|
|
493
495
|
printf ' Some steps need attention -- see warnings above.\n\n'
|
|
494
496
|
printf ' Fallback:\n'
|
|
495
497
|
printf ' node cli/index.js\n'
|
|
496
498
|
fi
|
|
497
499
|
printf '\n'
|
|
500
|
+
|
|
501
|
+
# ---------------------------------------------------------------------------
|
|
502
|
+
# Source nvm into the current session so node/npm/easy-devops work immediately
|
|
503
|
+
# (only when nvm was actually used, i.e. NODE_ACTION != "keep")
|
|
504
|
+
# ---------------------------------------------------------------------------
|
|
505
|
+
if [ "$NODE_ACTION" != "keep" ]; then
|
|
506
|
+
export NVM_DIR="$HOME/.nvm"
|
|
507
|
+
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
|
508
|
+
. "$NVM_DIR/nvm.sh"
|
|
509
|
+
fi
|
|
510
|
+
|
|
511
|
+
# Also source shell config to pick up PATH changes
|
|
512
|
+
if [ -f "$HOME/.bashrc" ]; then
|
|
513
|
+
. "$HOME/.bashrc" 2>/dev/null || true
|
|
514
|
+
elif [ -f "$HOME/.bash_profile" ]; then
|
|
515
|
+
. "$HOME/.bash_profile" 2>/dev/null || true
|
|
516
|
+
elif [ -f "$HOME/.zshrc" ]; then
|
|
517
|
+
. "$HOME/.zshrc" 2>/dev/null || true
|
|
518
|
+
fi
|
|
519
|
+
fi
|
|
520
|
+
|
|
498
521
|
exit 0
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-devops",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A unified DevOps management tool with CLI and web dashboard for managing Nginx, SSL certificates, and Node.js on Linux and Windows servers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"devops",
|
|
7
7
|
"nginx",
|
|
8
8
|
"ssl",
|
|
9
|
-
"
|
|
9
|
+
"acme",
|
|
10
10
|
"letsencrypt",
|
|
11
11
|
"nodejs",
|
|
12
12
|
"dashboard",
|
|
@@ -30,26 +30,23 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/omar00050/Easy-DevOps#readme",
|
|
32
32
|
"type": "module",
|
|
33
|
-
"main": "cli/index.js",
|
|
33
|
+
"main": "src/cli/index.js",
|
|
34
34
|
"bin": {
|
|
35
|
-
"easy-devops": "cli/index.js",
|
|
36
|
-
"ezz": "cli/index.js"
|
|
35
|
+
"easy-devops": "src/cli/index.js",
|
|
36
|
+
"ezz": "src/cli/index.js"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
|
-
"
|
|
40
|
-
"core/",
|
|
41
|
-
"dashboard/",
|
|
42
|
-
"lib/",
|
|
39
|
+
"src/",
|
|
43
40
|
"data/.gitkeep",
|
|
44
41
|
"install.bat",
|
|
45
42
|
"install.ps1",
|
|
46
43
|
"install.sh"
|
|
47
44
|
],
|
|
48
45
|
"scripts": {
|
|
49
|
-
"start": "node cli/index.js",
|
|
46
|
+
"start": "node src/cli/index.js",
|
|
50
47
|
"test": "echo \" no test specified\"",
|
|
51
|
-
"dashboard": "node dashboard/server.js",
|
|
52
|
-
"system-info": "node cli/index.js system-info"
|
|
48
|
+
"dashboard": "node src/dashboard/server.js",
|
|
49
|
+
"system-info": "node src/cli/index.js system-info"
|
|
53
50
|
},
|
|
54
51
|
"engines": {
|
|
55
52
|
"node": ">=18.0.0"
|
|
@@ -66,4 +63,4 @@
|
|
|
66
63
|
"ora": "^7.0.1",
|
|
67
64
|
"socket.io": "^4.8.3"
|
|
68
65
|
}
|
|
69
|
-
}
|
|
66
|
+
}
|
package/{cli → src/cli}/index.js
RENAMED
|
@@ -14,7 +14,7 @@ import settingsMenu from './menus/settings.js';
|
|
|
14
14
|
import updateMenu from './menus/update.js';
|
|
15
15
|
|
|
16
16
|
const require = createRequire(import.meta.url);
|
|
17
|
-
const { version } = require('
|
|
17
|
+
const { version } = require('../../package.json');
|
|
18
18
|
|
|
19
19
|
process.on('SIGINT', () => process.exit(0));
|
|
20
20
|
|
|
@@ -20,7 +20,7 @@ import { loadConfig } from '../../core/config.js';
|
|
|
20
20
|
import { getDomains, saveDomains, findDomain, createDomain, DOMAIN_DEFAULTS } from '../../dashboard/lib/domains-db.js';
|
|
21
21
|
import { generateConf, buildConf } from '../../core/nginx-conf-generator.js';
|
|
22
22
|
import { issueCert } from './ssl-manager.js';
|
|
23
|
-
import { isWindows, nginxTestCmd, nginxReloadCmd, combineOutput } from '../../core/platform.js';
|
|
23
|
+
import { isWindows, nginxTestCmd, nginxReloadCmd, combineOutput, isNginxTestOk } from '../../core/platform.js';
|
|
24
24
|
|
|
25
25
|
// ─── List Domains ───────────────────────────────────────────────────────
|
|
26
26
|
|
|
@@ -300,9 +300,10 @@ async function addDomainAction() {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
spinner.text = 'Testing config...';
|
|
303
|
-
const
|
|
303
|
+
const testCmd = isWindows ? nginxTestCmd(nginxDir) : 'nginx -t';
|
|
304
|
+
const testResult = await run(testCmd, { cwd: nginxDir });
|
|
304
305
|
|
|
305
|
-
if (!testResult
|
|
306
|
+
if (!isNginxTestOk(testResult)) {
|
|
306
307
|
spinner.fail('Config test failed');
|
|
307
308
|
console.log(chalk.red('\n' + combineOutput(testResult)));
|
|
308
309
|
// Clean up failed config
|
|
@@ -376,9 +377,10 @@ async function editDomainAction() {
|
|
|
376
377
|
}
|
|
377
378
|
|
|
378
379
|
spinner.text = 'Testing config...';
|
|
379
|
-
const
|
|
380
|
+
const testCmd = isWindows ? nginxTestCmd(nginxDir) : 'nginx -t';
|
|
381
|
+
const testResult = await run(testCmd, { cwd: nginxDir });
|
|
380
382
|
|
|
381
|
-
if (!testResult
|
|
383
|
+
if (!isNginxTestOk(testResult)) {
|
|
382
384
|
spinner.fail('Config test failed');
|
|
383
385
|
console.log(chalk.red('\n' + combineOutput(testResult)));
|
|
384
386
|
return;
|
|
@@ -451,8 +453,9 @@ async function reloadNginxAfterChange() {
|
|
|
451
453
|
const { nginxDir } = loadConfig();
|
|
452
454
|
const spinner = ora('Reloading nginx...').start();
|
|
453
455
|
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
+
const testCmd = isWindows ? nginxTestCmd(nginxDir) : 'nginx -t';
|
|
457
|
+
const testResult = await run(testCmd, { cwd: nginxDir });
|
|
458
|
+
if (!isNginxTestOk(testResult)) {
|
|
456
459
|
spinner.fail('Config test failed');
|
|
457
460
|
console.log(chalk.red('\n' + combineOutput(testResult)));
|
|
458
461
|
return false;
|
|
@@ -526,8 +529,9 @@ async function toggleDomainAction() {
|
|
|
526
529
|
} else {
|
|
527
530
|
await fs.rename(disabledPath, enabledPath);
|
|
528
531
|
// Test config before reload
|
|
529
|
-
const
|
|
530
|
-
|
|
532
|
+
const testCmd = isWindows ? nginxTestCmd(nginxDir) : 'nginx -t';
|
|
533
|
+
const testResult = await run(testCmd, { cwd: nginxDir });
|
|
534
|
+
if (!isNginxTestOk(testResult)) {
|
|
531
535
|
await fs.rename(enabledPath, disabledPath).catch(() => {});
|
|
532
536
|
spinner.fail('Config test failed — rolled back');
|
|
533
537
|
console.log(chalk.red('\n' + combineOutput(testResult)));
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import inquirer from 'inquirer';
|
|
15
15
|
import ora from 'ora';
|
|
16
|
-
import { run, runLive } from '../../core/shell.js';
|
|
16
|
+
import { run, runLive, runInteractive } from '../../core/shell.js';
|
|
17
17
|
import { loadConfig } from '../../core/config.js';
|
|
18
18
|
import { ensureNginxInclude } from '../../core/nginx-conf-generator.js';
|
|
19
|
-
import { isWindows } from '../../core/platform.js';
|
|
19
|
+
import { isWindows, isNginxTestOk } from '../../core/platform.js';
|
|
20
|
+
import path from 'path';
|
|
20
21
|
|
|
21
22
|
// ─── Helpers ────────────────────────────────────────────────────────────────
|
|
22
23
|
import { access } from 'fs/promises';
|
|
@@ -66,23 +67,45 @@ async function testConfig(nginxExe, nginxDir) {
|
|
|
66
67
|
await ensureNginxInclude(nginxDir);
|
|
67
68
|
const cmd = isWindows ? `& "${nginxExe}" -t` : 'nginx -t';
|
|
68
69
|
const result = await run(cmd, { cwd: nginxDir });
|
|
69
|
-
const PathDomain = await pathExists(`${nginxDir}\\conf\\conf.d`);
|
|
70
|
-
const willKnown = await pathExists(`${nginxDir}\\html\\.well-known`);
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
// On Linux: conf.d is directly under nginxDir (/etc/nginx/conf.d)
|
|
72
|
+
// On Windows: conf.d is under the conf sub-directory (C:\nginx\conf\conf.d)
|
|
73
|
+
const confDPath = isWindows
|
|
74
|
+
? path.join(nginxDir, 'conf', 'conf.d')
|
|
75
|
+
: path.join(nginxDir, 'conf.d');
|
|
76
|
+
const wellKnownPath = path.join(nginxDir, 'html', '.well-known');
|
|
77
|
+
const acmePath = path.join(wellKnownPath, 'acme-challenge');
|
|
78
|
+
|
|
79
|
+
const hasConfD = await pathExists(confDPath);
|
|
80
|
+
const hasWellKnown = await pathExists(wellKnownPath);
|
|
81
|
+
|
|
82
|
+
if (!hasConfD) {
|
|
73
83
|
console.warn(chalk.yellow(`Warning: conf.d directory not found in ${nginxDir} — creating it now...`));
|
|
74
|
-
|
|
84
|
+
if (isWindows) {
|
|
85
|
+
await import('fs/promises').then(fs => fs.mkdir(confDPath, { recursive: true }));
|
|
86
|
+
} else {
|
|
87
|
+
const mkResult = await runInteractive(`sudo mkdir -p "${confDPath}"`);
|
|
88
|
+
if (!mkResult.success) {
|
|
89
|
+
console.warn(chalk.red(` Failed to create ${confDPath} — run manually: sudo mkdir -p ${confDPath}`));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
75
92
|
}
|
|
76
93
|
|
|
77
|
-
if (!
|
|
78
|
-
console.warn(chalk.yellow(`Warning: .well-known/acme-challenge directory not found
|
|
79
|
-
|
|
80
|
-
|
|
94
|
+
if (!hasWellKnown) {
|
|
95
|
+
console.warn(chalk.yellow(`Warning: .well-known/acme-challenge directory not found — creating it now...`));
|
|
96
|
+
if (isWindows) {
|
|
97
|
+
await import('fs/promises').then(fs => fs.mkdir(acmePath, { recursive: true }));
|
|
98
|
+
} else {
|
|
99
|
+
const mkResult = await runInteractive(`sudo mkdir -p "${acmePath}"`);
|
|
100
|
+
if (!mkResult.success) {
|
|
101
|
+
console.warn(chalk.red(` Failed to create ${acmePath} — run manually: sudo mkdir -p ${acmePath}`));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
81
104
|
}
|
|
82
105
|
|
|
83
106
|
return {
|
|
84
|
-
success: result
|
|
85
|
-
output: (result.stdout + '\n' + result.stderr).trim(),
|
|
107
|
+
success: isNginxTestOk(result),
|
|
108
|
+
output: ((result.stdout || '') + '\n' + (result.stderr || '')).trim(),
|
|
86
109
|
};
|
|
87
110
|
}
|
|
88
111
|
|
|
@@ -99,8 +122,12 @@ async function reloadNginx(nginxExe, nginxDir) {
|
|
|
99
122
|
}
|
|
100
123
|
|
|
101
124
|
spinner.text = 'Reloading nginx…';
|
|
102
|
-
|
|
103
|
-
|
|
125
|
+
let result;
|
|
126
|
+
if (isWindows) {
|
|
127
|
+
result = await run(`& "${nginxExe}" -s reload`, { cwd: nginxDir });
|
|
128
|
+
} else {
|
|
129
|
+
result = await runInteractive('sudo /usr/bin/systemctl reload nginx');
|
|
130
|
+
}
|
|
104
131
|
|
|
105
132
|
if (result.success) {
|
|
106
133
|
spinner.succeed('nginx reloaded successfully');
|
|
@@ -111,7 +138,7 @@ async function reloadNginx(nginxExe, nginxDir) {
|
|
|
111
138
|
return {
|
|
112
139
|
success: result.success,
|
|
113
140
|
message: result.success ? 'nginx reloaded successfully' : 'Reload failed',
|
|
114
|
-
output: (result.stdout + '\n' + result.stderr).trim(),
|
|
141
|
+
output: ((result.stdout || '') + '\n' + (result.stderr || '')).trim(),
|
|
115
142
|
};
|
|
116
143
|
}
|
|
117
144
|
|
|
@@ -134,7 +161,7 @@ async function restartNginx(nginxExe, nginxDir) {
|
|
|
134
161
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
135
162
|
result = await run(`& "${nginxExe}"`, { cwd: nginxDir });
|
|
136
163
|
} else {
|
|
137
|
-
result = await
|
|
164
|
+
result = await runInteractive('sudo /usr/bin/systemctl restart nginx');
|
|
138
165
|
}
|
|
139
166
|
|
|
140
167
|
if (result.success) {
|
|
@@ -146,7 +173,7 @@ async function restartNginx(nginxExe, nginxDir) {
|
|
|
146
173
|
return {
|
|
147
174
|
success: result.success,
|
|
148
175
|
message: result.success ? 'nginx restarted successfully' : 'Restart failed',
|
|
149
|
-
output: (result.stdout + '\n' + result.stderr).trim(),
|
|
176
|
+
output: ((result.stdout || '') + '\n' + (result.stderr || '')).trim(),
|
|
150
177
|
};
|
|
151
178
|
}
|
|
152
179
|
|
|
@@ -187,10 +214,9 @@ async function startNginx(nginxExe, nginxDir) {
|
|
|
187
214
|
const startCmd = `Start-Process -FilePath "${nginxExe}" -WorkingDirectory "${nginxDir}" -WindowStyle Hidden`;
|
|
188
215
|
await run(startCmd, { timeout: 10000 });
|
|
189
216
|
} else {
|
|
190
|
-
const result = await
|
|
217
|
+
const result = await runInteractive('sudo /usr/bin/systemctl start nginx');
|
|
191
218
|
if (!result.success) {
|
|
192
219
|
spinner.fail('Start failed');
|
|
193
|
-
console.log(chalk.red('\n' + (result.stderr || result.stdout)));
|
|
194
220
|
return { success: false };
|
|
195
221
|
}
|
|
196
222
|
}
|
|
@@ -236,15 +262,22 @@ async function startNginx(nginxExe, nginxDir) {
|
|
|
236
262
|
|
|
237
263
|
async function stopNginx(nginxDir) {
|
|
238
264
|
const spinner = ora('Stopping nginx…').start();
|
|
239
|
-
|
|
240
|
-
|
|
265
|
+
let result;
|
|
266
|
+
if (isWindows) {
|
|
267
|
+
result = await run('taskkill /f /IM nginx.exe', { cwd: nginxDir });
|
|
268
|
+
} else {
|
|
269
|
+
result = await runInteractive('sudo /usr/bin/systemctl stop nginx');
|
|
270
|
+
}
|
|
271
|
+
|
|
241
272
|
if (result.success) {
|
|
242
273
|
spinner.succeed('nginx stopped');
|
|
243
274
|
} else {
|
|
244
275
|
spinner.fail('Stop failed');
|
|
245
|
-
|
|
276
|
+
if (result.stderr || result.stdout) {
|
|
277
|
+
console.log(chalk.red('\n' + (result.stderr || result.stdout)));
|
|
278
|
+
}
|
|
246
279
|
}
|
|
247
|
-
return { success: result.success, output: (result.stdout + '\n' + result.stderr).trim() };
|
|
280
|
+
return { success: result.success, output: ((result.stdout || '') + '\n' + (result.stderr || '')).trim() };
|
|
248
281
|
}
|
|
249
282
|
|
|
250
283
|
// ─── installNginx ─────────────────────────────────────────────────────────────
|
|
@@ -252,15 +285,38 @@ async function stopNginx(nginxDir) {
|
|
|
252
285
|
async function installNginx() {
|
|
253
286
|
if (!isWindows) {
|
|
254
287
|
const spinner = ora('Installing nginx…').start();
|
|
255
|
-
const result = await
|
|
256
|
-
if (result.success) {
|
|
257
|
-
spinner.
|
|
258
|
-
|
|
288
|
+
const result = await runInteractive('sudo apt-get install -y nginx');
|
|
289
|
+
if (!result.success) {
|
|
290
|
+
spinner.fail('Installation failed');
|
|
291
|
+
console.log(chalk.gray('\n Manual instructions: https://nginx.org/en/docs/install.html\n'));
|
|
292
|
+
return { success: false, message: 'Installation failed', output: '' };
|
|
259
293
|
}
|
|
260
|
-
spinner.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
294
|
+
spinner.succeed('nginx installed successfully');
|
|
295
|
+
|
|
296
|
+
const { nginxDir } = loadConfig();
|
|
297
|
+
const confDPath = path.join(nginxDir, 'conf.d');
|
|
298
|
+
const acmePath = path.join(nginxDir, 'html', '.well-known', 'acme-challenge');
|
|
299
|
+
|
|
300
|
+
// Create conf.d directory for domain config files
|
|
301
|
+
const confSpinner = ora(`Creating ${confDPath}…`).start();
|
|
302
|
+
const confResult = await runInteractive(`sudo mkdir -p "${confDPath}"`);
|
|
303
|
+
if (confResult.success) {
|
|
304
|
+
confSpinner.succeed(`Created ${confDPath}`);
|
|
305
|
+
} else {
|
|
306
|
+
confSpinner.warn(`Could not create ${confDPath} — run manually: sudo mkdir -p ${confDPath}`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Create html/.well-known/acme-challenge directory for SSL certificate verification
|
|
310
|
+
const acmeSpinner = ora(`Creating ${acmePath}…`).start();
|
|
311
|
+
const acmeResult = await runInteractive(`sudo mkdir -p "${acmePath}"`);
|
|
312
|
+
if (acmeResult.success) {
|
|
313
|
+
await runInteractive(`sudo touch "${path.join(acmePath, '.keep')}"`);
|
|
314
|
+
acmeSpinner.succeed(`Created ${acmePath}`);
|
|
315
|
+
} else {
|
|
316
|
+
acmeSpinner.warn(`Could not create ${acmePath} — run manually: sudo mkdir -p ${acmePath}`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return { success: true, message: 'nginx installed successfully', output: '' };
|
|
264
320
|
}
|
|
265
321
|
|
|
266
322
|
// ── Windows ──────────────────────────────────────────────────────────────────
|
|
@@ -339,17 +395,11 @@ async function installNginx() {
|
|
|
339
395
|
}
|
|
340
396
|
|
|
341
397
|
// Create conf/conf.d directory for domain config files
|
|
342
|
-
await import('fs/promises').then(fs => fs.mkdir(
|
|
398
|
+
await import('fs/promises').then(fs => fs.mkdir(path.join(nginxDir, 'conf', 'conf.d'), { recursive: true }));
|
|
343
399
|
|
|
344
|
-
await import('fs/promises').then(fs => fs.mkdir(`${nginxDir}\\html\\.well-known\\`, { recursive: true }));
|
|
345
400
|
// Create html/.well-known/acme-challenge directory for SSL certificate verification
|
|
346
|
-
await import('fs/promises').then(fs => fs.
|
|
347
|
-
|
|
348
|
-
console.error(chalk.red(`Failed to create acme-challenge directory: ${err.message}`));
|
|
349
|
-
} else {
|
|
350
|
-
console.log(chalk.green('Created acme-challenge directory for SSL certificate verification'));
|
|
351
|
-
}
|
|
352
|
-
}));
|
|
401
|
+
await import('fs/promises').then(fs => fs.mkdir(path.join(nginxDir, 'html', '.well-known', 'acme-challenge'), { recursive: true }));
|
|
402
|
+
await import('fs/promises').then(fs => fs.writeFile(path.join(nginxDir, 'html', '.well-known', 'acme-challenge', '.keep'), ''));
|
|
353
403
|
|
|
354
404
|
spinner.succeed(`nginx ${nginxVersion} installed to ${nginxDir}`);
|
|
355
405
|
return { success: true, message: `nginx ${nginxVersion} installed successfully`, output: '' };
|
|
@@ -19,6 +19,7 @@ import path from 'path';
|
|
|
19
19
|
import http from 'http';
|
|
20
20
|
import net from 'net';
|
|
21
21
|
import * as acme from 'acme-client';
|
|
22
|
+
import os from 'os';
|
|
22
23
|
import { run, runLive } from '../../core/shell.js';
|
|
23
24
|
import { loadConfig } from '../../core/config.js';
|
|
24
25
|
import { isWindows } from '../../core/platform.js';
|
|
@@ -36,7 +37,14 @@ function getSslDir() {
|
|
|
36
37
|
*/
|
|
37
38
|
async function getAccountKey(sslDir) {
|
|
38
39
|
const keyPath = path.join(sslDir, '.account', 'account.key');
|
|
39
|
-
|
|
40
|
+
const accountDir = path.dirname(keyPath);
|
|
41
|
+
if (!isWindows) {
|
|
42
|
+
const user = os.userInfo().username;
|
|
43
|
+
await run(`sudo -n mkdir -p "${accountDir}"`);
|
|
44
|
+
await run(`sudo -n chown ${user}:${user} "${accountDir}"`);
|
|
45
|
+
} else {
|
|
46
|
+
await fs.mkdir(accountDir, { recursive: true });
|
|
47
|
+
}
|
|
40
48
|
try {
|
|
41
49
|
return await fs.readFile(keyPath);
|
|
42
50
|
} catch {
|
|
@@ -223,7 +231,13 @@ export async function issueCert(domainName, {
|
|
|
223
231
|
|
|
224
232
|
// Ensure certificate directory exists
|
|
225
233
|
const certDir = path.join(sslDir, domainName);
|
|
226
|
-
|
|
234
|
+
if (!isWindows) {
|
|
235
|
+
const user = os.userInfo().username;
|
|
236
|
+
await run(`sudo -n mkdir -p "${certDir}"`);
|
|
237
|
+
await run(`sudo -n chown ${user}:${user} "${certDir}"`);
|
|
238
|
+
} else {
|
|
239
|
+
await fs.mkdir(certDir, { recursive: true });
|
|
240
|
+
}
|
|
227
241
|
|
|
228
242
|
// Load or create account key
|
|
229
243
|
const accountKey = await getAccountKey(sslDir);
|
|
@@ -14,7 +14,7 @@ import { run } from '../../core/shell.js';
|
|
|
14
14
|
|
|
15
15
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
16
|
const isWindows = process.platform === 'win32';
|
|
17
|
-
const LOG_PATH = path.resolve(__dirname, '
|
|
17
|
+
const LOG_PATH = path.resolve(__dirname, '../../../data/dashboard.log');
|
|
18
18
|
const SERVER_PATH = path.resolve(__dirname, '../../dashboard/server.js');
|
|
19
19
|
|
|
20
20
|
// ─── Port helpers ─────────────────────────────────────────────────────────────
|
|
@@ -2,6 +2,7 @@ import chalk from 'chalk';
|
|
|
2
2
|
import inquirer from 'inquirer';
|
|
3
3
|
import { loadConfig, saveConfig } from '../../core/config.js';
|
|
4
4
|
import { dbGet } from '../../core/db.js';
|
|
5
|
+
import { setupLinuxPermissions, checkPermissionsConfigured } from '../../core/permissions.js';
|
|
5
6
|
|
|
6
7
|
export default async function settingsMenu() {
|
|
7
8
|
// T021: detect missing/corrupted config before loadConfig() creates defaults
|
|
@@ -17,6 +18,9 @@ export default async function settingsMenu() {
|
|
|
17
18
|
const passwordDisplay = config.dashboardPassword ? '***' : '(not set)';
|
|
18
19
|
const emailDisplay = config.acmeEmail || '(not set)';
|
|
19
20
|
|
|
21
|
+
const isLinux = process.platform !== 'win32';
|
|
22
|
+
const permsOk = isLinux ? await checkPermissionsConfigured() : true;
|
|
23
|
+
|
|
20
24
|
console.log();
|
|
21
25
|
console.log(chalk.bold('⚙️ Settings'));
|
|
22
26
|
console.log(chalk.gray('─'.repeat(40)));
|
|
@@ -38,12 +42,31 @@ export default async function settingsMenu() {
|
|
|
38
42
|
{ name: `Nginx Directory (${config.nginxDir})`, value: 'nginxDir' },
|
|
39
43
|
{ name: `SSL Directory (${config.sslDir})`, value: 'sslDir' },
|
|
40
44
|
{ name: `ACME Email (${emailDisplay})`, value: 'acmeEmail' },
|
|
45
|
+
...(isLinux ? [{
|
|
46
|
+
name: permsOk
|
|
47
|
+
? '🔓 Linux Permissions ✅ configured'
|
|
48
|
+
: '🔓 Setup Linux Permissions ⚠ required',
|
|
49
|
+
value: 'permissions',
|
|
50
|
+
}] : []),
|
|
41
51
|
{ name: '← Back', value: 'back' },
|
|
42
52
|
],
|
|
43
53
|
}]);
|
|
44
54
|
|
|
45
55
|
if (field === 'back') return;
|
|
46
56
|
|
|
57
|
+
if (field === 'permissions') {
|
|
58
|
+
if (process.platform !== 'win32') {
|
|
59
|
+
console.log(chalk.yellow('\n You will be prompted for your sudo password once.\n'));
|
|
60
|
+
const result = await setupLinuxPermissions();
|
|
61
|
+
if (result.success) {
|
|
62
|
+
console.log(chalk.green('\n ✅ Permissions configured! No more password prompts.\n'));
|
|
63
|
+
} else {
|
|
64
|
+
console.log(chalk.red(`\n ✗ Failed: ${result.reason || 'unknown error'}\n`));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
47
70
|
if (field === 'dashboardPort') {
|
|
48
71
|
// T015: port validation with inline error + re-prompt
|
|
49
72
|
const { value } = await inquirer.prompt([{
|
|
@@ -27,7 +27,7 @@ import { getDashboardStatus, startDashboard, stopDashboard } from './dashboard.j
|
|
|
27
27
|
|
|
28
28
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
29
29
|
const require = createRequire(import.meta.url);
|
|
30
|
-
const { version: currentVersion } = require('
|
|
30
|
+
const { version: currentVersion } = require('../../../package.json');
|
|
31
31
|
|
|
32
32
|
// ─── Version helpers ──────────────────────────────────────────────────────────
|
|
33
33
|
|
package/{core → src/core}/db.js
RENAMED
|
@@ -4,7 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
5
|
|
|
6
6
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
-
const DATA_DIR = path.join(__dirname, '..', 'data');
|
|
7
|
+
const DATA_DIR = path.join(__dirname, '..', '..', 'data');
|
|
8
8
|
const DB_PATH = path.join(DATA_DIR, 'easy-devops.sqlite');
|
|
9
9
|
|
|
10
10
|
try {
|