iobroker.script-restore 0.0.7 → 0.0.9
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 +12 -0
- package/admin/i18n/de/translations.json +40 -0
- package/admin/i18n/en/translations.json +40 -0
- package/admin/i18n/es/translations.json +40 -0
- package/admin/i18n/fr/translations.json +40 -0
- package/admin/i18n/it/translations.json +40 -0
- package/admin/i18n/nl/translations.json +40 -0
- package/admin/i18n/pl/translations.json +40 -0
- package/admin/i18n/pt/translations.json +40 -0
- package/admin/i18n/ru/translations.json +40 -0
- package/admin/i18n/uk/translations.json +40 -0
- package/admin/i18n/zh-cn/translations.json +40 -0
- package/admin/jsonConfig.json +423 -0
- package/build/main.js +34 -33
- package/build/main.js.map +2 -2
- package/io-package.json +28 -2
- package/package.json +1 -1
- package/admin/index_m.html +0 -412
- package/admin/style.css +0 -32
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "tabs",
|
|
3
|
+
"i18n": true,
|
|
4
|
+
"items": {
|
|
5
|
+
"tabLocal": {
|
|
6
|
+
"type": "panel",
|
|
7
|
+
"label": "localSection",
|
|
8
|
+
"items": {
|
|
9
|
+
"localEnabled": {
|
|
10
|
+
"type": "checkbox",
|
|
11
|
+
"label": "localEnabled",
|
|
12
|
+
"default": true,
|
|
13
|
+
"xs": 12,
|
|
14
|
+
"sm": 12,
|
|
15
|
+
"md": 12,
|
|
16
|
+
"lg": 12,
|
|
17
|
+
"xl": 12
|
|
18
|
+
},
|
|
19
|
+
"_divLocal": {
|
|
20
|
+
"type": "divider"
|
|
21
|
+
},
|
|
22
|
+
"backupPath": {
|
|
23
|
+
"type": "text",
|
|
24
|
+
"label": "backupPath",
|
|
25
|
+
"placeholder": "/opt/iobroker/backups",
|
|
26
|
+
"hidden": "!data.localEnabled",
|
|
27
|
+
"xs": 12,
|
|
28
|
+
"sm": 9,
|
|
29
|
+
"md": 9,
|
|
30
|
+
"lg": 10,
|
|
31
|
+
"xl": 10
|
|
32
|
+
},
|
|
33
|
+
"_suggestBtn": {
|
|
34
|
+
"type": "sendTo",
|
|
35
|
+
"command": "suggestBackupPath",
|
|
36
|
+
"label": "suggestPath",
|
|
37
|
+
"hidden": "!data.localEnabled",
|
|
38
|
+
"xs": 12,
|
|
39
|
+
"sm": 3,
|
|
40
|
+
"md": 3,
|
|
41
|
+
"lg": 2,
|
|
42
|
+
"xl": 2
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"tabFtp": {
|
|
47
|
+
"type": "panel",
|
|
48
|
+
"label": "ftpSection",
|
|
49
|
+
"items": {
|
|
50
|
+
"ftpEnabled": {
|
|
51
|
+
"type": "checkbox",
|
|
52
|
+
"label": "ftpEnabled",
|
|
53
|
+
"xs": 12,
|
|
54
|
+
"sm": 12,
|
|
55
|
+
"md": 12,
|
|
56
|
+
"lg": 12,
|
|
57
|
+
"xl": 12
|
|
58
|
+
},
|
|
59
|
+
"_divFtp": {
|
|
60
|
+
"type": "divider"
|
|
61
|
+
},
|
|
62
|
+
"ftpHost": {
|
|
63
|
+
"type": "text",
|
|
64
|
+
"label": "ftpHost",
|
|
65
|
+
"placeholder": "192.168.1.100",
|
|
66
|
+
"hidden": "!data.ftpEnabled",
|
|
67
|
+
"xs": 12,
|
|
68
|
+
"sm": 6,
|
|
69
|
+
"md": 6,
|
|
70
|
+
"lg": 6,
|
|
71
|
+
"xl": 6
|
|
72
|
+
},
|
|
73
|
+
"ftpPort": {
|
|
74
|
+
"type": "number",
|
|
75
|
+
"label": "ftpPort",
|
|
76
|
+
"placeholder": "21",
|
|
77
|
+
"min": 1,
|
|
78
|
+
"max": 65535,
|
|
79
|
+
"hidden": "!data.ftpEnabled",
|
|
80
|
+
"xs": 12,
|
|
81
|
+
"sm": 3,
|
|
82
|
+
"md": 3,
|
|
83
|
+
"lg": 3,
|
|
84
|
+
"xl": 3
|
|
85
|
+
},
|
|
86
|
+
"ftpSecure": {
|
|
87
|
+
"type": "checkbox",
|
|
88
|
+
"label": "ftpSecure",
|
|
89
|
+
"hidden": "!data.ftpEnabled",
|
|
90
|
+
"xs": 12,
|
|
91
|
+
"sm": 3,
|
|
92
|
+
"md": 3,
|
|
93
|
+
"lg": 3,
|
|
94
|
+
"xl": 3
|
|
95
|
+
},
|
|
96
|
+
"ftpUser": {
|
|
97
|
+
"type": "text",
|
|
98
|
+
"label": "ftpUser",
|
|
99
|
+
"placeholder": "anonymous",
|
|
100
|
+
"hidden": "!data.ftpEnabled",
|
|
101
|
+
"xs": 12,
|
|
102
|
+
"sm": 6,
|
|
103
|
+
"md": 6,
|
|
104
|
+
"lg": 6,
|
|
105
|
+
"xl": 6
|
|
106
|
+
},
|
|
107
|
+
"ftpPassword": {
|
|
108
|
+
"type": "password",
|
|
109
|
+
"label": "ftpPassword",
|
|
110
|
+
"hidden": "!data.ftpEnabled",
|
|
111
|
+
"xs": 12,
|
|
112
|
+
"sm": 6,
|
|
113
|
+
"md": 6,
|
|
114
|
+
"lg": 6,
|
|
115
|
+
"xl": 6
|
|
116
|
+
},
|
|
117
|
+
"ftpPath": {
|
|
118
|
+
"type": "text",
|
|
119
|
+
"label": "ftpPath",
|
|
120
|
+
"placeholder": "/backups",
|
|
121
|
+
"hidden": "!data.ftpEnabled",
|
|
122
|
+
"xs": 12,
|
|
123
|
+
"sm": 9,
|
|
124
|
+
"md": 9,
|
|
125
|
+
"lg": 9,
|
|
126
|
+
"xl": 9
|
|
127
|
+
},
|
|
128
|
+
"_ftpTestBtn": {
|
|
129
|
+
"type": "sendTo",
|
|
130
|
+
"command": "testFtp",
|
|
131
|
+
"label": "testConnection",
|
|
132
|
+
"hidden": "!data.ftpEnabled",
|
|
133
|
+
"xs": 12,
|
|
134
|
+
"sm": 3,
|
|
135
|
+
"md": 3,
|
|
136
|
+
"lg": 3,
|
|
137
|
+
"xl": 3
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"tabSmb": {
|
|
142
|
+
"type": "panel",
|
|
143
|
+
"label": "smbSection",
|
|
144
|
+
"items": {
|
|
145
|
+
"smbEnabled": {
|
|
146
|
+
"type": "checkbox",
|
|
147
|
+
"label": "smbEnabled",
|
|
148
|
+
"xs": 12,
|
|
149
|
+
"sm": 12,
|
|
150
|
+
"md": 12,
|
|
151
|
+
"lg": 12,
|
|
152
|
+
"xl": 12
|
|
153
|
+
},
|
|
154
|
+
"_smbInfo": {
|
|
155
|
+
"type": "staticText",
|
|
156
|
+
"text": "smbInfo",
|
|
157
|
+
"hidden": "!data.smbEnabled",
|
|
158
|
+
"xs": 12,
|
|
159
|
+
"sm": 12,
|
|
160
|
+
"md": 12,
|
|
161
|
+
"lg": 12,
|
|
162
|
+
"xl": 12
|
|
163
|
+
},
|
|
164
|
+
"_divSmb": {
|
|
165
|
+
"type": "divider"
|
|
166
|
+
},
|
|
167
|
+
"smbHost": {
|
|
168
|
+
"type": "text",
|
|
169
|
+
"label": "smbHost",
|
|
170
|
+
"placeholder": "192.168.1.100",
|
|
171
|
+
"hidden": "!data.smbEnabled",
|
|
172
|
+
"xs": 12,
|
|
173
|
+
"sm": 6,
|
|
174
|
+
"md": 6,
|
|
175
|
+
"lg": 6,
|
|
176
|
+
"xl": 6
|
|
177
|
+
},
|
|
178
|
+
"smbShare": {
|
|
179
|
+
"type": "text",
|
|
180
|
+
"label": "smbShare",
|
|
181
|
+
"placeholder": "Backups",
|
|
182
|
+
"hidden": "!data.smbEnabled",
|
|
183
|
+
"xs": 12,
|
|
184
|
+
"sm": 6,
|
|
185
|
+
"md": 6,
|
|
186
|
+
"lg": 6,
|
|
187
|
+
"xl": 6
|
|
188
|
+
},
|
|
189
|
+
"smbPath": {
|
|
190
|
+
"type": "text",
|
|
191
|
+
"label": "smbPath",
|
|
192
|
+
"hidden": "!data.smbEnabled",
|
|
193
|
+
"xs": 12,
|
|
194
|
+
"sm": 6,
|
|
195
|
+
"md": 6,
|
|
196
|
+
"lg": 6,
|
|
197
|
+
"xl": 6
|
|
198
|
+
},
|
|
199
|
+
"smbDomain": {
|
|
200
|
+
"type": "text",
|
|
201
|
+
"label": "smbDomain",
|
|
202
|
+
"hidden": "!data.smbEnabled",
|
|
203
|
+
"xs": 12,
|
|
204
|
+
"sm": 6,
|
|
205
|
+
"md": 6,
|
|
206
|
+
"lg": 6,
|
|
207
|
+
"xl": 6
|
|
208
|
+
},
|
|
209
|
+
"smbUser": {
|
|
210
|
+
"type": "text",
|
|
211
|
+
"label": "smbUser",
|
|
212
|
+
"hidden": "!data.smbEnabled",
|
|
213
|
+
"xs": 12,
|
|
214
|
+
"sm": 6,
|
|
215
|
+
"md": 6,
|
|
216
|
+
"lg": 6,
|
|
217
|
+
"xl": 6
|
|
218
|
+
},
|
|
219
|
+
"smbPassword": {
|
|
220
|
+
"type": "password",
|
|
221
|
+
"label": "smbPassword",
|
|
222
|
+
"hidden": "!data.smbEnabled",
|
|
223
|
+
"xs": 12,
|
|
224
|
+
"sm": 6,
|
|
225
|
+
"md": 6,
|
|
226
|
+
"lg": 6,
|
|
227
|
+
"xl": 6
|
|
228
|
+
},
|
|
229
|
+
"_smbTestBtn": {
|
|
230
|
+
"type": "sendTo",
|
|
231
|
+
"command": "testSmb",
|
|
232
|
+
"label": "testConnection",
|
|
233
|
+
"hidden": "!data.smbEnabled",
|
|
234
|
+
"xs": 12,
|
|
235
|
+
"sm": 12,
|
|
236
|
+
"md": 12,
|
|
237
|
+
"lg": 12,
|
|
238
|
+
"xl": 12
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
"tabHttp": {
|
|
243
|
+
"type": "panel",
|
|
244
|
+
"label": "httpSection",
|
|
245
|
+
"items": {
|
|
246
|
+
"httpEnabled": {
|
|
247
|
+
"type": "checkbox",
|
|
248
|
+
"label": "httpEnabled",
|
|
249
|
+
"xs": 12,
|
|
250
|
+
"sm": 12,
|
|
251
|
+
"md": 12,
|
|
252
|
+
"lg": 12,
|
|
253
|
+
"xl": 12
|
|
254
|
+
},
|
|
255
|
+
"_httpInfo": {
|
|
256
|
+
"type": "staticText",
|
|
257
|
+
"text": "httpInfo",
|
|
258
|
+
"hidden": "!data.httpEnabled",
|
|
259
|
+
"xs": 12,
|
|
260
|
+
"sm": 12,
|
|
261
|
+
"md": 12,
|
|
262
|
+
"lg": 12,
|
|
263
|
+
"xl": 12
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"tabSftp": {
|
|
268
|
+
"type": "panel",
|
|
269
|
+
"label": "sftpSection",
|
|
270
|
+
"items": {
|
|
271
|
+
"sftpEnabled": {
|
|
272
|
+
"type": "checkbox",
|
|
273
|
+
"label": "sftpEnabled",
|
|
274
|
+
"xs": 12,
|
|
275
|
+
"sm": 12,
|
|
276
|
+
"md": 12,
|
|
277
|
+
"lg": 12,
|
|
278
|
+
"xl": 12
|
|
279
|
+
},
|
|
280
|
+
"_divSftp": {
|
|
281
|
+
"type": "divider"
|
|
282
|
+
},
|
|
283
|
+
"sftpHost": {
|
|
284
|
+
"type": "text",
|
|
285
|
+
"label": "sftpHost",
|
|
286
|
+
"placeholder": "192.168.1.100",
|
|
287
|
+
"hidden": "!data.sftpEnabled",
|
|
288
|
+
"xs": 12,
|
|
289
|
+
"sm": 6,
|
|
290
|
+
"md": 6,
|
|
291
|
+
"lg": 6,
|
|
292
|
+
"xl": 6
|
|
293
|
+
},
|
|
294
|
+
"sftpPort": {
|
|
295
|
+
"type": "number",
|
|
296
|
+
"label": "sftpPort",
|
|
297
|
+
"placeholder": "22",
|
|
298
|
+
"min": 1,
|
|
299
|
+
"max": 65535,
|
|
300
|
+
"hidden": "!data.sftpEnabled",
|
|
301
|
+
"xs": 12,
|
|
302
|
+
"sm": 6,
|
|
303
|
+
"md": 6,
|
|
304
|
+
"lg": 6,
|
|
305
|
+
"xl": 6
|
|
306
|
+
},
|
|
307
|
+
"sftpUser": {
|
|
308
|
+
"type": "text",
|
|
309
|
+
"label": "sftpUser",
|
|
310
|
+
"hidden": "!data.sftpEnabled",
|
|
311
|
+
"xs": 12,
|
|
312
|
+
"sm": 6,
|
|
313
|
+
"md": 6,
|
|
314
|
+
"lg": 6,
|
|
315
|
+
"xl": 6
|
|
316
|
+
},
|
|
317
|
+
"sftpPassword": {
|
|
318
|
+
"type": "password",
|
|
319
|
+
"label": "sftpPassword",
|
|
320
|
+
"hidden": "!data.sftpEnabled",
|
|
321
|
+
"xs": 12,
|
|
322
|
+
"sm": 6,
|
|
323
|
+
"md": 6,
|
|
324
|
+
"lg": 6,
|
|
325
|
+
"xl": 6
|
|
326
|
+
},
|
|
327
|
+
"sftpPath": {
|
|
328
|
+
"type": "text",
|
|
329
|
+
"label": "sftpPath",
|
|
330
|
+
"placeholder": "/",
|
|
331
|
+
"hidden": "!data.sftpEnabled",
|
|
332
|
+
"xs": 12,
|
|
333
|
+
"sm": 9,
|
|
334
|
+
"md": 9,
|
|
335
|
+
"lg": 9,
|
|
336
|
+
"xl": 9
|
|
337
|
+
},
|
|
338
|
+
"_sftpTestBtn": {
|
|
339
|
+
"type": "sendTo",
|
|
340
|
+
"command": "testSftp",
|
|
341
|
+
"label": "testConnection",
|
|
342
|
+
"hidden": "!data.sftpEnabled",
|
|
343
|
+
"xs": 12,
|
|
344
|
+
"sm": 3,
|
|
345
|
+
"md": 3,
|
|
346
|
+
"lg": 3,
|
|
347
|
+
"xl": 3
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
"tabWebdav": {
|
|
352
|
+
"type": "panel",
|
|
353
|
+
"label": "webdavSection",
|
|
354
|
+
"items": {
|
|
355
|
+
"webdavEnabled": {
|
|
356
|
+
"type": "checkbox",
|
|
357
|
+
"label": "webdavEnabled",
|
|
358
|
+
"xs": 12,
|
|
359
|
+
"sm": 12,
|
|
360
|
+
"md": 12,
|
|
361
|
+
"lg": 12,
|
|
362
|
+
"xl": 12
|
|
363
|
+
},
|
|
364
|
+
"_divWebdav": {
|
|
365
|
+
"type": "divider"
|
|
366
|
+
},
|
|
367
|
+
"webdavUrl": {
|
|
368
|
+
"type": "text",
|
|
369
|
+
"label": "webdavUrl",
|
|
370
|
+
"placeholder": "https://cloud.example.com/remote.php/webdav",
|
|
371
|
+
"hidden": "!data.webdavEnabled",
|
|
372
|
+
"xs": 12,
|
|
373
|
+
"sm": 12,
|
|
374
|
+
"md": 12,
|
|
375
|
+
"lg": 12,
|
|
376
|
+
"xl": 12
|
|
377
|
+
},
|
|
378
|
+
"webdavUser": {
|
|
379
|
+
"type": "text",
|
|
380
|
+
"label": "webdavUser",
|
|
381
|
+
"hidden": "!data.webdavEnabled",
|
|
382
|
+
"xs": 12,
|
|
383
|
+
"sm": 6,
|
|
384
|
+
"md": 6,
|
|
385
|
+
"lg": 6,
|
|
386
|
+
"xl": 6
|
|
387
|
+
},
|
|
388
|
+
"webdavPassword": {
|
|
389
|
+
"type": "password",
|
|
390
|
+
"label": "webdavPassword",
|
|
391
|
+
"hidden": "!data.webdavEnabled",
|
|
392
|
+
"xs": 12,
|
|
393
|
+
"sm": 6,
|
|
394
|
+
"md": 6,
|
|
395
|
+
"lg": 6,
|
|
396
|
+
"xl": 6
|
|
397
|
+
},
|
|
398
|
+
"webdavPath": {
|
|
399
|
+
"type": "text",
|
|
400
|
+
"label": "webdavPath",
|
|
401
|
+
"placeholder": "/",
|
|
402
|
+
"hidden": "!data.webdavEnabled",
|
|
403
|
+
"xs": 12,
|
|
404
|
+
"sm": 9,
|
|
405
|
+
"md": 9,
|
|
406
|
+
"lg": 9,
|
|
407
|
+
"xl": 9
|
|
408
|
+
},
|
|
409
|
+
"_webdavTestBtn": {
|
|
410
|
+
"type": "sendTo",
|
|
411
|
+
"command": "testWebdav",
|
|
412
|
+
"label": "testConnection",
|
|
413
|
+
"hidden": "!data.webdavEnabled",
|
|
414
|
+
"xs": 12,
|
|
415
|
+
"sm": 3,
|
|
416
|
+
"md": 3,
|
|
417
|
+
"lg": 3,
|
|
418
|
+
"xl": 3
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
package/build/main.js
CHANGED
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
mod
|
|
23
23
|
));
|
|
24
24
|
var utils = __toESM(require("@iobroker/adapter-core"));
|
|
25
|
-
var fs = __toESM(require("fs/promises"));
|
|
25
|
+
var fs = __toESM(require("node:fs/promises"));
|
|
26
26
|
var path = __toESM(require("node:path"));
|
|
27
27
|
var os = __toESM(require("node:os"));
|
|
28
28
|
var import_node_child_process = require("node:child_process");
|
|
@@ -183,52 +183,47 @@ class ScriptRestore extends utils.Adapter {
|
|
|
183
183
|
}
|
|
184
184
|
// ─── Tests ───────────────────────────────────────────────────────────────
|
|
185
185
|
async handleTestFtp(obj) {
|
|
186
|
-
const msg = obj.message;
|
|
187
186
|
const client = new ftp.Client();
|
|
188
187
|
client.ftp.verbose = false;
|
|
189
188
|
try {
|
|
190
189
|
await client.access({
|
|
191
|
-
host:
|
|
192
|
-
port:
|
|
193
|
-
user:
|
|
194
|
-
password:
|
|
195
|
-
secure:
|
|
190
|
+
host: this.config.ftpHost,
|
|
191
|
+
port: this.config.ftpPort || 21,
|
|
192
|
+
user: this.config.ftpUser || "anonymous",
|
|
193
|
+
password: this.config.ftpPassword || "",
|
|
194
|
+
secure: this.config.ftpSecure || false
|
|
196
195
|
});
|
|
197
|
-
const list = await client.list(
|
|
196
|
+
const list = await client.list(this.config.ftpPath || "/");
|
|
198
197
|
const count = list.filter((i) => i.type === ftp.FileType.File).length;
|
|
199
198
|
this.sendTo(
|
|
200
199
|
obj.from,
|
|
201
200
|
obj.command,
|
|
202
|
-
|
|
201
|
+
`\u2713 Verbunden! ${count} Datei(en) in: ${this.config.ftpPath || "/"}`,
|
|
203
202
|
obj.callback
|
|
204
203
|
);
|
|
205
204
|
} catch (e) {
|
|
206
|
-
this.sendTo(obj.from, obj.command, {
|
|
205
|
+
this.sendTo(obj.from, obj.command, { error: e.message }, obj.callback);
|
|
207
206
|
} finally {
|
|
208
207
|
client.close();
|
|
209
208
|
}
|
|
210
209
|
}
|
|
211
210
|
async handleTestSmb(obj) {
|
|
212
|
-
const msg = obj.message;
|
|
213
211
|
const smb = new SMB2({
|
|
214
|
-
share: `\\\\${
|
|
215
|
-
username:
|
|
216
|
-
password:
|
|
217
|
-
domain:
|
|
212
|
+
share: `\\\\${this.config.smbHost}\\${this.config.smbShare}`,
|
|
213
|
+
username: this.config.smbUser || "",
|
|
214
|
+
password: this.config.smbPassword || "",
|
|
215
|
+
domain: this.config.smbDomain || ""
|
|
218
216
|
});
|
|
219
217
|
try {
|
|
220
|
-
const files = await this.smbReaddir(smb,
|
|
218
|
+
const files = await this.smbReaddir(smb, this.config.smbPath || "");
|
|
221
219
|
this.sendTo(
|
|
222
220
|
obj.from,
|
|
223
221
|
obj.command,
|
|
224
|
-
{
|
|
225
|
-
success: true,
|
|
226
|
-
message: `Verbunden! ${files.length} Eintr\xE4ge in: \\\\${msg.host}\\${msg.share}${msg.path ? `\\${msg.path}` : ""}`
|
|
227
|
-
},
|
|
222
|
+
`\u2713 Verbunden! ${files.length} Eintr\xE4ge in: \\\\${this.config.smbHost}\\${this.config.smbShare}${this.config.smbPath ? `\\${this.config.smbPath}` : ""}`,
|
|
228
223
|
obj.callback
|
|
229
224
|
);
|
|
230
225
|
} catch (e) {
|
|
231
|
-
this.sendTo(obj.from, obj.command, {
|
|
226
|
+
this.sendTo(obj.from, obj.command, { error: e.message }, obj.callback);
|
|
232
227
|
} finally {
|
|
233
228
|
smb.disconnect();
|
|
234
229
|
}
|
|
@@ -512,12 +507,12 @@ class ScriptRestore extends utils.Adapter {
|
|
|
512
507
|
for (const p of candidates) {
|
|
513
508
|
try {
|
|
514
509
|
await fs.access(p);
|
|
515
|
-
this.sendTo(obj.from, obj.command,
|
|
510
|
+
this.sendTo(obj.from, obj.command, p, obj.callback);
|
|
516
511
|
return;
|
|
517
512
|
} catch {
|
|
518
513
|
}
|
|
519
514
|
}
|
|
520
|
-
this.sendTo(obj.from, obj.command,
|
|
515
|
+
this.sendTo(obj.from, obj.command, "", obj.callback);
|
|
521
516
|
}
|
|
522
517
|
// ─── HTTP ────────────────────────────────────────────────────────────────
|
|
523
518
|
downloadUrl(urlRaw) {
|
|
@@ -553,20 +548,24 @@ class ScriptRestore extends utils.Adapter {
|
|
|
553
548
|
}
|
|
554
549
|
// ─── SFTP ────────────────────────────────────────────────────────────────
|
|
555
550
|
async handleTestSftp(obj) {
|
|
556
|
-
const msg = obj.message;
|
|
557
551
|
const sftp = new import_ssh2_sftp_client.default();
|
|
558
552
|
try {
|
|
559
|
-
await sftp.connect({
|
|
560
|
-
|
|
553
|
+
await sftp.connect({
|
|
554
|
+
host: this.config.sftpHost,
|
|
555
|
+
port: this.config.sftpPort || 22,
|
|
556
|
+
username: this.config.sftpUser,
|
|
557
|
+
password: this.config.sftpPassword
|
|
558
|
+
});
|
|
559
|
+
const list = await sftp.list(this.config.sftpPath || "/");
|
|
561
560
|
const count = list.filter((i) => i.type === "-").length;
|
|
562
561
|
this.sendTo(
|
|
563
562
|
obj.from,
|
|
564
563
|
obj.command,
|
|
565
|
-
|
|
564
|
+
`\u2713 Verbunden! ${count} Datei(en) in: ${this.config.sftpPath || "/"}`,
|
|
566
565
|
obj.callback
|
|
567
566
|
);
|
|
568
567
|
} catch (e) {
|
|
569
|
-
this.sendTo(obj.from, obj.command, {
|
|
568
|
+
this.sendTo(obj.from, obj.command, { error: e.message }, obj.callback);
|
|
570
569
|
} finally {
|
|
571
570
|
await sftp.end();
|
|
572
571
|
}
|
|
@@ -624,20 +623,22 @@ class ScriptRestore extends utils.Adapter {
|
|
|
624
623
|
}
|
|
625
624
|
// ─── WebDAV ──────────────────────────────────────────────────────────────
|
|
626
625
|
async handleTestWebdav(obj) {
|
|
627
|
-
const msg = obj.message;
|
|
628
626
|
try {
|
|
629
627
|
const { createClient: createWebdavClient } = await Promise.resolve().then(() => __toESM(require("webdav")));
|
|
630
|
-
const client = createWebdavClient(
|
|
631
|
-
|
|
628
|
+
const client = createWebdavClient(this.config.webdavUrl, {
|
|
629
|
+
username: this.config.webdavUser,
|
|
630
|
+
password: this.config.webdavPassword
|
|
631
|
+
});
|
|
632
|
+
const list = await client.getDirectoryContents(this.config.webdavPath || "/");
|
|
632
633
|
const arr = Array.isArray(list) ? list : list.data;
|
|
633
634
|
this.sendTo(
|
|
634
635
|
obj.from,
|
|
635
636
|
obj.command,
|
|
636
|
-
|
|
637
|
+
`\u2713 Verbunden! ${arr.length} Eintr\xE4ge in: ${this.config.webdavPath || "/"}`,
|
|
637
638
|
obj.callback
|
|
638
639
|
);
|
|
639
640
|
} catch (e) {
|
|
640
|
-
this.sendTo(obj.from, obj.command, {
|
|
641
|
+
this.sendTo(obj.from, obj.command, { error: e.message }, obj.callback);
|
|
641
642
|
}
|
|
642
643
|
}
|
|
643
644
|
async handleListWebdavFiles(obj) {
|