underpost 2.8.82 → 2.8.85

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 (115) hide show
  1. package/.env.development +1 -0
  2. package/.env.production +1 -0
  3. package/.env.test +1 -0
  4. package/.github/workflows/{ghpkg.yml → ghpkg.ci.yml} +5 -5
  5. package/.github/workflows/{npmpkg.yml → npmpkg.ci.yml} +5 -5
  6. package/.github/workflows/{publish.yml → publish.ci.yml} +1 -1
  7. package/.github/workflows/{pwa-microservices-template.page.yml → pwa-microservices-template-page.cd.yml} +1 -1
  8. package/.github/workflows/{pwa-microservices-template.test.yml → pwa-microservices-template-test.ci.yml} +1 -1
  9. package/.vscode/extensions.json +1 -1
  10. package/.vscode/settings.json +0 -44
  11. package/README.md +62 -2
  12. package/bin/build.js +15 -5
  13. package/bin/deploy.js +42 -92
  14. package/bin/file.js +33 -9
  15. package/bin/vs.js +12 -4
  16. package/cli.md +90 -42
  17. package/conf.js +1 -1
  18. package/docker-compose.yml +1 -1
  19. package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
  20. package/manifests/deployment/tensorflow/tf-gpu-test.yaml +65 -0
  21. package/manifests/maas/device-scan.sh +3 -3
  22. package/manifests/maas/gpu-diag.sh +19 -0
  23. package/manifests/maas/maas-setup.sh +10 -10
  24. package/manifests/maas/snap-clean.sh +26 -0
  25. package/package.json +4 -6
  26. package/src/api/user/user.router.js +24 -1
  27. package/src/api/user/user.service.js +1 -4
  28. package/src/cli/baremetal.js +105 -73
  29. package/src/cli/cloud-init.js +21 -12
  30. package/src/cli/cluster.js +227 -133
  31. package/src/cli/deploy.js +34 -0
  32. package/src/cli/index.js +28 -1
  33. package/src/cli/monitor.js +8 -12
  34. package/src/cli/repository.js +7 -4
  35. package/src/cli/run.js +367 -0
  36. package/src/cli/ssh.js +32 -0
  37. package/src/cli/test.js +1 -1
  38. package/src/client/Default.index.js +7 -3
  39. package/src/client/components/core/Account.js +1 -1
  40. package/src/client/components/core/Chat.js +1 -1
  41. package/src/client/components/core/CommonJs.js +24 -22
  42. package/src/client/components/core/Content.js +1 -5
  43. package/src/client/components/core/Css.js +258 -18
  44. package/src/client/components/core/CssCore.js +8 -8
  45. package/src/client/components/core/Docs.js +14 -61
  46. package/src/client/components/core/DropDown.js +137 -82
  47. package/src/client/components/core/EventsUI.js +92 -5
  48. package/src/client/components/core/LoadingAnimation.js +8 -15
  49. package/src/client/components/core/Modal.js +597 -136
  50. package/src/client/components/core/NotificationManager.js +2 -2
  51. package/src/client/components/core/ObjectLayerEngine.js +638 -0
  52. package/src/client/components/core/Panel.js +158 -34
  53. package/src/client/components/core/PanelForm.js +12 -3
  54. package/src/client/components/core/Recover.js +1 -1
  55. package/src/client/components/core/Router.js +77 -17
  56. package/src/client/components/core/SocketIo.js +3 -3
  57. package/src/client/components/core/Translate.js +6 -2
  58. package/src/client/components/core/VanillaJs.js +0 -3
  59. package/src/client/components/core/Worker.js +3 -1
  60. package/src/client/components/default/CssDefault.js +17 -3
  61. package/src/client/components/default/MenuDefault.js +264 -45
  62. package/src/client/components/default/RoutesDefault.js +6 -12
  63. package/src/client/public/default/android-chrome-144x144.png +0 -0
  64. package/src/client/public/default/android-chrome-192x192.png +0 -0
  65. package/src/client/public/default/android-chrome-256x256.png +0 -0
  66. package/src/client/public/default/android-chrome-36x36.png +0 -0
  67. package/src/client/public/default/android-chrome-48x48.png +0 -0
  68. package/src/client/public/default/android-chrome-72x72.png +0 -0
  69. package/src/client/public/default/android-chrome-96x96.png +0 -0
  70. package/src/client/public/default/apple-touch-icon-114x114-precomposed.png +0 -0
  71. package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
  72. package/src/client/public/default/apple-touch-icon-120x120-precomposed.png +0 -0
  73. package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
  74. package/src/client/public/default/apple-touch-icon-144x144-precomposed.png +0 -0
  75. package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
  76. package/src/client/public/default/apple-touch-icon-152x152-precomposed.png +0 -0
  77. package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
  78. package/src/client/public/default/apple-touch-icon-180x180-precomposed.png +0 -0
  79. package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
  80. package/src/client/public/default/apple-touch-icon-57x57-precomposed.png +0 -0
  81. package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
  82. package/src/client/public/default/apple-touch-icon-60x60-precomposed.png +0 -0
  83. package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
  84. package/src/client/public/default/apple-touch-icon-72x72-precomposed.png +0 -0
  85. package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
  86. package/src/client/public/default/apple-touch-icon-76x76-precomposed.png +0 -0
  87. package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
  88. package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
  89. package/src/client/public/default/apple-touch-icon.png +0 -0
  90. package/src/client/public/default/assets/background/dark.jpg +0 -0
  91. package/src/client/public/default/assets/background/dark.svg +557 -0
  92. package/src/client/public/default/assets/logo/base-icon.png +0 -0
  93. package/src/client/public/default/assets/logo/underpost.gif +0 -0
  94. package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
  95. package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
  96. package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
  97. package/src/client/public/default/favicon-16x16.png +0 -0
  98. package/src/client/public/default/favicon-32x32.png +0 -0
  99. package/src/client/public/default/favicon.ico +0 -0
  100. package/src/client/public/default/mstile-144x144.png +0 -0
  101. package/src/client/public/default/mstile-150x150.png +0 -0
  102. package/src/client/public/default/mstile-310x150.png +0 -0
  103. package/src/client/public/default/mstile-310x310.png +0 -0
  104. package/src/client/public/default/mstile-70x70.png +0 -0
  105. package/src/client/public/default/safari-pinned-tab.svg +24 -0
  106. package/src/client/ssr/body/DefaultSplashScreen.js +2 -2
  107. package/src/index.js +34 -17
  108. package/src/monitor.js +24 -0
  109. package/src/runtime/lampp/Dockerfile +30 -39
  110. package/src/runtime/lampp/Lampp.js +11 -2
  111. package/src/server/client-build-docs.js +205 -0
  112. package/src/server/client-build.js +16 -166
  113. package/src/server/conf.js +18 -8
  114. package/src/server/process.js +16 -19
  115. package/src/server/valkey.js +102 -41
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.82
1
+ ## underpost ci/cd cli v2.8.85
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -28,6 +28,8 @@ Commands:
28
28
  fs [options] [path] Manages file storage, defaulting to file upload operations.
