easy-devops 1.2.1 → 1.3.1

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.
Files changed (126) hide show
  1. package/README.md +97 -6
  2. package/dist/ui/assets/index-CMRzkIKj.css +1 -0
  3. package/dist/ui/assets/index-DEouL3IK.js +452 -0
  4. package/dist/ui/assets/socket-DwLPrgsr.js +1 -0
  5. package/dist/ui/assets/socket-K5ttLD2q.js +65 -0
  6. package/dist/ui/brand/apple-touch-icon.png +0 -0
  7. package/dist/ui/brand/favicon-16.png +0 -0
  8. package/dist/ui/brand/favicon-32.png +0 -0
  9. package/dist/ui/brand/favicon-light-16.png +0 -0
  10. package/dist/ui/brand/favicon-light-32.png +0 -0
  11. package/dist/ui/brand/favicon.ico +0 -0
  12. package/dist/ui/brand/icon-192.png +0 -0
  13. package/dist/ui/brand/icon-48.png +0 -0
  14. package/dist/ui/brand/icon-512.png +0 -0
  15. package/dist/ui/brand/icon-64-light.png +0 -0
  16. package/dist/ui/brand/icon-64.png +0 -0
  17. package/dist/ui/brand/logo-dark.png +0 -0
  18. package/dist/ui/brand/logo-light.png +0 -0
  19. package/dist/ui/brand/mark-dark.png +0 -0
  20. package/dist/ui/brand/mark-light.png +0 -0
  21. package/dist/ui/index.html +71 -0
  22. package/install.ps1 +188 -1
  23. package/install.sh +254 -29
  24. package/package.json +15 -4
  25. package/src/cli/dash.js +110 -0
  26. package/src/cli/index.js +237 -106
  27. package/src/cli/managers/domain-manager.js +60 -40
  28. package/src/cli/managers/ssl-manager.js +47 -330
  29. package/src/cli/menu.js +156 -0
  30. package/src/cli/menus/cleanup.js +205 -0
  31. package/src/cli/menus/dashboard.js +92 -1
  32. package/src/cli/menus/runtime.js +236 -0
  33. package/src/cli/menus/service.js +764 -0
  34. package/src/cli/menus/settings.js +176 -8
  35. package/src/cli/menus/uninstall.js +167 -0
  36. package/src/cli/menus/update.js +222 -47
  37. package/src/core/acme-challenge.js +273 -0
  38. package/src/core/cert-operations.js +189 -0
  39. package/src/{dashboard/lib → core}/cert-reader.js +2 -2
  40. package/src/core/cert-renewal.js +494 -0
  41. package/src/core/cleanup.js +600 -0
  42. package/src/core/config.js +169 -2
  43. package/src/core/daemon/ipc.js +292 -0
  44. package/src/core/daemon/lock.js +294 -0
  45. package/src/core/daemon/run.js +241 -0
  46. package/src/core/daemon/stopRequest.js +162 -0
  47. package/src/core/db.js +37 -8
  48. package/src/core/deploy/apps.js +491 -0
  49. package/src/core/deploy/domainLink.js +200 -0
  50. package/src/core/deploy/engine.js +973 -0
  51. package/src/core/deploy/ezfile.js +361 -0
  52. package/src/core/deploy/github.js +239 -0
  53. package/src/core/deploy/githubApi.js +261 -0
  54. package/src/core/deploy/hookServer.js +325 -0
  55. package/src/core/deploy/hubCommands.js +267 -0
  56. package/src/core/deploy/launcher.js +57 -0
  57. package/src/core/deploy/status.js +91 -0
  58. package/src/core/deploy/store.js +398 -0
  59. package/src/core/domainNotifier.js +94 -28
  60. package/src/core/domains-db.js +234 -0
  61. package/src/core/events.js +94 -2
  62. package/src/core/hub/agent.js +842 -0
  63. package/src/core/hubLink.js +306 -0
  64. package/src/core/hubPermissions.js +430 -0
  65. package/src/core/installSource.js +162 -0
  66. package/src/core/jobs/bus.js +120 -0
  67. package/src/core/jobs/index.js +371 -0
  68. package/src/core/jobs/monitors.js +368 -0
  69. package/src/core/jobs/owner.js +217 -0
  70. package/src/core/jobs/revisionWatcher.js +106 -0
  71. package/src/core/nginx-apply.js +213 -0
  72. package/src/core/nginx-conf-generator.js +253 -17
  73. package/src/{dashboard/lib → core}/nginx-service.js +18 -9
  74. package/src/core/notifications/claim.js +214 -0
  75. package/src/core/notifications/dispatch.js +154 -0
  76. package/src/core/notifier.js +31 -1
  77. package/src/core/passwords.js +172 -0
  78. package/src/core/permissions.js +8 -4
  79. package/src/core/platform.js +709 -2
  80. package/src/core/probeCache.js +258 -0
  81. package/src/core/purge.js +372 -0
  82. package/src/core/runner.js +488 -0
  83. package/src/core/service/acl.js +226 -0
  84. package/src/core/service/dataDir.js +345 -0
  85. package/src/core/service/index.js +1128 -0
  86. package/src/core/service/legacy.js +218 -0
  87. package/src/core/service/runtime.js +446 -0
  88. package/src/core/service/runtimeUpdate.js +800 -0
  89. package/src/core/service/systemd.js +458 -0
  90. package/src/core/service/windowsPersonal.js +530 -0
  91. package/src/core/service/windowsService.js +576 -0
  92. package/src/core/service/winsw.js +260 -0
  93. package/src/core/setupCode.js +331 -0
  94. package/src/core/shell.js +70 -7
  95. package/src/core/ssl-issuer.js +627 -0
  96. package/src/core/updater.js +295 -0
  97. package/src/core/validators.js +99 -0
  98. package/src/dashboard/controllers/authController.js +302 -15
  99. package/src/dashboard/controllers/deploymentsController.js +479 -0
  100. package/src/dashboard/controllers/domainsController.js +80 -61
  101. package/src/dashboard/controllers/hubController.js +135 -0
  102. package/src/dashboard/controllers/nginxController.js +21 -3
  103. package/src/dashboard/controllers/processesController.js +368 -0
  104. package/src/dashboard/controllers/settingsController.js +180 -12
  105. package/src/dashboard/controllers/sslController.js +288 -10
  106. package/src/dashboard/lib/daemonBridge.js +163 -0
  107. package/src/dashboard/lib/localRequest.js +235 -0
  108. package/src/dashboard/lib/loginRateLimit.js +119 -0
  109. package/src/dashboard/lib/requireAuth.js +80 -0
  110. package/src/dashboard/public/js/app.js +489 -19
  111. package/src/dashboard/routes/auth.js +10 -10
  112. package/src/dashboard/routes/deployments.js +46 -0
  113. package/src/dashboard/routes/domains.js +9 -0
  114. package/src/dashboard/routes/hub.js +22 -0
  115. package/src/dashboard/routes/nginx.js +9 -0
  116. package/src/dashboard/routes/processes.js +29 -0
  117. package/src/dashboard/routes/settings.js +9 -0
  118. package/src/dashboard/routes/ssl.js +10 -0
  119. package/src/dashboard/server.js +288 -21
  120. package/src/dashboard/socketManager.js +171 -207
  121. package/src/dashboard/views/index.ejs +1 -0
  122. package/src/dashboard/views/partials/login.ejs +68 -7
  123. package/src/dashboard/views/partials/processes-panel.ejs +261 -0
  124. package/src/dashboard/views/partials/settings-panel.ejs +287 -0
  125. package/src/dashboard/views/partials/sidebar.ejs +2 -0
  126. package/src/dashboard/lib/domains-db.js +0 -51
