@underpostnet/underpost 2.99.5 → 2.99.7

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 (37) hide show
  1. package/.github/workflows/ghpkg.ci.yml +10 -25
  2. package/.github/workflows/npmpkg.ci.yml +13 -2
  3. package/CHANGELOG.md +496 -0
  4. package/README.md +4 -4
  5. package/baremetal/commission-workflows.json +43 -6
  6. package/bin/deploy.js +13 -0
  7. package/cli.md +84 -42
  8. package/examples/static-page/README.md +80 -13
  9. package/jsdoc.json +26 -5
  10. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +47 -0
  11. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +47 -0
  12. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  13. package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
  14. package/package.json +2 -4
  15. package/scripts/maas-setup.sh +13 -9
  16. package/scripts/rocky-kickstart.sh +294 -0
  17. package/src/cli/baremetal.js +237 -555
  18. package/src/cli/cloud-init.js +27 -45
  19. package/src/cli/index.js +52 -6
  20. package/src/cli/kickstart.js +149 -0
  21. package/src/cli/repository.js +166 -13
  22. package/src/cli/run.js +26 -19
  23. package/src/cli/ssh.js +1 -1
  24. package/src/cli/static.js +27 -1
  25. package/src/cli/system.js +332 -0
  26. package/src/client/components/core/Docs.js +22 -3
  27. package/src/db/DataBaseProvider.js +3 -3
  28. package/src/db/mariadb/MariaDB.js +3 -3
  29. package/src/db/mongo/MongooseDB.js +3 -3
  30. package/src/index.js +28 -5
  31. package/src/mailer/EmailRender.js +3 -3
  32. package/src/mailer/MailerProvider.js +4 -4
  33. package/src/server/backup.js +23 -5
  34. package/src/server/client-build-docs.js +29 -3
  35. package/src/server/conf.js +6 -27
  36. package/src/server/cron.js +354 -135
  37. package/src/server/dns.js +2 -0
package/src/cli/run.js CHANGED
@@ -68,7 +68,8 @@ const logger = loggerFactory(import.meta);
68
68
  * @property {boolean} etcHosts - Whether to modify /etc/hosts.
69
69
  * @property {string} confServerPath - The configuration server path.
70
70
  * @property {string} underpostRoot - The root path of the Underpost installation.
71
- * @property {string} cronJobs - The cron jobs to run.
71
+ * @property {string} cmdCronJobs - Pre-script commands to run before cron job execution.
72
+ * @property {string} deployIdCronJobs - The deployment ID for cron jobs.
72
73
  * @property {string} timezone - The timezone to set.
73
74
  * @property {boolean} kubeadm - Whether to run in kubeadm mode.
74
75
  * @property {boolean} kind - Whether to run in kind mode.
@@ -84,6 +85,8 @@ const logger = loggerFactory(import.meta);
84
85
  * @property {string} monitorStatusKindType - The monitor status kind type option.
85
86
  * @property {string} monitorStatusDeltaMs - The monitor status delta in milliseconds.
86
87
  * @property {string} monitorStatusMaxAttempts - The maximum number of attempts for monitor status.
88
+ * @property {boolean} dryRun - Whether to perform a dry run.
89
+ * @property {boolean} createJobNow - Whether to create the job immediately.
87
90
  * @property {boolean} logs - Whether to enable logs.
88
91
  * @memberof UnderpostRun
89
92
  */