29
29
  test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
30
30
  monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
31
+ ssh [options] Import and start ssh server and client based on current default deployment ID.
32
+ run [options] <runner-id> [path] Runs a script from the specified path.
31
33
  lxd [options] Manages LXD containers and virtual machines.
32
34
  baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
33
35
  help [command] display help for command
@@ -117,7 +119,8 @@ options.
117
119
  Arguments:
118
120
  path The absolute or relative directory path of the repository.
119
121
  commit-type The type of commit to perform. Options: feat, fix, docs, style,
120
- refactor, perf, cd, test, build, ci, chore, revert, backup.
122
+ refactor, perf, ci, cd, infra, build, test, chore, revert,
123
+ backup.
121
124
  module-tag Optional: Sets a specific module tag for the commit.
122
125
  message Optional: Provides an additional custom message for the commit.
123
126
 
@@ -205,48 +208,53 @@ Options:
205
208
  Manages Kubernetes clusters, defaulting to Kind cluster initialization.
206
209
 
207
210
  Arguments:
208
- pod-name Optional: Filters information by a specific pod name.
211
+ pod-name Optional: Filters information by a specific pod name.
209
212
 
210
213
  Options:
211
- --reset Deletes all clusters and prunes all related data and
212
- caches.
213
- --mariadb Initializes the cluster with a MariaDB statefulset.
214
- --mysql Initializes the cluster with a MySQL statefulset.
215
- --mongodb Initializes the cluster with a MongoDB statefulset.
216
- --postgresql Initializes the cluster with a PostgreSQL statefulset.
217
- --mongodb4 Initializes the cluster with a MongoDB 4.4 service.
218
- --valkey Initializes the cluster with a Valkey service.
219
- --contour Initializes the cluster with Project Contour base
220
- HTTPProxy and Envoy.
221
- --cert-manager Initializes the cluster with a Let's Encrypt production
222
- ClusterIssuer.
223
- --dedicated-gpu Initializes the cluster with dedicated GPU base
224
- resources and environment settings.
225
- --info Retrieves information about all deployed Kubernetes
226
- objects.
227
- --full Initializes the cluster with all available statefulsets
228
- and services.
229
- --ns-use <ns-name> Switches the current Kubernetes context to the specified
230
- namespace.
231
- --kubeadm Initializes the cluster using kubeadm for control plane
232
- management.
233
- --dev Initializes a development-specific cluster
234
- configuration.
235
- --list-pods Displays detailed information about all pods.
236
- --info-capacity Displays the current total machine capacity information.
237
- --info-capacity-pod Displays the current machine capacity information per
238
- pod.
239
- --pull-image Sets an optional associated image to pull during
240
- initialization.
241
- --init-host Installs necessary Kubernetes node CLI tools (e.g.,
242
- kind, kubeadm, docker, podman, helm).
243
- --config Sets the base Kubernetes node configuration.
244
- --worker Sets the context for a worker node.
245
- --chown Sets the appropriate ownership for Kubernetes kubeconfig
246
- files.
247
- --k3s Initializes the cluster using K3s (Lightweight
248
- Kubernetes).
249
- -h, --help display help for command
214
+ --reset Deletes all clusters and prunes all related data and
215
+ caches.
216
+ --mariadb Initializes the cluster with a MariaDB statefulset.
217
+ --mysql Initializes the cluster with a MySQL statefulset.
218
+ --mongodb Initializes the cluster with a MongoDB statefulset.
219
+ --mongo-db-host <host> Set custom mongo db host
220
+ --postgresql Initializes the cluster with a PostgreSQL
221
+ statefulset.
222
+ --mongodb4 Initializes the cluster with a MongoDB 4.4 service.
223
+ --valkey Initializes the cluster with a Valkey service.
224
+ --contour Initializes the cluster with Project Contour base
225
+ HTTPProxy and Envoy.
226
+ --cert-manager Initializes the cluster with a Let's Encrypt
227
+ production ClusterIssuer.
228
+ --dedicated-gpu Initializes the cluster with dedicated GPU base
229
+ resources and environment settings.
230
+ --info Retrieves information about all deployed Kubernetes
231
+ objects.
232
+ --full Initializes the cluster with all available
233
+ statefulsets and services.
234
+ --ns-use <ns-name> Switches the current Kubernetes context to the
235
+ specified namespace.
236
+ --kubeadm Initializes the cluster using kubeadm for control
237
+ plane management.
238
+ --dev Initializes a development-specific cluster
239
+ configuration.
240
+ --list-pods Displays detailed information about all pods.
241
+ --info-capacity Displays the current total machine capacity
242
+ information.
243
+ --info-capacity-pod Displays the current machine capacity information per
244
+ pod.
245
+ --pull-image Sets an optional associated image to pull during
246
+ initialization.
247
+ --init-host Installs necessary Kubernetes node CLI tools (e.g.,
248
+ kind, kubeadm, docker, podman, helm).
249
+ --uninstall-host Uninstalls all host components installed by
250
+ init-host.
251
+ --config Sets the base Kubernetes node configuration.
252
+ --worker Sets the context for a worker node.
253
+ --chown Sets the appropriate ownership for Kubernetes
254
+ kubeconfig files.
255
+ --k3s Initializes the cluster using K3s (Lightweight
256
+ Kubernetes).
257
+ -h, --help display help for command
250
258
 