package/install.sh CHANGED
@@ -8,6 +8,8 @@
8
8
  # --help, -h Print this help and exit 0
9
9
  # --version VERSION Skip picker; use the specified Node.js version
10
10
  # --keep-node Skip Node.js management; proceed to dependency install
11
+ # --service Install the background service without asking
12
+ # --no-service Skip the background service without asking
11
13
  #
12
14
  # Exit codes:
13
15
  # 0 Installation completed successfully
@@ -18,47 +20,146 @@ set -euo pipefail
18
20
 
19
21
  # ---------------------------------------------------------------------------
20
22
  # Resolve script and project directory
23
+ #
24
+ # BASH_SOURCE[0] is empty when the script arrives on stdin — `curl | bash`, or
25
+ # `bash -s`. In that case the directory this resolves to is just the user's
26
+ # current directory and has nothing to do with Easy DevOps, so it must not be
27
+ # used to decide anything. PIPED records that distinction once, here, rather
28
+ # than letting each later test guess.
21
29
  # ---------------------------------------------------------------------------
22
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
23
- EASYDEVOPS_DIR="${EASYDEVOPS_DIR:-$SCRIPT_DIR}"
30
+ _SELF="${BASH_SOURCE[0]:-}"
31
+ case "$_SELF" in
32
+ ''|/dev/stdin|/dev/fd/*|/proc/self/fd/*|bash|sh|-) PIPED=true ;;
33
+ *) PIPED=false ;;
34
+ esac
35
+
36
+ if [ "$PIPED" = "true" ]; then
37
+ # Deliberately not the current directory: see above.
38
+ SCRIPT_DIR=""
39
+ else
40
+ SCRIPT_DIR="$(cd "$(dirname "$_SELF")" && pwd)"
41
+ fi
42
+
43
+ EASYDEVOPS_DIR="${EASYDEVOPS_DIR:-${SCRIPT_DIR:-$PWD}}"
24
44
 
25
45
  # ---------------------------------------------------------------------------
26
- # Source lib modules (auto-download if running standalone)
46
+ # Lib modules
47
+ #
48
+ # The modules live at src/lib/installer in the repository and in the published
49
+ # npm package (package.json ships `src/`). They used to be looked for at
50
+ # lib/installer, which exists in neither — so a clone failed, and the fallback
51
+ # then `mkdir -p`'d an empty lib/installer into whatever directory the user
52
+ # happened to be in. Both halves of that are fixed here: every real layout is
53
+ # searched, and a download goes to a temporary directory that is cleaned up.
54
+ #
55
+ # Defined as functions and called AFTER the flags are parsed, so `--help` costs
56
+ # no network request and writes nothing.
27
57
  # ---------------------------------------------------------------------------
28
- LIB_DIR="$SCRIPT_DIR/lib/installer"
29
- _LIB_BASE="https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/lib/installer"
58
+ _LIB_BASE="https://raw.githubusercontent.com/omar00050/Easy-DevOps/main/src/lib/installer"
30
59
  _LIB_MODULES="progress.sh detect.sh node-versions.sh picker.sh nvm-bootstrap.sh"
60
+ LIB_DIR=""
61
+ _LIB_TMP=""
62
+
63
+ # Set EZ_INSTALL_NO_DOWNLOAD=1 to require the modules locally. The installer
64
+ # tests use it to prove the failure is a clear message rather than a stray
65
+ # directory.
66
+ _lib_download_allowed() {
67
+ [ "${EZ_INSTALL_NO_DOWNLOAD:-0}" != "1" ]
68
+ }
69
+
70
+ _lib_dir_complete() {
71
+ local dir="$1" _m
72
+ [ -n "$dir" ] || return 1
73
+ for _m in $_LIB_MODULES; do
74
+ [ -f "$dir/$_m" ] || return 1
75
+ done
76
+ return 0
77
+ }
78
+
79
+ # Every layout the modules can legitimately be in: a clone or the published
80
+ # package (src/lib/installer), an older checkout (lib/installer), and the
81
+ # parent of a copied script.
82
+ resolve_lib_dir() {
83
+ local candidate
84
+ for candidate in \
85
+ "${EASYDEVOPS_DIR:+$EASYDEVOPS_DIR/src/lib/installer}" \
86
+ "${SCRIPT_DIR:+$SCRIPT_DIR/src/lib/installer}" \
87
+ "${SCRIPT_DIR:+$SCRIPT_DIR/lib/installer}" \
88
+ "${SCRIPT_DIR:+$SCRIPT_DIR/../src/lib/installer}" \
89
+ "${EZ_INSTALL_LIB_DIR:-}"
90
+ do
91
+ if _lib_dir_complete "$candidate"; then
92
+ LIB_DIR="$(cd "$candidate" && pwd)"
93
+ return 0
94
+ fi
95
+ done
96
+ return 1
97
+ }
98
+
99
+ _cleanup_lib_tmp() {
100
+ [ -n "$_LIB_TMP" ] && [ -d "$_LIB_TMP" ] && rm -rf "$_LIB_TMP"
101
+ }
31
102
 
32
- if [ ! -f "$LIB_DIR/progress.sh" ]; then
33
- printf 'Lib modules not found locally — downloading from GitHub...\n'
34
- mkdir -p "$LIB_DIR"
35
- _dl_ok=true
103
+ download_lib_dir() {
104
+ local downloader=""
105
+ if command -v curl >/dev/null 2>&1; then downloader="curl"
106
+ elif command -v wget >/dev/null 2>&1; then downloader="wget"
107
+ else
108
+ printf 'Error: the installer modules are not present and neither curl nor wget is available.\n' >&2
109
+ printf 'Clone the repository and run it from there:\n' >&2
110
+ printf ' git clone https://github.com/omar00050/Easy-DevOps.git\n' >&2
111
+ printf ' bash Easy-DevOps/install.sh\n' >&2
112
+ return 1
113
+ fi
114
+
115
+ # A temporary directory, never the current one: this used to create
116
+ # ./lib/installer wherever it was run.
117
+ _LIB_TMP="$(mktemp -d 2>/dev/null || mktemp -d -t ezinstall)" || {
118
+ printf 'Error: could not create a temporary directory for the installer modules.\n' >&2
119
+ return 1
120
+ }
121
+ trap _cleanup_lib_tmp EXIT
122
+
123
+ printf 'Installer modules not found locally — downloading...\n'
124
+ local _module
36
125
  for _module in $_LIB_MODULES; do
37
- if command -v curl >/dev/null 2>&1; then
38
- curl -fsSL "$_LIB_BASE/$_module" -o "$LIB_DIR/$_module" 2>/dev/null || _dl_ok=false
39
- elif command -v wget >/dev/null 2>&1; then
40
- wget -q "$_LIB_BASE/$_module" -O "$LIB_DIR/$_module" 2>/dev/null || _dl_ok=false
126
+ if [ "$downloader" = "curl" ]; then
127
+ curl -fsSL "$_LIB_BASE/$_module" -o "$_LIB_TMP/$_module" 2>/dev/null || true
41
128
  else
42
- printf 'Error: curl or wget is required to download installer modules.\n' >&2
43
- exit 1
129
+ wget -q "$_LIB_BASE/$_module" -O "$_LIB_TMP/$_module" 2>/dev/null || true
44
130
  fi
45
131
  done
46
- if [ "$_dl_ok" = "false" ]; then
47
- printf 'Error: Failed to download one or more installer modules from GitHub.\n' >&2
48
- printf 'Check your internet connection and try again.\n' >&2
49
- exit 1
132
+
133
+ if ! _lib_dir_complete "$_LIB_TMP"; then
134
+ printf 'Error: could not download the installer modules from GitHub.\n' >&2
135
+ printf ' %s\n' "$_LIB_BASE" >&2
136
+ printf 'Check your internet connection, or clone the repository and run install.sh from it.\n' >&2
137
+ return 1
50
138
  fi
139
+
140
+ LIB_DIR="$_LIB_TMP"
51
141
  printf 'Modules downloaded.\n\n'
52
- fi
142
+ return 0
143
+ }
53
144
 
54
- for _module in $_LIB_MODULES; do
55
- if [ ! -f "$LIB_DIR/$_module" ]; then
56
- printf 'Error: Required module not found: %s/%s\n' "$LIB_DIR" "$_module" >&2
57
- exit 1
145
+ source_lib_modules() {
146
+ if ! resolve_lib_dir; then
147
+ if ! _lib_download_allowed; then
148
+ printf 'Error: the installer modules were not found and downloading is disabled.\n' >&2
149
+ printf 'Expected them at:\n' >&2
150
+ printf ' %s/src/lib/installer\n' "${EASYDEVOPS_DIR:-$PWD}" >&2
151
+ printf 'Clone the repository and run install.sh from it, or allow the download.\n' >&2
152
+ exit 1
153
+ fi
154
+ download_lib_dir || exit 1
58
155
  fi
59
- # shellcheck source=/dev/null
60
- . "$LIB_DIR/$_module"
61
- done
156
+
157
+ local _module
158
+ for _module in $_LIB_MODULES; do
159
+ # shellcheck source=/dev/null
160
+ . "$LIB_DIR/$_module"
161
+ done
162
+ }
62
163
 
63
164
  # ---------------------------------------------------------------------------
64
165
  # Result tracking (mirrors install.ps1 summary table)
@@ -121,6 +222,8 @@ Options:
121
222
  version directly (e.g., --version 20.11.1)
122
223
  --keep-node Skip Node.js management entirely; proceed straight to
123
224
  dependency installation with whatever Node.js is active
225
+ --service Install the background service without asking
226
+ --no-service Do not install the background service, and do not ask
124
227
 
125
228
  Exit codes:
126
229
  0 Installation completed successfully
@@ -131,6 +234,8 @@ Examples:
131
234
  bash install.sh # Interactive install
132
235
  bash install.sh --version 20 # Install Node.js 20.x (latest patch)
133
236
  bash install.sh --keep-node # Skip Node.js management
237
+ bash install.sh --service # Unattended, with the background service
238
+ bash install.sh --no-service # Unattended, without it
134
239
  EOF
135
240
  }
136
241
 
@@ -139,6 +244,8 @@ EOF
139
244
  # ---------------------------------------------------------------------------
140
245
  FORCED_VERSION=""
141
246
  KEEP_NODE=false
247
+ # ask | yes | no — whether to install the background service at the end.
248
+ SERVICE_CHOICE="ask"
142
249
 
143
250
  while [ "$#" -gt 0 ]; do
144
251
  case "$1" in
@@ -162,6 +269,14 @@ while [ "$#" -gt 0 ]; do
162
269
  KEEP_NODE=true
163
270
  shift
164
271
  ;;
272
+ --service)
273
+ SERVICE_CHOICE="yes"
274
+ shift
275
+ ;;
276
+ --no-service)
277
+ SERVICE_CHOICE="no"
278
+ shift
279
+ ;;
165
280
  *)
166
281
  printf 'Unknown option: %s\n' "$1" >&2
167
282
  printf 'Run "bash install.sh --help" for usage.\n' >&2
@@ -170,22 +285,29 @@ while [ "$#" -gt 0 ]; do
170
285
  esac
171
286
  done
172
287
 
288
+ # Only now: --help above costs no network request and writes nothing.
289
+ source_lib_modules
290
+
173
291
  # ---------------------------------------------------------------------------
174
292
  # Install mode detection (mirrors install.ps1 3-mode logic)
175
293
  #
176
- # source : package.json with name=easy-devops found in script dir
294
+ # source : package.json with name=easy-devops found beside this script
177
295
  # -> npm install + npm link
178
296
  # update : easy-devops already on PATH
179
297
  # -> skip install steps
180
298
  # npm : standalone download, not in project dir
181
299
  # -> npm install -g easy-devops
300
+ #
301
+ # Piped execution is never source mode: with `curl | bash` there is no script
302
+ # directory, and the current directory's package.json belongs to whatever the
303
+ # user happened to be standing in.
182
304
  # ---------------------------------------------------------------------------
183
305
  SOURCE_MODE=false
184
306
  ALREADY_INSTALLED=false
185
307
  EXISTING_CMD=""
186
308
 
187
309
  # Source mode: script is running from the project directory
188
- if [ -f "$SCRIPT_DIR/package.json" ]; then
310
+ if [ "$PIPED" = "false" ] && [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/package.json" ]; then
189
311
  if command -v node >/dev/null 2>&1; then
190
312
  _pkg_name="$(node -e "try{process.stdout.write(require('$SCRIPT_DIR/package.json').name)}catch(e){}" 2>/dev/null || true)"
191
313
  else
@@ -518,4 +640,107 @@ if [ "$NODE_ACTION" != "keep" ]; then
518
640
  fi
519
641
  fi
520
642
 
643
+ # ---------------------------------------------------------------------------
644
+ # Offer to install the background service
645
+ #
646
+ # Asked LAST, after Node and the package are in place, because `ezz` has to be
647
+ # runnable for the answer to mean anything.
648
+ #
649
+ # Reading from /dev/tty rather than stdin is what makes this work under
650
+ # curl -fsSL .../install.sh | bash
651
+ # where stdin is the pipe carrying the script itself. A plain `read` there
652
+ # consumes script text, or sees EOF and silently takes the default — and this
653
+ # is the one question whose default decides whether the user's server is
654
+ # monitored at all. If there is no terminal (a CI run, a Dockerfile), the
655
+ # prompt is skipped and the command is printed instead.
656
+ # ---------------------------------------------------------------------------
657
+ maybe_install_service() {
658
+ # An explicit flag means do not ask.
659
+ if [ "$SERVICE_CHOICE" = "no" ]; then
660
+ printf ' Skipping the background service (--no-service).\n'
661
+ printf ' Install it later with: ezz service install\n\n'
662
+ return 0
663
+ fi
664
+
665
+ # Open the terminal on fd 3 ONCE, and let the open itself decide whether
666
+ # there is one. A "[ -r /dev/tty ]" test is not enough: it can pass while the
667
+ # open then fails with "No such device or address" on a process that has no
668
+ # controlling terminal -- measured, not assumed. That leaked an error to the
669
+ # user and then fell through to the default, and the default here is yes.
670
+ # Guessing yes on a question that runs sudo is the wrong direction.
671
+ # The braces matter: "exec 3</dev/tty 2>/dev/null" still lets the SHELL print
672
+ # its own "No such device or address" before the redirection takes effect.
673
+ # Grouping puts the shell's own diagnostic inside the redirect too.
674
+ _has_tty=false
675
+ if { exec 3</dev/tty; } 2>/dev/null; then
676
+ _has_tty=true
677
+ fi
678
+
679
+ if [ "$SERVICE_CHOICE" != "yes" ]; then
680
+ if [ "$_has_tty" != "true" ]; then
681
+ # Unattended: never guess on a question that needs sudo.
682
+ printf ' No terminal available, so the background service was not installed.\n'
683
+ printf ' Install it with: ezz service install\n'
684
+ printf ' Or non-interactively: bash install.sh --service\n\n'
685
+ return 0
686
+ fi
687
+
688
+ printf '\n'
689
+ printf ' Easy DevOps can run a background service that keeps monitoring,\n'
690
+ printf ' notifications and the Hub agent alive even with no dashboard open.\n'
691
+ printf ' It installs a systemd unit running as your user. sudo will ask for\n'
692
+ printf ' your password itself; nothing here stores or sees it.\n'
693
+ printf '\n'
694
+ printf ' Install the background service now? (recommended for servers) [Y/n] '
695
+
696
+ _answer=""
697
+ IFS= read -r _answer <&3 || _answer=""
698
+
699
+ case "$_answer" in
700
+ [Nn]|[Nn][Oo])
701
+ printf '\n Skipped. Install it later with: ezz service install\n\n'
702
+ exec 3<&-
703
+ return 0
704
+ ;;
705
+ esac
706
+ fi
707
+
708
+ printf '\n Installing the background service...\n\n'
709
+
710
+ # Resolve the CLI the same way a user would, then fall back to the checkout.
711
+ _ez=""
712
+ if command -v ezz >/dev/null 2>&1; then
713
+ _ez="ezz"
714
+ elif command -v easy-devops >/dev/null 2>&1; then
715
+ _ez="easy-devops"
716
+ elif [ -f "$EASYDEVOPS_DIR/src/cli/index.js" ]; then
717
+ _ez="node \"$EASYDEVOPS_DIR/src/cli/index.js\""
718
+ else
719
+ printf ' Could not find the ezz command, so the service was not installed.\n'
720
+ printf ' Open a new terminal and run: ezz service install\n\n'
721
+ if [ "$_has_tty" = "true" ]; then exec 3<&-; fi
722
+ return 0
723
+ fi
724
+
725
+ # stdin comes from the terminal for the same reason as the prompt above:
726
+ # "ezz service install" runs sudo, and sudo must be able to ask.
727
+ _installed=false
728
+ if [ "$_has_tty" = "true" ]; then
729
+ if eval "$_ez service install" <&3; then _installed=true; fi
730
+ exec 3<&-
731
+ elif eval "$_ez service install"; then
732
+ _installed=true
733
+ fi
734
+
735
+ if [ "$_installed" = "true" ]; then
736
+ return 0
737
+ fi
738
+
739
+ printf '\n The service was not installed. Nothing else was changed.\n'
740
+ printf ' You can retry with: ezz service install\n\n'
741
+ return 0
742
+ }
743
+
744
+ maybe_install_service
745
+
521
746
  exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easy-devops",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
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",
@@ -18,7 +18,8 @@
18
18
  ],
19
19
  "author": {
20
20
  "name": "Omar Farghaly",
21
- "url": "https://github.com/omar00050"
21
+ "url": "https://github.com/omar00050",
22
+ "email": "omar@farghlay.dev"
22
23
  },
23
24
  "license": "MIT",
24
25
  "repository": {
@@ -37,6 +38,8 @@
37
38
  },
38
39
  "files": [
39
40
  "src/",
41
+ "!src/dashboard/ui/",
42
+ "dist/ui/",
40
43
  "data/.gitkeep",
41
44
  "install.bat",
42
45
  "install.ps1",
@@ -44,7 +47,12 @@
44
47
  ],
45
48
  "scripts": {
46
49
  "start": "node src/cli/index.js",
47
- "test": "echo \" no test specified\"",
50
+ "dev": "node src/cli/index.js --dev",
51
+ "build:ui": "npm --prefix src/dashboard/ui install && npm --prefix src/dashboard/ui run build",
52
+ "prepublishOnly": "npm run build:ui && npm test",
53
+ "testold": "node e2e/run.mjs",
54
+ "test:e2e": "node e2e/run.mjs",
55
+ "test:e2e:check": "node e2e/run.mjs --check",
48
56
  "dashboard": "node src/dashboard/server.js",
49
57
  "system-info": "node src/cli/index.js system-info"
50
58
  },
@@ -53,6 +61,7 @@
53
61
  },
54
62
  "dependencies": {
55
63
  "acme-client": "^5.4.0",
64
+ "blakejs": "^1.2.1",
56
65
  "chalk": "^5.3.0",
57
66
  "cli-table3": "^0.6.5",
58
67
  "discord.js": "^14.26.2",
@@ -64,6 +73,8 @@
64
73
  "inquirer": "^9.2.12",
65
74
  "ora": "^7.0.1",
66
75
  "session-file-store": "^1.5.0",
67
- "socket.io": "^4.8.3"
76
+ "socket.io": "^4.8.3",
77
+ "socket.io-client": "^4.8.3",
78
+ "tweetnacl": "^1.0.3"
68
79
  }
69
80
  }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * cli/dash.js
3
+ *
4
+ * Runs the dashboard in the foreground (`ezz --dash`), skipping the menu.
5
+ *
6
+ * Importing dashboard/server.js starts the HTTP server as a side effect; this
7
+ * module waits for it to bind, prints the URL, and installs signal handlers
8
+ * that shut everything down cleanly so the terminal is returned on Ctrl+C.
9
+ */
10
+
11
+ import chalk from 'chalk';
12
+ import { getDataDir, isDevDataDir } from '../core/platform.js';
13
+ import { inspect } from '../core/daemon/lock.js';
14
+
15
+ /** How long a graceful shutdown may take before the process is forced out. */
16
+ const FORCE_EXIT_MS = 5000;
17
+
18
+ export async function runDashboard() {
19
+ const { whenListening, shutdown } = await import('../dashboard/server.js');
20
+
21
+ let port;
22
+ try {
23
+ port = await whenListening;
24
+ } catch (err) {
25
+ const hint = err?.code === 'EADDRINUSE'
26
+ ? '\n Another process is already using that port. Stop it, or change the port in Settings.'
27
+ : '';
28
+ process.stderr.write(chalk.red(`\n Failed to start the dashboard: ${err.message}${hint}\n\n`));
29
+ process.exit(1);
30
+ }
31
+
32
+ const url = `http://localhost:${port}`;
33
+
34
+ console.log();
35
+ if (isDevDataDir()) {
36
+ console.log(' ' + chalk.bgYellow.black(' DEV MODE ') + ' ' + chalk.yellow(`data: ${getDataDir()}`));
37
+ }
38
+ console.log(' ' + chalk.hex('#d64a29').bold('Easy DevOps Dashboard'));
39
+ console.log(' ' + chalk.white(url));
40
+ console.log(' ' + chalk.gray('Press Ctrl+C to stop'));
41
+ console.log();
42
+
43
+ printBackgroundServiceNotice();
44
+
45
+ let stopping = false;
46
+
47
+ /**
48
+ * Shuts down and exits. shutdown() is itself idempotent, so a second Ctrl+C
49
+ * cannot double-close; this guard only avoids printing the notice twice and
50
+ * re-arming the force-exit timer.
51
+ */
52
+ const stop = async (signal) => {
53
+ if (stopping) {
54
+ console.log(' ' + chalk.gray('Still shutting down…'));
55
+ return;
56
+ }
57
+ stopping = true;
58
+
59
+ console.log();
60
+ console.log(' ' + chalk.gray(`Received ${signal}, shutting down…`));
61
+
62
+ // Safety net: never leave the user stuck if a socket refuses to close.
63
+ const force = setTimeout(() => {
64
+ console.log(' ' + chalk.yellow('Shutdown timed out — exiting anyway.'));
65
+ process.exit(0);
66
+ }, FORCE_EXIT_MS);
67
+ force.unref();
68
+
69
+ try {
70
+ await shutdown();
71
+ console.log(' ' + chalk.green('Dashboard stopped.'));
72
+ console.log();
73
+ process.exit(0);
74
+ } catch (err) {
75
+ process.stderr.write(chalk.red(` Shutdown error: ${err.message}\n`));
76
+ process.exit(1);
77
+ }
78
+ };
79
+
80
+ process.on('SIGINT', () => { stop('SIGINT'); });
81
+ process.on('SIGTERM', () => { stop('SIGTERM'); });
82
+ }
83
+
84
+ /**
85
+ * Says whether monitoring survives closing this terminal.
86
+ *
87
+ * This is the single most confusing thing about the old design and the reason
88
+ * the daemon exists: notifications, domain health and the Hub agent only ran
89
+ * while a dashboard was open, and nothing said so. A user who closed the
90
+ * window believed they were still being watched.
91
+ *
92
+ * So the dashboard now states which of the two situations it is in — and when
93
+ * it is the one doing the work, it says what to install to make that
94
+ * permanent, rather than merely warning.
95
+ */
96
+ function printBackgroundServiceNotice() {
97
+ const state = inspect();
98
+
99
+ if (state.running) {
100
+ console.log(' ' + chalk.green('● Background service is running.'));
101
+ console.log(' ' + chalk.gray(` This dashboard is the interface only (service pid ${state.lock?.pid}).`));
102
+ console.log();
103
+ return;
104
+ }
105
+
106
+ console.log(' ' + chalk.yellow('▲ No background service is running.'));
107
+ console.log(' ' + chalk.gray(' Monitoring and notifications run in THIS window and stop when you close it.'));
108
+ console.log(' ' + chalk.white(' ezz service install') + chalk.gray(' keep them running in the background'));
109
+ console.log();
110
+ }