@@ -127,7 +130,8 @@ const DEFAULT_OPTION = {
127
130
  etcHosts: false,
128
131
  confServerPath: '',
129
132
  underpostRoot: '',
130
- cronJobs: '',
133
+ cmdCronJobs: '',
134
+ deployIdCronJobs: '',
131
135
  timezone: '',
132
136
  kubeadm: false,
133
137
  kind: false,
@@ -144,6 +148,8 @@ const DEFAULT_OPTION = {
144
148
  monitorStatusDeltaMs: '',
145
149
  monitorStatusMaxAttempts: '',
146
150
  logs: false,
151
+ dryRun: false,
152
+ createJobNow: false,
147
153
  };
148
154
 
149
155
  /**
@@ -339,6 +345,7 @@ class UnderpostRun {
339
345
  */
340
346
  'template-deploy': (path = '', options = DEFAULT_OPTION) => {
341
347
  const baseCommand = options.dev ? 'node bin' : 'underpost';
348
+ const message = shellExec(`node bin cmt --changelog --changelog-no-hash`, { silent: true, stdout: true }).trim();
342
349
  shellExec(`${baseCommand} run clean`);
343
350
  shellExec(
344
351
  `${baseCommand} push ./engine-private ${options.force ? '-f ' : ''}${
@@ -347,9 +354,23 @@ class UnderpostRun {
347
354
  );
348
355
  shellCd('/home/dd/engine');
349
356
  shellExec(`git reset`);
357
+ function replaceNthNewline(str, n, replacement = ' ') {
358
+ let count = 0;
359
+ return str.replace(/\r\n?|\n/g, (match) => {
360
+ count++;
361
+ return count === n ? replacement : match;
362
+ });
363
+ }
350
364
  shellExec(
351
365
  `${baseCommand} cmt . --empty ci package-pwa-microservices-template${
352
366
  path.startsWith('sync') ? `-${path}` : ''
367
+ }${
368
+ message
369
+ ? ` "${replaceNthNewline(
370
+ message.replaceAll('"', '').replaceAll('`', '').replaceAll('#', '').replaceAll('- ', ''),
371
+ 2,
372
+ )}"`
373
+ : ''
353
374
  }`,
354
375
  );
355
376
  shellExec(`${baseCommand} push . ${options.force ? '-f ' : ''}${process.env.GITHUB_USERNAME}/engine`);
@@ -502,7 +523,7 @@ class UnderpostRun {
502
523
  if (!validVersion) throw new Error('Version mismatch');
503
524
  }
504
525
  if (options.timezone !== 'none') shellExec(`${baseCommand} run${baseClusterCommand} tz`);
505
- if (options.cronJobs !== 'none') shellExec(`${baseCommand} run${baseClusterCommand} cron`);
526
+ if (options.deployIdCronJobs !== 'none') shellExec(`node bin cron --dev --setup-start --apply`);
506
527
  }
507
528
 
508
529
  const currentTraffic = isDeployRunnerContext(path, options)
@@ -708,20 +729,6 @@ class UnderpostRun {
708
729
  shellExec(`sudo timedatectl set-timezone ${tz}`);
709
730
  },
710
731
 
711
- /**
712
- * @method cron
713
- * @description Sets up and starts the `dd-cron` environment by writing environment variables, starting the cron service, and cleaning up.
714
- * @param {string} path - The input value, identifier, or path for the operation.
715
- * @param {Object} options - The default underpost runner options for customizing workflow
716
- * @memberof UnderpostRun
717
- */
718
- cron: (path, options = DEFAULT_OPTION) => {
719
- const env = options.dev ? 'development' : 'production';
720
- shellExec(`node bin env ${path ? path : 'dd-cron'} ${env}`);
721
- shellExec(`npm start`);
722
- shellExec(`node bin env clean`);
723
- },
724
-
725
732
  /**
726
733
  * @method get-proxy
727
734
  * @description Retrieves and logs the HTTPProxy resources in the specified namespace using `kubectl get HTTPProxy`.
@@ -991,7 +998,7 @@ EOF
991
998
  args: [daemonProcess(path ? path : `cd /home/dd/engine && npm install && npm run test`)],
992
999
  };
993
1000
 
994
- await Underpost.run.RUNNERS['deploy-job'](path, payload);
1001
+ await Underpost.run.CALL('deploy-job', path, payload);
995
1002
  },
996
1003
 
997
1004
  /**
@@ -1550,7 +1557,7 @@ EOF
1550
1557
  `${baseCommand} secret underpost --create-from-file /etc/config/.env.${env}`,
1551
1558
  `${baseCommand} start --build --run ${deployId} ${env} --underpost-quickly-install`,
1552
1559
  ];
1553
- shellExec(`node bin run sync${baseClusterCommand} --cron-jobs none dd-test --cmd "${cmd}"`);
1560
+ shellExec(`node bin run sync${baseClusterCommand} --deploy-id-cron-jobs none dd-test --cmd "${cmd}"`);
1554
1561
  },
1555
1562
 
1556
1563
  /**
package/src/cli/ssh.js CHANGED
@@ -536,7 +536,7 @@ SSH_KEY=$(node bin config get --plain DEFAULT_SSH_KEY_PATH)
536
536
 
537
537
  chmod 600 "$SSH_KEY"
538
538
 
539
- ssh -i "$SSH_KEY" -o BatchMode=yes "$REMOTE_USER@$REMOTE_HOST" -p $REMOTE_PORT sh <<EOF
539
+ ssh -i "$SSH_KEY" -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "$REMOTE_USER@$REMOTE_HOST" -p $REMOTE_PORT sh <<EOF
540
540
  ${cd ? `cd ${cd}` : ''}
541
541
  ${useSudo ? `sudo -n -- /bin/bash -lc "${remoteCommand}"` : remoteCommand}
542
542
  EOF
package/src/cli/static.js CHANGED
@@ -6,11 +6,12 @@
6
6
 
7
7
  import fs from 'fs-extra';
8
8
  import path from 'path';
9
+ import express from 'express';
9
10
  import { ssrFactory } from '../server/ssr.js';
10
11
  import { shellExec } from '../server/process.js';
11
12
  import Underpost from '../index.js';
12
13
  import { JSONweb } from '../server/client-formatted.js';
13
- import { loggerFactory } from '../server/logger.js';
14
+ import { loggerFactory, loggerMiddleware } from '../server/logger.js';
14
15
 
15
16
  const logger = loggerFactory(import.meta);
16
17
 
@@ -592,6 +593,31 @@ class UnderpostStatic {
592
593
  throw error;
593
594
  }
594
595
  }
596
+
597
+ // Start standalone static file server if --run-sv is specified
598
+ if (options.runSv !== undefined) {
599
+ const port = typeof options.runSv === 'string' ? parseInt(options.runSv, 10) : 5000;
600
+ const servePath =
601
+ options.outputPath && options.outputPath !== '.'
602
+ ? path.dirname(path.resolve(options.outputPath))
603
+ : path.resolve('.');
604
+
605
+ if (!fs.existsSync(servePath)) {
606
+ logger.error(`Serve path does not exist: ${servePath}`);
607
+ return;
608
+ }
609
+
610
+ const app = express();
611
+
612
+ app.use(loggerMiddleware(import.meta, 'debug', () => false));
613
+
614
+ app.use('/', express.static(servePath));
615
+
616
+ app.listen(port, () => {
617
+ logger.info(`Static file server running at http://localhost:${port}`);
618
+ logger.info(`Serving files from: ${servePath}`);
619
+ });
620
+ }
595
621
  },
