underpost 2.8.814 → 2.8.815

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 CHANGED
@@ -68,7 +68,7 @@ Run dev client server
68
68
  npm run dev
69
69
  ```
70
70
  <!-- -->
71
- ## underpost ci/cd cli v2.8.814
71
+ ## underpost ci/cd cli v2.8.815
72
72
 
73
73
  ### Usage: `underpost [options] [command]`
74
74
  ```
package/bin/deploy.js CHANGED
@@ -51,52 +51,50 @@ logger.info('argv', process.argv);
51
51
 
52
52
  const [exe, dir, operator] = process.argv;
53
53
 
54
- const updateVirtualRoot = async ({ IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip }) => {
55
- // <consumer_key>:<consumer_token>:<secret>
56
- const MAAS_API_TOKEN = shellExec(`maas apikey --username ${process.env.MAAS_ADMIN_USERNAME}`, {
57
- stdout: true,
58
- }).trim();
59
- const [consumer_key, consumer_token, secret] = MAAS_API_TOKEN.split(`\n`)[0].split(':');
60
- const chronyConfPath = `/etc/chrony/chrony.conf`;
61
- const timezone = 'America/New_York';
62
-
63
- const timeZoneSteps = [
64
- `export DEBIAN_FRONTEND=noninteractive`,
65
-
66
- `ln -fs /usr/share/zoneinfo/${timezone} /etc/localtime`,
67
-
68
- `sudo dpkg-reconfigure --frontend noninteractive tzdata`,
69
- ];
70
- const keyboardSteps = [
71
- `sudo locale-gen en_US.UTF-8`,
72
- `sudo update-locale LANG=en_US.UTF-8`,
73
- `sudo sed -i 's/XKBLAYOUT="us"/XKBLAYOUT="es"/' /etc/default/keyboard`,
74
- `sudo dpkg-reconfigure --frontend noninteractive keyboard-configuration`,
75
- `sudo systemctl restart keyboard-setup.service`,
76
- ];
77
- // # - ${JSON.stringify([...timeZoneSteps, ...chronySetUp(chronyConfPath)])}
78
- const installSteps = [
79
- `cat <<EOF | tee /etc/apt/sources.list
54
+ const chronyConfPath = `/etc/chrony/chrony.conf`;
55
+
56
+ const timezone = 'America/New_York';
57
+
58
+ const timeZoneSteps = [
59
+ `export DEBIAN_FRONTEND=noninteractive`,
60
+
61
+ `ln -fs /usr/share/zoneinfo/${timezone} /etc/localtime`,
62
+
63
+ `sudo dpkg-reconfigure --frontend noninteractive tzdata`,
64
+ ];
65
+ const keyboardSteps = [
66
+ `sudo locale-gen en_US.UTF-8`,
67
+ `sudo update-locale LANG=en_US.UTF-8`,
68
+ `sudo sed -i 's/XKBLAYOUT="us"/XKBLAYOUT="es"/' /etc/default/keyboard`,
69
+ `sudo dpkg-reconfigure --frontend noninteractive keyboard-configuration`,
70
+ `sudo systemctl restart keyboard-setup.service`,
71
+ ];
72
+ // # - ${JSON.stringify([...timeZoneSteps, ...chronySetUp(chronyConfPath)])}
73
+ const installSteps = [
74
+ `cat <<EOF | tee /etc/apt/sources.list
80
75
  deb http://ports.ubuntu.com/ubuntu-ports noble main restricted universe multiverse
81
76
  deb http://ports.ubuntu.com/ubuntu-ports noble-updates main restricted universe multiverse
82
77
  deb http://ports.ubuntu.com/ubuntu-ports noble-security main restricted universe multiverse
83
78
  EOF`,
84
79
 
85
- `apt update -qq`,
86
- `apt -y full-upgrade`,
87
- `apt install -y xinput x11-xkb-utils usbutils`,
88
- // `apt install -y cloud-init=25.1.2-0ubuntu0~24.04.1`,
89
- `apt install -y cloud-init systemd-sysv openssh-server sudo locales udev util-linux systemd-sysv iproute2 netplan.io ca-certificates curl wget chrony`,
90
- `ln -sf /lib/systemd/systemd /sbin/init`,
91
-
92
- `apt-get update`,
93
- `DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils`,
94
- `DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata kmod keyboard-configuration console-setup`,
95
- ];
96
-
97
- let steps = [
98
- // Configure cloud-init for MAAS
99
- `cat <<EOF_MAAS_CFG > /etc/cloud/cloud.cfg.d/90_maas.cfg
80
+ `apt update -qq`,
81
+ `apt -y full-upgrade`,
82
+ `apt install -y xinput x11-xkb-utils usbutils`,
83
+ // `apt install -y cloud-init=25.1.2-0ubuntu0~24.04.1`,
84
+ `apt install -y cloud-init systemd-sysv openssh-server sudo locales udev util-linux systemd-sysv iproute2 netplan.io ca-certificates curl wget chrony`,
85
+ `ln -sf /lib/systemd/systemd /sbin/init`,
86
+
87
+ `apt-get update`,
88
+ `DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils`,
89
+ `DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata kmod keyboard-configuration console-setup iputils-ping`,
90
+ ];
91
+
92
+ const cloudConfigFactory = (
93
+ { IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip },
94
+ { consumer_key, consumer_token, secret },
95
+ ) => [
96
+ // Configure cloud-init for MAAS
97
+ `cat <<EOF_MAAS_CFG > /etc/cloud/cloud.cfg.d/90_maas.cfg
100
98
  #cloud-config
101
99
 
102
100
  hostname: ${host}
@@ -114,37 +112,40 @@ hostname: ${host}
114
112
  datasource_list: [ MAAS ]
115
113
  datasource:
116
114
  MAAS:
117
- metadata_url: http://${IP_ADDRESS}:5240/MAAS/metadata
115
+ metadata_url: http://${IP_ADDRESS}:5248/MAAS/metadata
118
116
  consumer_key: ${consumer_key}
119
117
  token_key: ${consumer_token}
120
118
  token_secret: ${secret}
119
+
121
120
  users:
122
- - name: rpiadmin
123
- sudo: ['ALL=(ALL) NOPASSWD:ALL']
124
- shell: /bin/bash
125
- lock_passwd: true
126
- ssh_authorized_keys:
127
- - ${fs.readFileSync(`/home/dd/engine/engine-private/deploy/id_rsa.pub`, 'utf8')}
121
+ - name: root
122
+ sudo: ['ALL=(ALL) NOPASSWD:ALL']
123
+ shell: /bin/bash
124
+ lock_passwd: true
125
+ ssh_authorized_keys:
126
+ - ${fs.readFileSync(`/home/dd/engine/engine-private/deploy/id_rsa.pub`, 'utf8')}
128
127
 
128
+ # manage_resolv_conf: true
129
+ # resolv_conf:
130
+ # nameservers: [8.8.8.8]
129
131
 
130
132
  # keyboard:
131
133
  # layout: es
132
134
 
133
-
134
135
  # check timedatectl on host
135
136
  # timezone: America/Santiago
136
- timezone: ${timezone}
137
-
138
- ntp:
139
- enabled: true
140
- servers:
141
- - ${IP_ADDRESS}
142
- ntp_client: chrony
143
- config:
144
- confpath: ${chronyConfPath}
145
- packages:
146
- - chrony
147
- service_name: chrony
137
+ # timezone: ${timezone}
138
+
139
+ # ntp:
140
+ # enabled: true
141
+ # servers:
142
+ # - ${IP_ADDRESS}
143
+ # ntp_client: chrony
144
+ # config:
145
+ # confpath: ${chronyConfPath}
146
+ # packages:
147
+ # - chrony
148
+ # service_name: chrony
148
149
 
149
150
  # ssh:
150
151
  # allow-pw: false
@@ -161,13 +162,13 @@ packages:
161
162
  resize_rootfs: false
162
163
  growpart:
163
164
  mode: off
164
- network:
165
- version: 2
166
- ethernets:
167
- ${process.env.RPI4_INTERFACE_NAME}:
168
- dhcp4: true
169
- addresses:
170
- - ${ipaddr}/24
165
+ # network:
166
+ # version: 2
167
+ # ethernets:
168
+ # ${process.env.RPI4_INTERFACE_NAME}:
169
+ # dhcp4: true
170
+ # addresses:
171
+ # - ${ipaddr}/24
171
172
  # routes:
172
173
  # - to: default
173
174
  # via: ${gatewayip}
@@ -175,7 +176,7 @@ network:
175
176
  # chpasswd:
176
177
  # expire: false
177
178
  # users:
178
- # - {name: rpiadmin, password: changeme, type: text}
179
+ # - {name: root, password: changeme, type: text}
179
180
 
180
181
  final_message: "The system is up, after $UPTIME seconds"
181
182
 
@@ -193,86 +194,21 @@ runcmd:
193
194
  - echo "Init runcmd"
194
195
  - echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
195
196
  EOF_MAAS_CFG`,
196
- ];
197
+ ];
197
198
 