251
259
  ```
252
260
 
@@ -545,6 +553,46 @@ Options:
545
553
  ```
546
554
 
547
555
 
556
+ ### `ssh` :
557
+ ```
558
+ Usage: underpost ssh [options]
559
+
560
+ Import and start ssh server and client based on current default deployment ID.
561
+
562
+ Options:
563
+ --generate Generates new ssh credential and stores it in current private
564
+ keys file storage.
565
+ -h, --help display help for command
566
+
567
+ ```
568
+
569
+
570
+ ### `run` :
571
+ ```
572
+ Usage: underpost run [options] <runner-id> [path]
573
+
574
+ Runs a script from the specified path.
575
+
576
+ Arguments:
577
+ runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, dev-cluster, cyberia-ide, engine-ide, template-deploy, ssh-deploy, ide, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
578
+ path The absolute or relative directory path where the script is located.
579
+
580
+ Options:
581
+ --command <command-array> Array of commands to run.
582
+ --args <args-array> Array of arguments to pass to the command.
583
+ --dev Sets the development context environment for the script.
584
+ --pod-name <pod-name> Optional: Specifies the pod name for test execution.
585
+ --volume-host-path <volume-host-path> Optional: Specifies the volume host path for test execution.
586
+ --volume-mount-path <volume-mount-path> Optional: Specifies the volume mount path for test execution.
587
+ --volume-type <volume-type> Optional: Specifies the volume type for test execution.
588
+ --image-name <image-name> Optional: Specifies the image name for test execution.
589
+ --container-name <container-name> Optional: Specifies the container name for test execution.
590
+ --namespace <namespace> Optional: Specifies the namespace for test execution.
591
+ -h, --help display help for command
592
+
593
+ ```
594
+
595
+
548
596
  ### `lxd` :