596
622
 
597
623
  /**
@@ -0,0 +1,332 @@
1
+ /**
2
+ * System provisioning module for Underpost CLI.
3
+ * This module provides a factory for generating shell commands to provision systems based on their OS type.
4
+ * It includes methods for basic system setup, user creation, timezone configuration, and keyboard layout settings.
5
+ * The provisioning steps are tailored for both Ubuntu and Rocky Linux distributions, ensuring compatibility and ease of use.
6
+ * @module src/cli/system.js
7
+ * @namespace UnderpostSystemProvisionig
8
+ */
9
+
10
+ import fs from 'fs-extra';
11
+
12
+ /**
13
+ * @class UnderpostSystemProvisionig
14
+ * @description A class that encapsulates the system provisioning logic for Underpost CLI. It provides a structured way to generate shell commands for provisioning systems based on their OS type, including Ubuntu and Rocky Linux. The class contains a static API object with a factory for different provisioning steps, making it easy to extend and maintain.
15
+ * @memberof UnderpostSystemProvisionig
16
+ */
17
+ class UnderpostSystemProvisionig {
18
+ static API = {
19
+ /**
20
+ * @property {object} factory
21
+ * @description A factory object containing functions for system provisioning based on OS type.
22
+ * Each OS type (e.g., 'ubuntu') provides methods for base system setup, user creation,
23
+ * timezone configuration, and keyboard layout settings.
24
+ * @memberof UnderpostSystemProvisionig
25
+ */
26
+ factory: {
27
+ /**
28
+ * @property {object} ubuntu
29
+ * @description Provisioning steps for Ubuntu-based systems.
30
+ * @memberof UnderpostSystemProvisionig
31
+ */
32
+ ubuntu: {
33
+ /**
34
+ * @method base
35
+ * @description Generates shell commands for basic Ubuntu system provisioning.
36
+ * This includes updating package lists, installing essential build tools,
37
+ * kernel modules, cloud-init, SSH server, and other core utilities.
38
+ * @param {object} params - The parameters for the function.
39
+ * @memberof UnderpostSystemProvisionig
40
+ * @returns {string[]} An array of shell commands.
41
+ */
42
+ base: () => [
43
+ // Configure APT sources for Ubuntu ports
44
+ `cat <<SOURCES | tee /etc/apt/sources.list
45
+ deb http://ports.ubuntu.com/ubuntu-ports noble main restricted universe multiverse
46
+ deb http://ports.ubuntu.com/ubuntu-ports noble-updates main restricted universe multiverse
47
+ deb http://ports.ubuntu.com/ubuntu-ports noble-security main restricted universe multiverse
48
+ SOURCES`,
49
+
50
+ // Update package lists and perform a full system upgrade
51
+ `apt update -qq`,
52
+ `apt -y full-upgrade`,
53
+
54
+ // Install all essential packages in one consolidated step
55
+ `DEBIAN_FRONTEND=noninteractive apt install -y build-essential xinput x11-xkb-utils usbutils uuid-runtime linux-image-generic systemd-sysv openssh-server sudo locales udev util-linux iproute2 netplan.io ca-certificates curl wget chrony apt-utils tzdata kmod keyboard-configuration console-setup iputils-ping`,
56
+
57
+ // Ensure systemd is the init system
58
+ `ln -sf /lib/systemd/systemd /sbin/init`,
59
+
60
+ // Clean up
61
+ `apt-get clean`,
62
+ ],
63
+ /**
64
+ * @method user
65
+ * @description Generates shell commands for creating a root user and configuring SSH access.
66
+ * This is a critical security step for initial access to the provisioned system.
67
+ * @memberof UnderpostSystemProvisionig
68
+ * @returns {string[]} An array of shell commands.
69
+ */
70
+ user: () => [
71
+ `useradd -m -s /bin/bash -G sudo root`, // Create a root user with bash shell and sudo privileges.
72
+ `echo 'root:root' | chpasswd`, // Set a default password for the root user (consider more secure methods for production).
73
+ `mkdir -p /home/root/.ssh`, // Create .ssh directory for authorized keys.
74
+ // Add the public SSH key to authorized_keys for passwordless login.
75
+ `echo '${fs.readFileSync(
76
+ `/home/dd/engine/engine-private/deploy/id_rsa.pub`,
77
+ 'utf8',
78
+ )}' > /home/root/.ssh/authorized_keys`,
79
+ `chown -R root /home/root/.ssh`, // Set ownership for security.
80
+ `chmod 700 /home/root/.ssh`, // Set permissions for the .ssh directory.
81
+ `chmod 600 /home/root/.ssh/authorized_keys`, // Set permissions for authorized_keys.
82
+ ],
83
+ /**
84
+ * @method timezone
85
+ * @description Generates shell commands for configuring the system timezone and Chrony (NTP client).
86
+ * Accurate time synchronization is essential for logging, security, and distributed systems.
87
+ * @param {object} params - The parameters for the function.
88
+ * @param {string} params.timezone - The timezone string (e.g., 'America/New_York').
89
+ * @param {string} params.chronyConfPath - The path to the Chrony configuration file.
90
+ * @param {string} [alias='chrony'] - The alias for the chrony service.
91
+ * @memberof UnderpostSystemProvisionig
92
+ * @returns {string[]} An array of shell commands.
93
+ */
94
+ timezone: ({ timezone, chronyConfPath }, alias = 'chrony') => [
95
+ `export DEBIAN_FRONTEND=noninteractive`, // Set non-interactive mode for Debian packages.
96
+ `ln -fs /usr/share/zoneinfo/${timezone} /etc/localtime`, // Symlink timezone.
97
+ `sudo dpkg-reconfigure --frontend noninteractive tzdata`, // Reconfigure timezone data.
98
+ `sudo timedatectl set-timezone ${timezone}`, // Set timezone using timedatectl.
99
+ `sudo timedatectl set-ntp true`, // Enable NTP synchronization.
100
+
101
+ // Write the Chrony configuration file.
102
+ `echo '
103
+ # Use public servers from the pool.ntp.org project.
104
+ # Please consider joining the pool (http://www.pool.ntp.org/join.html).
105
+ # pool 2.pool.ntp.org iburst
106
+ server ${process.env.MAAS_NTP_SERVER} iburst
107
+
108
+ # Record the rate at which the system clock gains/losses time.
109
+ driftfile /var/lib/chrony/drift
110
+
111
+ # Allow the system clock to be stepped in the first three updates
112
+ # if its offset is larger than 1 second.
113
+ makestep 1.0 3
114
+
115
+ # Enable kernel synchronization of the real-time clock (RTC).
116
+ rtcsync
117
+
118
+ # Enable hardware timestamping on all interfaces that support it.
119
+ #hwtimestamp *
120
+
121
+ # Increase the minimum number of selectable sources required to adjust
122
+ # the system clock.
123
+ #minsources 2
124
+
125
+ # Allow NTP client access from local network.
126
+ #allow 192.168.0.0/16
127
+
128
+ # Serve time even if not synchronized to a time source.
129
+ #local stratum 10
130
+
131
+ # Specify file containing keys for NTP authentication.
132
+ keyfile /etc/chrony.keys
133
+
134
+ # Get TAI-UTC offset and leap seconds from the system tz database.
135
+ leapsectz right/UTC
136
+
137
+ # Specify directory for log files.
138
+ logdir /var/log/chrony
139
+
140
+ # Select which information is logged.
141
+ #log measurements statistics tracking
142
+ ' > ${chronyConfPath}`,
143
+ `systemctl stop ${alias}`, // Stop Chrony service before reconfiguring.
144
+
145
+ // Enable, restart, and check status of Chrony service.
146
+ `sudo systemctl enable --now ${alias}`,
147
+ `sudo systemctl restart ${alias}`,
148
+
149
+ // Wait for chrony to synchronize
150
+ `echo "Waiting for chrony to synchronize..."`,
151
+ `for i in {1..30}; do chronyc tracking | grep -q "Leap status : Normal" && break || sleep 2; done`,
152
+
153
+ `sudo systemctl status ${alias}`,
154
+
155
+ // Verify Chrony synchronization.
156
+ `chronyc sources`,
157
+ `chronyc tracking`,
158
+
159
+ `chronyc sourcestats -v`, // Display source statistics.
160
+ `timedatectl status`, // Display current time and date settings.
161
+ ],
162
+ /**
163
+ * @method keyboard
164
+ * @description Generates shell commands for configuring the keyboard layout.
165
+ * This ensures correct input behavior on the provisioned system.
166
+ * @param {string} [keyCode='en'] - The keyboard layout code (e.g., 'en', 'es').
167
+ * @memberof UnderpostSystemProvisionig
168
+ * @returns {string[]} An array of shell commands.
169
+ */
170
+ keyboard: (keyCode = 'en') => [
171
+ `sudo locale-gen en_US.UTF-8`,
172
+ `sudo update-locale LANG=en_US.UTF-8`,
173
+ `sudo sed -i 's/XKBLAYOUT="us"/XKBLAYOUT="${keyCode}"/' /etc/default/keyboard`,
174
+ `sudo dpkg-reconfigure --frontend noninteractive keyboard-configuration`,
175
+ `sudo systemctl restart keyboard-setup.service`,
176
+ ],
177
+ },
178
+ /**
179
+ * @property {object} rocky
180
+ * @description Provisioning steps for Rocky Linux-based systems.
181
+ * @memberof UnderpostSystemProvisionig
182
+ */
183
+ rocky: {
184
+ /**
185
+ * @method base
186
+ * @description Generates shell commands for basic Rocky Linux system provisioning.
187
+ * This includes installing Node.js, npm, and underpost CLI tools.
188
+ * @param {object} params - The parameters for the function.
189
+ * @memberof UnderpostSystemProvisionig
190
+ * @returns {string[]} An array of shell commands.
191
+ */
192
+ base: () => [
193
+ // Update system and install EPEL repository
194
+ `dnf -y update`,
195
+ `dnf -y install epel-release`,
196
+
197
+ // Install essential system tools (avoiding duplicates from container packages)
198
+ `dnf -y install --allowerasing bzip2 openssh-server nano vim-enhanced less openssl-devel git gnupg2 libnsl perl`,
199
+ `dnf clean all`,
200
+
201
+ // Install Node.js
202
+ `curl -fsSL https://rpm.nodesource.com/setup_24.x | bash -`,
203
+ `dnf install -y nodejs`,
204
+ `dnf clean all`,
205
+
206
+ // Verify Node.js and npm versions
207
+ `node --version`,
208
+ `npm --version`,
209
+
210
+ // Install underpost ci/cd cli
211
+ `npm install -g underpost`,
212
+ `underpost --version`,
213
+ ],
214
+ /**
215
+ * @method user
216
+ * @description Generates shell commands for creating a root user and configuring SSH access on Rocky Linux.
217
+ * This is a critical security step for initial access to the provisioned system.
218
+ * @memberof UnderpostSystemProvisionig
219
+ * @returns {string[]} An array of shell commands.
220
+ */
221
+ user: () => [
222
+ `useradd -m -s /bin/bash -G wheel root`, // Create a root user with bash shell and wheel group (sudo on RHEL)
223
+ `echo 'root:root' | chpasswd`, // Set a default password for the root user
224
+ `mkdir -p /home/root/.ssh`, // Create .ssh directory for authorized keys
225
+ // Add the public SSH key to authorized_keys for passwordless login
226
+ `echo '${fs.readFileSync(
227
+ `/home/dd/engine/engine-private/deploy/id_rsa.pub`,
228
+ 'utf8',
229
+ )}' > /home/root/.ssh/authorized_keys`,
230
+ `chown -R root:root /home/root/.ssh`, // Set ownership for security
231
+ `chmod 700 /home/root/.ssh`, // Set permissions for the .ssh directory
232
+ `chmod 600 /home/root/.ssh/authorized_keys`, // Set permissions for authorized_keys
233
+ ],
234
+ /**
235
+ * @method timezone
236
+ * @description Generates shell commands for configuring the system timezone on Rocky Linux.
237
+ * @param {object} params - The parameters for the function.
238
+ * @param {string} params.timezone - The timezone string (e.g., 'America/Santiago').
239
+ * @param {string} params.chronyConfPath - The path to the Chrony configuration file (optional).
240
+ * @memberof UnderpostSystemProvisionig
241
+ * @returns {string[]} An array of shell commands.
242
+ */
243
+ timezone: ({ timezone, chronyConfPath = '/etc/chrony.conf' }) => [
244
+ // Set system timezone using both methods (for chroot and running system)
245
+ `ln -sf /usr/share/zoneinfo/${timezone} /etc/localtime`,
246
+ `echo '${timezone}' > /etc/timezone`,
247
+ `timedatectl set-timezone ${timezone} 2>/dev/null`,
248
+
249
+ // Configure chrony with local NTP server and common NTP pools
250
+ `echo '# Local NTP server' > ${chronyConfPath}`,
251
+ `echo 'server 192.168.1.1 iburst prefer' >> ${chronyConfPath}`,
252
+ `echo '' >> ${chronyConfPath}`,
253
+ `echo '# Fallback public NTP servers' >> ${chronyConfPath}`,
254
+ `echo 'server 0.pool.ntp.org iburst' >> ${chronyConfPath}`,
255
+ `echo 'server 1.pool.ntp.org iburst' >> ${chronyConfPath}`,
256
+ `echo 'server 2.pool.ntp.org iburst' >> ${chronyConfPath}`,
257
+ `echo 'server 3.pool.ntp.org iburst' >> ${chronyConfPath}`,
258
+ `echo '' >> ${chronyConfPath}`,
259
+ `echo '# Configuration' >> ${chronyConfPath}`,
260
+ `echo 'driftfile /var/lib/chrony/drift' >> ${chronyConfPath}`,
261
+ `echo 'makestep 1.0 3' >> ${chronyConfPath}`,
262
+ `echo 'rtcsync' >> ${chronyConfPath}`,
263
+ `echo 'logdir /var/log/chrony' >> ${chronyConfPath}`,
264
+
265
+ // Enable chronyd to start on boot
266
+ `systemctl enable chronyd 2>/dev/null`,
267
+
268
+ // Create systemd link for boot (works in chroot)
269
+ `mkdir -p /etc/systemd/system/multi-user.target.wants`,
270
+ `ln -sf /usr/lib/systemd/system/chronyd.service /etc/systemd/system/multi-user.target.wants/chronyd.service 2>/dev/null`,
271
+
272
+ // Start chronyd if systemd is running
273
+ `systemctl start chronyd 2>/dev/null`,
274
+
275
+ // Restart chronyd to apply configuration
276
+ `systemctl restart chronyd 2>/dev/null`,
277
+
278
+ // Force immediate time synchronization (only if chronyd is running)
279
+ `chronyc makestep 2>/dev/null`,
280
+
281
+ // Verify timezone configuration
282
+ `ls -l /etc/localtime`,
283
+ `cat /etc/timezone || echo 'No /etc/timezone file'`,
284
+ `timedatectl status 2>/dev/null || echo 'Timezone set to ${timezone} (timedatectl not available in chroot)'`,
285
+ `chronyc tracking 2>/dev/null || echo 'Chrony configured but not running (will start on boot)'`,
286
+ ],
287
+ /**
288
+ * @method keyboard
289
+ * @description Generates shell commands for configuring the keyboard layout on Rocky Linux.
290
+ * This uses localectl to set the keyboard layout for both console and X11.
291
+ * @param {string} [keyCode='us'] - The keyboard layout code (e.g., 'us', 'es').
292
+ * @memberof UnderpostSystemProvisionig
293
+ * @returns {string[]} An array of shell commands.
294
+ */
295
+ keyboard: (keyCode = 'us') => [
296
+ // Configure vconsole.conf for console keyboard layout (persistent)
297
+ `echo 'KEYMAP=${keyCode}' > /etc/vconsole.conf`,
298
+ `echo 'FONT=latarcyrheb-sun16' >> /etc/vconsole.conf`,
299
+
300
+ // Configure locale.conf for system locale
301
+ `echo 'LANG=en_US.UTF-8' > /etc/locale.conf`,
302
+ `echo 'LC_ALL=en_US.UTF-8' >> /etc/locale.conf`,
303
+
304
+ // Set keyboard layout using localectl (works if systemd is running)
305
+ `localectl set-locale LANG=en_US.UTF-8 2>/dev/null`,
306
+ `localectl set-keymap ${keyCode} 2>/dev/null`,
307
+ `localectl set-x11-keymap ${keyCode} 2>/dev/null`,
308
+
309
+ // Configure X11 keyboard layout file directly
310
+ `mkdir -p /etc/X11/xorg.conf.d`,
311
+ `echo 'Section "InputClass"' > /etc/X11/xorg.conf.d/00-keyboard.conf`,
312
+ `echo ' Identifier "system-keyboard"' >> /etc/X11/xorg.conf.d/00-keyboard.conf`,
313
+ `echo ' MatchIsKeyboard "on"' >> /etc/X11/xorg.conf.d/00-keyboard.conf`,
314
+ `echo ' Option "XkbLayout" "${keyCode}"' >> /etc/X11/xorg.conf.d/00-keyboard.conf`,
315
+ `echo 'EndSection' >> /etc/X11/xorg.conf.d/00-keyboard.conf`,
316
+
317
+ // Load the keymap immediately (if not in chroot)
318
+ `loadkeys ${keyCode} 2>/dev/null || echo 'Keymap ${keyCode} configured (loadkeys not available in chroot)'`,
319
+
320
+ // Verify configuration
321
+ `echo 'Keyboard configuration files:'`,
322
+ `cat /etc/vconsole.conf`,
323
+ `cat /etc/locale.conf`,
324
+ `cat /etc/X11/xorg.conf.d/00-keyboard.conf 2>/dev/null || echo 'X11 config created'`,
325
+ `localectl status 2>/dev/null || echo 'Keyboard layout set to ${keyCode} (localectl not available in chroot)'`,
326
+ ],
327
+ },
328
+ },
329
+ };
330
+ }
331
+
332
+ export default UnderpostSystemProvisionig;
@@ -22,8 +22,9 @@ const Docs = {
22
22
  return html`
23
23
  <iframe
24
24
  class="in iframe-${ModalId}"
25
- style="width: 100%; border: none; background: white"
25
+ style="width: 100%; border: none; background: white; display: block"
26
26
  src="${docData.url()}"
27
+ sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-popups-to-escape-sandbox"
27
28
  >
28
29
  </iframe>
29
30
  `;
@@ -37,9 +38,27 @@ const Docs = {
37
38
  query: true,
38
39
  RouterInstance: Modal.Data['modal-docs'].options.RouterInstance,
39
40
  });