198
- const runSteps = (steps = []) => {
199
- const script = steps
200
- .map(
201
- (s, i) => `echo "step ${i + 1}/${steps.length}: ${s.split('\n')[0]}"
199
+ const runSteps = (nfsHostPath, steps = []) => {
200
+ const script = steps
201
+ .map(
202
+ (s, i) => `echo "step ${i + 1}/${steps.length}: ${s.split('\n')[0]}"
202
203
  ${s}`,
203
- )
204
- .join('\n');
204
+ )
205
+ .join('\n');
205
206
 
206
- const cmd = `sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF_OUTER'
207
+ const cmd = `sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF_OUTER'
207
208
  ${script}
208
209
  EOF_OUTER`;
209
210
 
210
- shellExec(cmd);
211
- };
212
-
213
- if (update) {
214
- // --reboot
215
- shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
216
- sudo cloud-init clean --logs --seed --configs all --machine-id
217
- sudo rm -rf /var/lib/cloud/*
218
- EOF`);
219
-
220
- if (fs.existsSync(`${nfsHostPath}/var/log/`)) {
221
- fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init.log`, '', 'utf8');
222
- fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init-output.log`, '', 'utf8');
223
- }
224
-
225
- runSteps(steps);
226
- } else {
227
- runSteps(installSteps.concat(steps));
228
-
229
- shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
230
- echo "nameserver ${process.env.MAAS_DNS}" | tee /etc/resolv.conf > /dev/null
231
- apt update
232
- EOF`);
233
- fs.writeFileSync(
234
- `${nfsHostPath}/dns.sh`,
235
- `rm /etc/resolv.conf
236
- echo 'nameserver 8.8.8.8' > /run/systemd/resolve/stub-resolv.conf
237
- ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf`,
238
- 'utf8',
239
- );
240
-
241
- runSteps([
242
- // `date -s "${shellExec(`date '+%Y-%m-%d %H:%M:%S'`, { stdout: true }).trim()}"`,
243
- // `date`,
244
- ...timeZoneSteps,
245
- ...chronySetUp(chronyConfPath),
246
- ...keyboardSteps,
247
- ]);
248
-
249
- runSteps([
250
- `useradd -m -s /bin/bash -G sudo root`,
251
- `echo 'root:root' | chpasswd`,
252
- `mkdir -p /home/root/.ssh`,
253
- `echo '${fs.readFileSync(
254
- `/home/dd/engine/engine-private/deploy/id_rsa.pub`,
255
- 'utf8',
256
- )}' > /home/root/.ssh/authorized_keys`,
257
- `chown -R root /home/root/.ssh`,
258
- `chmod 700 /home/root/.ssh`,
259
- `chmod 600 /home/root/.ssh/authorized_keys`,
260
- ]);
261
- }
262
-
263
- logger.info('Check virtual root user config');
264
- {
265
- const cmd = `sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF_OUTER'
266
- echo -e "\n=== Current date/time ==="
267
- date '+%Y-%m-%d %H:%M:%S'
268
- echo -e "\n=== Keyboard layout ==="
269
- cat /etc/default/keyboard
270
- echo -e "\n=== Registered users ==="
271
- cut -d: -f1 /etc/passwd
272
- EOF_OUTER`;
273
-
274
- shellExec(cmd);
275
- }
211
+ shellExec(cmd);
276
212
  };
277
213
 
278
214
  const chronySetUp = (path) => {
@@ -336,6 +272,155 @@ logdir /var/log/chrony
336
272
  ];
337
273
  };
338
274
 
275
+ const installUbuntuUnderpostTools = (nfsHostPath) => {
276
+ fs.mkdirSync(`${nfsHostPath}/underpost`, { recursive: true });
277
+
278
+ logger.info('Build', `${nfsHostPath}/underpost/date.sh`);
279
+ fs.writeFileSync(
280
+ `${nfsHostPath}/underpost/date.sh`,
281
+ `${timeZoneSteps.join('\n')}
282
+ ${chronySetUp(chronyConfPath).join('\n')}
283
+ `,
284
+ 'utf8',
285
+ );
286
+
287
+ logger.info('Build', `${nfsHostPath}/underpost/keyboard.sh`);
288
+ fs.writeFileSync(
289
+ `${nfsHostPath}/underpost/keyboard.sh`,
290
+ `${keyboardSteps.join('\n')}
291
+ `,
292
+ 'utf8',
293
+ );
294
+
295
+ logger.info('Build', `${nfsHostPath}/underpost/dns.sh`);
296
+ // echo "nameserver ${process.env.MAAS_DNS}" | tee /etc/resolv.conf > /dev/null
297
+ fs.writeFileSync(
298
+ `${nfsHostPath}/underpost/dns.sh`,
299
+ `rm /etc/resolv.conf
300
+ echo 'nameserver 8.8.8.8' > /run/systemd/resolve/stub-resolv.conf
301
+ ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf`,
302
+ 'utf8',
303
+ );
304
+
305
+ logger.info('Build', `${nfsHostPath}/underpost/help.sh`);
306
+ fs.writeFileSync(
307
+ `${nfsHostPath}/underpost/help.sh`,
308
+ `echo "=== Cloud init utils ==="
309
+ echo "sudo cloud-init --all-stages"
310
+ echo "sudo cloud-init init --local"
311
+ echo "sudo cloud-init init"
312
+ echo "sudo cloud-init modules --mode=config"
313
+ echo "sudo cloud-init modules --mode=final"`,
314
+ 'utf8',
315
+ );
316
+
317
+ logger.info('Build', `${nfsHostPath}/underpost/test.sh`);
318
+ fs.writeFileSync(
319
+ `${nfsHostPath}/underpost/test.sh`,
320
+ `echo -e "\n=== Current date/time ==="
321
+ date '+%Y-%m-%d %H:%M:%S'
322
+ echo -e "\n=== Keyboard layout ==="
323
+ cat /etc/default/keyboard
324
+ echo -e "\n=== Registered users ==="
325
+ cut -d: -f1 /etc/passwd
326
+ `,
327
+ 'utf8',
328
+ );
329
+
330
+ logger.info('Build', `${nfsHostPath}/underpost/config-path.sh`);
331
+ fs.writeFileSync(`${nfsHostPath}/underpost/config-path.sh`, `echo "/etc/cloud/cloud.cfg.d/90_maas.cfg"`, 'utf8');
332
+
333
+ shellExec(`sudo rm -rf ${nfsHostPath}/root/.ssh`);
334
+ shellExec(`sudo rm -rf ${nfsHostPath}/home/root/.ssh`);
335
+
336
+ fs.copySync(`/root/.ssh`, `${nfsHostPath}/root/.ssh`);
337
+
338
+ logger.info('Run', `${nfsHostPath}/underpost/test.sh`);
339
+ runSteps(nfsHostPath, [
340
+ `chmod +x /underpost/date.sh`,
341
+ `chmod +x /underpost/keyboard.sh`,
342
+ `chmod +x /underpost/dns.sh`,
343
+ `chmod +x /underpost/help.sh`,
344
+ `chmod +x /underpost/config-path.sh`,
345
+ `chmod +x /underpost/test.sh`,
346
+ `sudo chmod 700 ~/.ssh/`,
347
+ `sudo chmod 600 ~/.ssh/authorized_keys`,
348
+ `sudo chmod 644 ~/.ssh/known_hosts`,
349
+ `sudo chmod 600 ~/.ssh/id_rsa`,
350
+ `sudo chmod 600 /etc/ssh/ssh_host_ed25519_key`,
351
+ `chown -R root:root ~/.ssh`,
352
+ `/underpost/test.sh`,
353
+ ]);
354
+ };
355
+
356
+ const updateVirtualRoot = async ({ IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip }) => {
357
+ // <consumer_key>:<consumer_token>:<secret>
358
+ let [consumer_key, consumer_token, secret] = process.argv.includes('reset')
359
+ ? shellExec(`maas apikey --username ${process.env.MAAS_ADMIN_USERNAME}`, {
360
+ stdout: true,
361
+ })
362
+ .trim()
363
+ .split(`\n`)[0]
364
+ .split(':')
365
+ : shellExec(`maas apikey --generate --username ${process.env.MAAS_ADMIN_USERNAME}`, {
366
+ stdout: true,
367
+ })
368
+ .trim()
369
+ .split(':');
370
+
371
+ if (process.argv.includes('reset')) secret = '&' + secret;
372
+
373
+ logger.info('Maas api token generated', { consumer_key, consumer_token, secret });
374
+
375
+ if (update) {
376
+ // --reboot
377
+ if (process.argv.includes('reset'))
378
+ shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
379
+ sudo cloud-init clean --logs --seed --configs all --machine-id
380
+ sudo rm -rf /var/lib/cloud/*
381
+ EOF`);
382
+
383
+ if (fs.existsSync(`${nfsHostPath}/var/log/`)) {
384
+ fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init.log`, '', 'utf8');
385
+ fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init-output.log`, '', 'utf8');
386
+ }
387
+ } else {
388
+ runSteps(nfsHostPath, installSteps);
389
+ runSteps(nfsHostPath, [
390
+ `useradd -m -s /bin/bash -G sudo root`,
391
+ `echo 'root:root' | chpasswd`,
392
+ `mkdir -p /home/root/.ssh`,
393
+ `echo '${fs.readFileSync(
394
+ `/home/dd/engine/engine-private/deploy/id_rsa.pub`,
395
+ 'utf8',
396
+ )}' > /home/root/.ssh/authorized_keys`,
397
+ `chown -R root /home/root/.ssh`,
398
+ `chmod 700 /home/root/.ssh`,
399
+ `chmod 600 /home/root/.ssh/authorized_keys`,
400
+ ]);
401
+ runSteps(nfsHostPath, [
402
+ // `date -s "${shellExec(`date '+%Y-%m-%d %H:%M:%S'`, { stdout: true }).trim()}"`,
403
+ // `date`,
404
+ ...timeZoneSteps,
405
+ ...chronySetUp(chronyConfPath),
406
+ ...keyboardSteps,
407
+ ]);
408
+ }
409
+
410
+ runSteps(
411
+ nfsHostPath,
412
+ cloudConfigFactory(
413
+ { IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip },
414
+ {
415
+ consumer_key,
416
+ consumer_token,
417
+ secret,
418
+ },
419
+ ),
420
+ );
421
+ installUbuntuUnderpostTools(nfsHostPath);
422
+ };
423
+
339
424
  try {
340
425
  switch (operator) {
341
426
  case 'save':
@@ -1876,7 +1961,7 @@ EOF`);
1876
1961
 
1877
1962
  // identity:
1878
1963
  // hostname: rpi4
1879
- // username: rpiadmin
1964
+ // username: root
1880
1965
  // password: "{{PASSWORD}}"
1881
1966
 
1882
1967
  // ssh:
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.814
1
+ ## underpost ci/cd cli v2.8.815
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -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.814'
61
+ engine.version: '2.8.815'
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.814
20
+ image: localhost/rockylinux9-underpost:v2.8.815
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.814
103
+ image: localhost/rockylinux9-underpost:v2.8.815
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.814",
5
+ "version": "2.8.815",
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",
package/src/index.js CHANGED
@@ -32,7 +32,7 @@ class Underpost {
32
32
  * @type {String}
33
33
  * @memberof Underpost
34
34
  */
35
- static version = 'v2.8.814';
35
+ static version = 'v2.8.815';
36
36
  /**
37
37
  * Repository cli API
38
38
  * @static