549
597
  ```
550
598
  Usage: underpost lxd [options]
package/conf.js CHANGED
@@ -6,7 +6,7 @@ const DefaultConf = /**/ {
6
6
  client: {
7
7
  default: {
8
8
  metadata: {
9
- title: 'Demo App',
9
+ title: 'PWA Demo App',
10
10
  backgroundImage: 'assets/background/white0-min.jpg',
11
11
  description: 'Web application',
12
12
  keywords: ['web', 'app', 'spa', 'demo', 'github-pages'],
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.82'
61
+ engine.version: '2.8.85'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-template-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.82
20
+ image: localhost/rockylinux9-underpost:v2.8.85
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-template-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.82
103
+ image: localhost/rockylinux9-underpost:v2.8.85
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -0,0 +1,65 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: tf-gpu-test-script
6
+ namespace: default
7
+ data:
8
+ main_tf_gpu_test.py: |
9
+ import os
10
+ import tensorflow as tf
11
+
12
+ print("--- Starting GPU and Library Check ---")
13
+
14
+ gpus = tf.config.list_physical_devices("GPU")
15
+ if gpus:
16
+ try:
17
+ tf.config.set_visible_devices(gpus[0], "GPU")
18
+ logical_gpus = tf.config.list_logical_devices("GPU")
19
+ print(
20
+ f"TensorFlow detected {len(gpus)} Physical GPUs, {len(logical_gpus)} Logical GPUs. Using: {gpus[0].name}"
21
+ )
22
+ except RuntimeError as e:
23
+ print(f"RuntimeError during GPU configuration: {e}")
24
+ else:
25
+ print("TensorFlow did not detect any GPU devices. Running on CPU.")
26
+
27
+ print(f"XLA_FLAGS environment variable: {os.environ.get('XLA_FLAGS')}")
28
+ print(f"TF_XLA_FLAGS environment variable: {os.environ.get('TF_XLA_FLAGS')}")
29
+
30
+ print(f"TensorFlow version: {tf.__version__}")
31
+ print(f"Built with CUDA: {tf.test.is_built_with_cuda()}")
32
+ print(f"Is GPU available: {tf.config.list_physical_devices('GPU') != []}")
33
+
34
+ print("--- GPU and Library Check Complete ---")
35
+ ---
36
+ apiVersion: v1
37
+ kind: Pod
38
+ metadata:
39
+ name: tf-gpu-test-pod
40
+ namespace: default
41
+ spec:
42
+ restartPolicy: Never
43
+ runtimeClassName: nvidia
44
+ containers:
45
+ - name: tensorflow-gpu-tester
46
+ image: nvcr.io/nvidia/tensorflow:24.04-tf2-py3
47
+ imagePullPolicy: IfNotPresent
48
+ command: ['python']
49
+ args: ['/app/main_tf_gpu_test.py']
50
+ resources:
51
+ limits:
52
+ nvidia.com/gpu: '1'
53
+ env:
54
+ - name: NVIDIA_VISIBLE_DEVICES
55
+ value: all
56
+ volumeMounts:
57
+ - name: tf-script-volume
58
+ mountPath: /app
59
+ volumes:
60
+ - name: tf-script-volume
61
+ configMap:
62
+ name: tf-gpu-test-script
63
+ items:
64
+ - key: main_tf_gpu_test.py
65
+ path: main_tf_gpu_test.py
@@ -8,14 +8,14 @@ for iface_path in /sys/class/net/*; do
8
8
  operstate=$(< "$iface_path/operstate")
9
9
  mtu=$(< "$iface_path/mtu")
10
10
 
11
- # Driver: módulo kernel que maneja esta interfaz
11
+ # Driver
12
12
  if [ -L "$iface_path/device/driver" ]; then
13
13
  driver=$(basename "$(readlink -f "$iface_path/device/driver")")
14
14
  else
15
15
  driver="—"
16
16
  fi
17
17
 
18
- # Vendor:Device ID PCI
18
+ # Vendor device ID PCI
19
19
  pci_dev="$iface_path/device"
20
20
  if [ -f "$pci_dev/vendor" ] && [ -f "$pci_dev/device" ]; then
21
21
  vendor_id=$(< "$pci_dev/vendor")
@@ -28,7 +28,7 @@ for iface_path in /sys/class/net/*; do
28
28
  pci="—"
29
29
  fi
30
30
 
31
- # Link Speed: lectura directa de /sys/class/net/<iface>/speed
31
+ # Link Speed
32
32
  speed=$(cat "$iface_path/speed" 2>/dev/null || echo "—")
33
33
 
34
34
  echo "Interface: $name"
@@ -0,0 +1,19 @@
1
+ # GPUs and drivers in use
2
+ sudo lspci -nnk | egrep -i 'vga|3d' -A3
3
+
4
+ # modules loaded relevant
5
+ lsmod | egrep 'nvidia|nouveau|amdgpu' || true
6
+
7
+ # if exists nvidia tool
8
+ nvidia-smi 2>/dev/null || echo "nvidia-smi not found"
9
+
10
+ # kernel related errors
11
+ sudo dmesg | egrep -i 'nvidia|nouveau|amdgpu' --color=auto
12
+
13
+ # recent system errors / gdm / mutter / X
14
+ sudo journalctl -b -p err --no-pager | head -n 200
15
+ journalctl -b _COMM=gdm --no-pager | tail -n 200
16
+ journalctl -b _COMM=Xorg --no-pager | tail -n 200
17
+
18
+ # X log (if exists)
19
+ sudo grep -E "(EE|WW|NVIDIA|nouveau|amdgpu)" /var/log/Xorg.0.log || true
@@ -58,14 +58,14 @@ maas "$MAAS_ADMIN_USERNAME" maas set-config name=upstream_dns value=8.8.8.8
58
58
  # os="ubuntu" release="noble" arches="amd64" \
59
59
  # subarches="ga-24.04" labels="*"
60
60
 
61
- echo "Downloading Ubuntu Noble arm64/ga-24.04 image..."
62
- maas $MAAS_ADMIN_USERNAME boot-source-selections create 1 \
63
- os="ubuntu" release="noble" arches="arm64" \
64
- subarches="ga-24.04" labels="*"
61
+ # echo "Downloading Ubuntu Noble arm64/ga-24.04 image..."
62
+ # maas $MAAS_ADMIN_USERNAME boot-source-selections create 1 \
63
+ # os="ubuntu" release="noble" arches="arm64" \
64
+ # subarches="ga-24.04" labels="*"
65
65
 
66
66
  # Import the newly selected boot images
67
- echo "Importing boot images (this may take some time)..."
68
- maas "$MAAS_ADMIN_USERNAME" boot-resources import
67
+ # echo "Importing boot images (this may take some time)..."
68
+ # maas "$MAAS_ADMIN_USERNAME" boot-resources import
69
69
 
70
70
  # Disable the MAAS HTTP proxy
71
71
  echo "Disabling MAAS HTTP proxy..."
@@ -108,13 +108,13 @@ if [ -z "$FABRIC_ID" ]; then
108
108
  exit 1
109
109
  fi
110
110
 
111
- # Enable DHCP on the untagged VLAN (VLAN tag 0)
112
- echo "Enabling DHCP on VLAN 0 for fabric-1 (ID: $FABRIC_ID)..."
113
- maas "$MAAS_ADMIN_USERNAME" vlan update "$FABRIC_ID" 0 dhcp_on=true primary_rack="$RACK_CONTROLLER_ID"
114
-
115
111
  # Create a Dynamic IP Range for enlistment, commissioning, and deployment
116
112
  echo "Creating dynamic IP range from $START_IP to $END_IP..."
117
113
  maas "$MAAS_ADMIN_USERNAME" ipranges create type=dynamic start_ip="$START_IP" end_ip="$END_IP"
118
114
 
115
+ # Enable DHCP on the untagged VLAN (VLAN tag 0)
116
+ echo "Enabling DHCP on VLAN 0 for fabric-1 (ID: $FABRIC_ID)..."
117
+ maas "$MAAS_ADMIN_USERNAME" vlan update "$FABRIC_ID" 0 dhcp_on=true primary_rack="$RACK_CONTROLLER_ID"
118
+
119
119
  echo "Setting gateway IP for subnet $SUBNET_CIDR (ID: $SUBNET_ID) to $IP_ADDRESS..."
120
120
  maas "$MAAS_ADMIN_USERNAME" subnet update $SUBNET_ID gateway_ip=$IP_ADDRESS
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env bash
2
+ # cleanup-snap.sh
3
+ # Remove all disabled snap revisions to free up disk space.
4
+
5
+ set -euo pipefail
6
+
7
+ # Ensure we’re running as root
8
+ if [[ $EUID -ne 0 ]]; then
9
+ echo "Please run this script with sudo or as root."
10
+ exit 1
11
+ fi
12
+
13
+ echo "Gathering list of snaps with disabled revisions..."
14
+ snap list --all \
15
+ | awk '/disabled/ {print $1, $3}' \
16
+ | while read -r pkg rev; do
17
+ echo " -> Removing $pkg (revision $rev)..."
18
+ snap remove "$pkg" --revision="$rev"
19
+ done
20
+
21
+ echo "Cleanup complete."
22
+ echo
23
+ echo "Tip: Limit how many revisions Snap retains by setting:"
24
+ echo " sudo snap set system refresh.retain=2"
25
+ echo "Then apply with:"
26
+ echo " sudo snap refresh"
package/package.json CHANGED
@@ -2,16 +2,17 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.82",
5
+ "version": "2.8.85",
6
6
  "description": "pwa api rest template",
7
7
  "scripts": {
8
8
  "start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
9
+ "build": "node bin/deploy build-full-client",
9
10
  "test": "env-cmd -f .env.test c8 mocha",
10
11
  "pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine",
11
12
  "dev": "env-cmd -f .env.development node src/client.dev default",
12
13
  "dev-img": "env-cmd -f .env.development node src/server",
13
14
  "prod-img": "env-cmd -f .env.production node src/server",
14
- "monitor": "pm2 start bin/deploy.js --name monitor -- monitor",
15
+ "monitor": "pm2 start src/monitor.js --name monitor -- dd production",
15
16
  "dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
16
17
  "dev-client": "env-cmd -f .env.development node src/client.dev",
17
18
  "proxy": "node src/proxy proxy",
@@ -23,8 +24,7 @@
23
24
  "docker:start": "docker-compose up",
24
25
  "prettier": "prettier --write .",
25
26
  "fix": "npm audit fix --force && npm audit",
26
- "changelog": "auto-changelog",
27
- "build": "node bin/deploy build-full-client"
27
+ "changelog": "auto-changelog"
28
28
  },
29
29
  "bin": {
30
30
  "underpost": "bin/index.js"
@@ -99,14 +99,12 @@
99
99
  "peer": "^1.0.2",
100
100
  "peerjs": "^1.5.2",
101
101
  "pixi.js": "7.4.2",
102
- "plantuml": "^0.0.2",
103
102
  "prom-client": "^15.1.2",
104
103
  "public-ip": "^6.0.1",
105
104
  "read": "^2.1.0",
106
105
  "rrule": "^2.8.1",
107
106
  "sharp": "^0.32.5",
108
107
  "shelljs": "^0.8.5",
109
- "simple-icons": "^13.9.0",
110
108
  "sitemap": "^7.1.1",
111
109
  "socket.io": "^4.8.0",
112
110
  "sortablejs": "^1.15.0",
@@ -1,8 +1,9 @@
1
- import { authMiddleware } from '../../server/auth.js';
1
+ import { authMiddleware, hashPassword } from '../../server/auth.js';
2
2
  import fs from 'fs-extra';
3
3
  import { loggerFactory } from '../../server/logger.js';
4
4
  import { UserController } from './user.controller.js';
5
5
  import express from 'express';
6
+ import { DataBaseProvider } from '../../db/DataBaseProvider.js';
6
7
 
7
8
  const logger = loggerFactory(import.meta);
8
9
 
@@ -10,6 +11,28 @@ const UserRouter = (options) => {
10
11
  const router = express.Router();
11
12
 
12
13
  (async () => {
14
+ const models = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models;
15
+ if (models.User) {
16
+ try {
17
+ const adminUser = await models.User.findOne({ role: 'admin' });
18
+ if (!adminUser) {
19
+ const defaultPassword = process.env.DEFAULT_ADMIN_PASSWORD || 'changethis';
20
+ const hashedPassword = hashPassword(defaultPassword);
21
+
22
+ const result = await models.User.create({
23
+ username: 'admin',
24
+ email: process.env.DEFAULT_ADMIN_EMAIL || 'admin@' + options.host,
25
+ password: hashedPassword,
26
+ role: 'admin',
27
+ emailConfirmed: true,
28
+ publicKey: [],
29
+ });
30
+ logger.warn('Default admin user created. Please change the default password immediately!', result._doc);
31
+ }
32
+ } catch (error) {
33
+ logger.error('Error checking/creating admin user:', error);
34
+ }
35
+ }
13
36
  options.png = {
14
37
  buffer: {
15
38
  'invalid-token': fs.readFileSync(`./src/client/public/default/assets/mailer/api-user-invalid-token.png`),
@@ -444,7 +444,7 @@ const UserService = {
444
444
  _id: user._id,
445
445
  }).select(UserDto.select.get());
446
446
  } else throw new Error('invalid token');
447
- }
447
+ } else delete req.body.password;
448
448
 
449
449
  switch (req.params.id) {
450
450
  default: {
@@ -453,9 +453,6 @@ const UserService = {
453
453
  });
454
454
  switch (user.role) {
455
455
  case 'admin': {
456
- if (req.body.password !== undefined && req.body.password !== user.password)
457
- req.body.password = await hashPassword(req.body.password);
458
- else delete req.body.password;
459
456
  return await User.findByIdAndUpdate(req.params.id, req.body, {
460
457
  runValidators: true,
461
458
  });