From 276e6978ecf797d8b0cde5c25c88970064038e1d Mon Sep 17 00:00:00 2001
From: Pascal Bleser
Date: Tue, 23 Jun 2026 15:24:33 +0200
Subject: [PATCH] stalwart-snapshot-passwords: fix for Node, and beautify
---
.../stalwart-snapshot-passwords | 40 +++++++++----------
1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/devtools/deployments/opencloud_full/stalwart-snapshot-passwords b/devtools/deployments/opencloud_full/stalwart-snapshot-passwords
index 58e20d28f6..b7ad9716fa 100755
--- a/devtools/deployments/opencloud_full/stalwart-snapshot-passwords
+++ b/devtools/deployments/opencloud_full/stalwart-snapshot-passwords
@@ -3,38 +3,36 @@
// - replace masked passwords with their correct value
// - replace the defaultHostname system setting
-const fs = require('fs');
-const readline = require('readline');
+import * as fs from 'node:fs'
+import readline from 'node:readline'
-const args = process.argv.slice(2);
-const inputs = args.length > 0
- ? args.map(file => fs.createReadStream(file))
- : [process.stdin];
+const args = process.argv.slice(2)
+const inputs = args.length > 0 ? args.map((file) => fs.createReadStream(file)) : [process.stdin]
async function processLines() {
for (const stream of inputs) {
const rl = readline.createInterface({
input: stream,
crlfDelay: Infinity
- });
+ })
for await (const line of rl) {
- const trimmed = line.trim();
- if (!trimmed) continue;
+ const trimmed = line.trim()
+ if (!trimmed) continue
- const item = JSON.parse(trimmed);
- const t = item['@type'];
- const o = item['object'];
+ const item = JSON.parse(trimmed)
+ const t = item['@type']
+ const o = item['object']
if (t === 'create' && o === 'Account') {
- const value = item['value'] || {};
+ const value = item['value'] || {}
for (const [id, account] of Object.entries(value)) {
- const name = account['name'];
+ const name = account['name']
if (name === 'master' || name === 'admin') {
- const credentials = account['credentials'] || {};
+ const credentials = account['credentials'] || {}
for (const [cid, creds] of Object.entries(credentials)) {
if (creds['@type'] === 'Password') {
- creds['secret'] = 'supersecret1234';
+ creds['secret'] = 'supersecret1234'
}
}
}
@@ -42,11 +40,11 @@ async function processLines() {
}
if (t === 'create' && o === 'Directory') {
- const value = item['value'] || {};
+ const value = item['value'] || {}
for (const [id, dir] of Object.entries(value)) {
if (dir['@type'] === 'Ldap') {
if (dir['bindSecret']) {
- dir['bindSecret']['secret'] = 'admin';
+ dir['bindSecret']['secret'] = 'admin'
}
}
}
@@ -54,13 +52,13 @@ async function processLines() {
if (t === 'update' && o === 'SystemSettings') {
if (item['value']) {
- item['value']['defaultHostname'] = 'stalwart.opencloud.test';
+ item['value']['defaultHostname'] = 'stalwart.opencloud.test'
}
}
- console.log(JSON.stringify(item));
+ console.log(JSON.stringify(item))
}
}
}
-processLines();
+processLines()