41
+ const iframeEl = s(`.iframe-${ModalId}`);
42
+ if (iframeEl) {
43
+ iframeEl.addEventListener('load', () => {
44
+ try {
45
+ const iframeWin = iframeEl.contentWindow;
46
+ if (iframeWin) {
47
+ Object.defineProperty(iframeWin, 'parent', { get: () => iframeWin, configurable: false });
48
+ Object.defineProperty(iframeWin, 'top', { get: () => iframeWin, configurable: false });
49
+ }
50
+ } catch (e) {
51
+ // cross-origin or security restriction — safe to ignore
52
+ }
53
+ window.scrollTo(0, 0);
54
+ });
55
+ }
40
56
  Modal.Data[ModalId].onObserverListener[ModalId] = () => {
41
- if (s(`.iframe-${ModalId}`))
42
- s(`.iframe-${ModalId}`).style.height = `${s(`.${ModalId}`).offsetHeight - Modal.headerTitleHeight}px`;
57
+ if (s(`.iframe-${ModalId}`)) {
58
+ const barEl = s(`.bar-default-modal-${ModalId}`);
59
+ const barHeight = barEl ? barEl.offsetHeight : Modal.headerTitleHeight;
60
+ s(`.iframe-${ModalId}`).style.height = `${s(`.${ModalId}`).offsetHeight - barHeight}px`;
61
+ }
43
62
 
44
63
  if (type.match('coverage')) {
45
64
  simpleIconsRender(`.doc-icon-coverage`);
@@ -4,7 +4,7 @@ import { loggerFactory } from '../server/logger.js';
4
4
  /**
5
5
  * Module for managing and loading various database connections (e.g., Mongoose, MariaDB).
6
6
  * @module src/db/DataBaseProvider.js
7
- * @namespace DataBaseProviderNamespace
7
+ * @namespace DataBaseProviderService
8
8
  */
9
9
 
10
10
  const logger = loggerFactory(import.meta);
@@ -12,7 +12,7 @@ const logger = loggerFactory(import.meta);
12
12
  /**
13
13
  * @class
14
14
  * @alias DataBaseProviderService
15
- * @memberof DataBaseProviderNamespace
15
+ * @memberof DataBaseProviderService
16
16
  * @classdesc Centralized service for loading, managing, and accessing multiple database connections
17
17
  * based on application configuration (host, path, provider type).
18
18
  */
@@ -90,7 +90,7 @@ class DataBaseProviderService {
90
90
  /**
91
91
  * Singleton instance of the DataBaseProviderService class for backward compatibility.
92
92
  * @alias DataBaseProvider
93
- * @memberof DataBaseProviderNamespace
93
+ * @memberof DataBaseProviderService
94
94
  * @type {DataBaseProviderService}
95
95
  */
96
96
  const DataBaseProvider = new DataBaseProviderService();
@@ -5,7 +5,7 @@ import { loggerFactory } from '../../server/logger.js';
5
5
  /**
6
6
  * Module for interacting with MariaDB/MySQL databases using the mariadb connector.
7
7
  * @module src/db/MariaDB.js
8
- * @namespace MariaDBNamespace
8
+ * @namespace MariaDBService
9
9
  */
10
10
 
11
11
  const logger = loggerFactory(import.meta);
@@ -13,7 +13,7 @@ const logger = loggerFactory(import.meta);
13
13
  /**
14
14
  * @class
15
15
  * @alias MariaDBService
16
- * @memberof MariaDBNamespace
16
+ * @memberof MariaDBService
17
17
  * @classdesc Provides a simplified interface for executing queries against a MariaDB/MySQL database
18
18
  * using a connection pool, ensuring connection management (acquisition and release).
19
19
  */
@@ -58,7 +58,7 @@ class MariaDBService {
58
58
  /**
59
59
  * Singleton instance of the MariaDBService class for backward compatibility.
60
60
  * @alias MariaDB
61
- * @memberof MariaDBNamespace
61
+ * @memberof MariaDBService
62
62
  * @type {MariaDBService}
63
63
  */
64
64
  const MariaDB = new MariaDBService();
@@ -5,7 +5,7 @@ import { getCapVariableName } from '../../client/components/core/CommonJs.js';
5
5
  /**
6
6
  * Module for connecting to and loading models for a MongoDB database using Mongoose.
7
7
  * @module src/db/MongooseDB.js
8
- * @namespace MongooseDBNamespace
8
+ * @namespace MongooseDBService
9
9
  */
10
10
 
11
11
  const logger = loggerFactory(import.meta);
@@ -13,7 +13,7 @@ const logger = loggerFactory(import.meta);
13
13
  /**
14
14
  * @class
15
15
  * @alias MongooseDBService
16
- * @memberof MongooseDBNamespace
16
+ * @memberof MongooseDBService
17
17
  * @classdesc Manages the Mongoose connection lifecycle and dynamic loading of database models
18
18
  * based on API configuration.
19
19
  */
@@ -66,7 +66,7 @@ class MongooseDBService {
66
66
  /**
67
67
  * Singleton instance of the MongooseDBService class for backward compatibility.
68
68
  * @alias MongooseDB
69
- * @memberof MongooseDBNamespace
69
+ * @memberof MongooseDBService
70
70
  * @type {MongooseDBService}
71
71
  */
72
72
  const MongooseDB = new MongooseDBService();