aaden-cli 1.1.172 → 1.1.184
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/AadenDeploy/Aaden/351/241/271/347/233/256/347/224/250/346/210/267/346/263/250/345/206/214/350/241/250.docx +0 -0
- package/dist/index.js +657 -654
- package/dist/patch/202107211049resetAutoUpgradeFixAuthProblem10.sh +16 -17
- package/{patch/202204061112ResetCronTab19.sh → dist/patch/202204061112ResetCronTab18.sh} +19 -17
- package/index.js +656 -653
- package/package.json +1 -1
- package/patch/202107211049resetAutoUpgradeFixAuthProblem10.sh +16 -17
- package/patch/202204061112ResetCronTab18.sh +19 -0
package/index.js
CHANGED
|
@@ -1,653 +1,656 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const dayjs = require('dayjs')
|
|
4
|
-
const colors = require('colors')
|
|
5
|
-
const fs = require('fs')
|
|
6
|
-
const InnerKenTimeStampFormat = 'YYYYMMDDHHmmss'
|
|
7
|
-
const prompts = require('prompts')
|
|
8
|
-
const GlobalDeviceId = 'notset'
|
|
9
|
-
|
|
10
|
-
const {program} = require('commander')
|
|
11
|
-
const cli = require('./modules/cli-utils')
|
|
12
|
-
const {hillo} = require('hillo')
|
|
13
|
-
const {uploadFile} = require('./aws')
|
|
14
|
-
const version = require('./package.json').version
|
|
15
|
-
|
|
16
|
-
program.version(version)
|
|
17
|
-
|
|
18
|
-
hillo.initial('http://innerken.com/iplogger/')
|
|
19
|
-
|
|
20
|
-
console.log(
|
|
21
|
-
'*******************************************************\n' +
|
|
22
|
-
'Aaden CLI'.bgCyan + ' Version:' + version.bgRed + '\n' +
|
|
23
|
-
'Made with ' + '❤'.red + ' and InnerKen \n' +
|
|
24
|
-
'*******************************************************'
|
|
25
|
-
)
|
|
26
|
-
program
|
|
27
|
-
.option('-d, --debug', 'use Debug Out put')
|
|
28
|
-
program.command('update [channel]').action(update)
|
|
29
|
-
program
|
|
30
|
-
.command('install <deviceId>')
|
|
31
|
-
.action(install)
|
|
32
|
-
program.command('remove-all-data').action(removeAllData)
|
|
33
|
-
program.command('mount-tse').action(remountTSE)
|
|
34
|
-
program.command('upgrade').action(upgrade) // auto execute.
|
|
35
|
-
program.command('auto-upgrade').action(autoUpgrade) // auto execute.
|
|
36
|
-
program.command('load-new-version').action(loadNewVersion) // auto execute.
|
|
37
|
-
program.command('local-version').action(() => {
|
|
38
|
-
console.log('storage:' + getStorageBackendFileVersion())
|
|
39
|
-
})
|
|
40
|
-
program.command('backup [noUpload]').action(backup)
|
|
41
|
-
program.command('ngrok').action(startNgrokService)
|
|
42
|
-
program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
|
|
43
|
-
program.command('get-database').action(getDatabase)
|
|
44
|
-
program.command('get-newdatabase').action(getNewDatabase)
|
|
45
|
-
program.command('run <filePath>').action(run)
|
|
46
|
-
program.command('patch').action(patch)
|
|
47
|
-
program.command('check-tse').action(checkTse)
|
|
48
|
-
program.command('setup-tse').action(enableTSE)
|
|
49
|
-
program.command('check-version').action(getBackendVersionOffline)
|
|
50
|
-
program.command('add-dish').action(addDish)
|
|
51
|
-
program.command('full-update').action(fullUpdate)
|
|
52
|
-
program.command('return-terminal').action(returnTerminal)
|
|
53
|
-
program.command('db').action(enterDatabase)
|
|
54
|
-
program.command('printer-test').action(testPrinter)
|
|
55
|
-
program.command('log').action(log)
|
|
56
|
-
program.command('enable-mile-pay').action(enableMilePay)
|
|
57
|
-
program.command('start-mile-pay').action(startService)
|
|
58
|
-
program.command('convert-database').action(convertDataBaseCharset)
|
|
59
|
-
program.command('mile-pay-option')
|
|
60
|
-
.option('-k, --access-key <accessKey>')
|
|
61
|
-
.option('-s, --access-secret <accessSecret>')
|
|
62
|
-
.option('-m, --merchant-no <merchantNo>')
|
|
63
|
-
.action(milePayOption)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (program.debug) {
|
|
67
|
-
debugInfo()
|
|
68
|
-
console.log(process.argv)
|
|
69
|
-
}
|
|
70
|
-
basicInfo()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
console.log('
|
|
80
|
-
console.log('
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{title: '
|
|
93
|
-
{title: '
|
|
94
|
-
{title: '
|
|
95
|
-
{title: '
|
|
96
|
-
{title: '
|
|
97
|
-
{title: '
|
|
98
|
-
{title: '
|
|
99
|
-
{title: '
|
|
100
|
-
{title: '
|
|
101
|
-
{
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
'aaden-cli
|
|
223
|
-
'aaden-cli
|
|
224
|
-
'aaden-cli
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
'cd
|
|
247
|
-
'sudo
|
|
248
|
-
'
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
'
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
'
|
|
281
|
-
'sudo mkdir -p backups
|
|
282
|
-
'sudo chmod 777 backups
|
|
283
|
-
'
|
|
284
|
-
|
|
285
|
-
'cd',
|
|
286
|
-
|
|
287
|
-
'
|
|
288
|
-
'
|
|
289
|
-
'sudo
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
console.log('
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
if (
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
frontVersion =
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
'
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
'
|
|
590
|
-
'
|
|
591
|
-
'
|
|
592
|
-
'
|
|
593
|
-
'wget https://innerken.com/biomace/
|
|
594
|
-
'
|
|
595
|
-
'
|
|
596
|
-
'
|
|
597
|
-
'
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
'
|
|
614
|
-
'
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const dayjs = require('dayjs')
|
|
4
|
+
const colors = require('colors')
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const InnerKenTimeStampFormat = 'YYYYMMDDHHmmss'
|
|
7
|
+
const prompts = require('prompts')
|
|
8
|
+
const GlobalDeviceId = 'notset'
|
|
9
|
+
|
|
10
|
+
const {program} = require('commander')
|
|
11
|
+
const cli = require('./modules/cli-utils')
|
|
12
|
+
const {hillo} = require('hillo')
|
|
13
|
+
const {uploadFile} = require('./aws')
|
|
14
|
+
const version = require('./package.json').version
|
|
15
|
+
|
|
16
|
+
program.version(version)
|
|
17
|
+
|
|
18
|
+
hillo.initial('http://innerken.com/iplogger/')
|
|
19
|
+
|
|
20
|
+
console.log(
|
|
21
|
+
'*******************************************************\n' +
|
|
22
|
+
'Aaden CLI'.bgCyan + ' Version:' + version.bgRed + '\n' +
|
|
23
|
+
'Made with ' + '❤'.red + ' and InnerKen \n' +
|
|
24
|
+
'*******************************************************'
|
|
25
|
+
)
|
|
26
|
+
program
|
|
27
|
+
.option('-d, --debug', 'use Debug Out put')
|
|
28
|
+
program.command('update [channel]').action(update)
|
|
29
|
+
program
|
|
30
|
+
.command('install <deviceId>')
|
|
31
|
+
.action(install)
|
|
32
|
+
program.command('remove-all-data').action(removeAllData)
|
|
33
|
+
program.command('mount-tse').action(remountTSE)
|
|
34
|
+
program.command('upgrade').action(upgrade) // auto execute.
|
|
35
|
+
program.command('auto-upgrade').action(autoUpgrade) // auto execute.
|
|
36
|
+
program.command('load-new-version').action(loadNewVersion) // auto execute.
|
|
37
|
+
program.command('local-version').action(() => {
|
|
38
|
+
console.log('storage:' + getStorageBackendFileVersion())
|
|
39
|
+
})
|
|
40
|
+
program.command('backup [noUpload]').action(backup)
|
|
41
|
+
program.command('ngrok').action(startNgrokService)
|
|
42
|
+
program.command('update-ngrok-config <deviceId>').action(updateNgrokConfig)
|
|
43
|
+
program.command('get-database').action(getDatabase)
|
|
44
|
+
program.command('get-newdatabase').action(getNewDatabase)
|
|
45
|
+
program.command('run <filePath>').action(run)
|
|
46
|
+
program.command('patch').action(patch)
|
|
47
|
+
program.command('check-tse').action(checkTse)
|
|
48
|
+
program.command('setup-tse').action(enableTSE)
|
|
49
|
+
program.command('check-version').action(getBackendVersionOffline)
|
|
50
|
+
program.command('add-dish').action(addDish)
|
|
51
|
+
program.command('full-update').action(fullUpdate)
|
|
52
|
+
program.command('return-terminal').action(returnTerminal)
|
|
53
|
+
program.command('db').action(enterDatabase)
|
|
54
|
+
program.command('printer-test').action(testPrinter)
|
|
55
|
+
program.command('log').action(log)
|
|
56
|
+
program.command('enable-mile-pay').action(enableMilePay)
|
|
57
|
+
program.command('start-mile-pay').action(startService)
|
|
58
|
+
program.command('convert-database').action(convertDataBaseCharset)
|
|
59
|
+
program.command('mile-pay-option')
|
|
60
|
+
.option('-k, --access-key <accessKey>')
|
|
61
|
+
.option('-s, --access-secret <accessSecret>')
|
|
62
|
+
.option('-m, --merchant-no <merchantNo>')
|
|
63
|
+
.action(milePayOption)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
if (program.debug) {
|
|
67
|
+
debugInfo()
|
|
68
|
+
console.log(process.argv)
|
|
69
|
+
}
|
|
70
|
+
basicInfo()
|
|
71
|
+
|
|
72
|
+
if (process.argv[2] === undefined) {
|
|
73
|
+
selectOption()
|
|
74
|
+
} else {
|
|
75
|
+
program.parse(process.argv)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function basicInfo () {
|
|
79
|
+
console.log('本设备DeviceId:' + getMyDeviceId().toString().bgYellow)
|
|
80
|
+
console.log('本设备当前后台版本:' + getBackendVersionOffline().bgYellow)
|
|
81
|
+
console.log('开始执行命令:' + process.argv.join(' ').cyan)
|
|
82
|
+
console.log('...')
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function selectOption () {
|
|
86
|
+
const select = await prompts({
|
|
87
|
+
type: 'autocomplete',
|
|
88
|
+
name: 'option',
|
|
89
|
+
message: 'Select what you want to do next? ' +
|
|
90
|
+
'请选择下一步要进行的操作',
|
|
91
|
+
choices: [
|
|
92
|
+
{title: 'Upgrade Aaden-cli 手动更新Aaden-cli到最新版本', description: '', value: 'upgrade'},
|
|
93
|
+
{title: 'Backup all backend data 备份后端数据库数据', description: '操作数据库数据前请先备份', value: 'backup'},
|
|
94
|
+
{title: 'Full update 全更新', description: '更新前请先备份', value: 'full-update'},
|
|
95
|
+
{title: 'Check Tse 检查Tse设备', description: '', value: 'check-tse'},
|
|
96
|
+
{title: 'Start Ngrok 打开Ngrok服务', description: '', value: 'ngrok'},
|
|
97
|
+
{title: 'Install Aaden Kasse 安装最新版Aaden Kasse', value: `install ${GlobalDeviceId}`},
|
|
98
|
+
{title: 'Add Dishes 执行上菜脚本app.py', description: '-p ImgPath -i DishCSVPath -a AttrPath', value: 'add-dish'},
|
|
99
|
+
{title: 'Check version 检查后端版本号', description: '', value: 'check-version'},
|
|
100
|
+
{title: 'Patch 打补丁', description: '请勿手动执行', value: 'patch'},
|
|
101
|
+
{title: 'Remove all data 删除所有数据', description: '谨慎操作'.red, value: 'remove-all-data'},
|
|
102
|
+
{title: 'Setup Tse 安装Tse', description: '谨慎操作'.red + ' 每个设备只能安装一次TSE', value: 'setup-tse'},
|
|
103
|
+
{
|
|
104
|
+
title: 'Mount Tse 永久挂载Tse设备', description: '谨慎操作'.red + ' ' +
|
|
105
|
+
'进行此操作会导致TSE重新自检,使用前请先检查是否已经正确插入Tse设备(Tse设备是否正常亮灯)', value: 'mount-tse'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
title: 'Update Ngrok 更新Ngrok配置',
|
|
109
|
+
description: '输入本设备的DeviceId,更新Ngrok配置',
|
|
110
|
+
value: `update-ngrok-config ${GlobalDeviceId}`
|
|
111
|
+
},
|
|
112
|
+
{title: 'Exit 退出', description: 'return to terminal', value: 'return-terminal'}
|
|
113
|
+
],
|
|
114
|
+
initial: 1
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
if (select.option) {
|
|
118
|
+
console.log(select.option)
|
|
119
|
+
process.argv = [...process.argv, ...select.option.split(' ')]
|
|
120
|
+
program.parse(process.argv)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function log(){
|
|
125
|
+
cli.executeInShell(['tail -f /var/www/html/Resource/failLog.log'])
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function enterDatabase () {
|
|
129
|
+
const command = [
|
|
130
|
+
`mysql -uaaden -pInnerken322. -Daaden`
|
|
131
|
+
]
|
|
132
|
+
cli.executeInShell(command, program.debug)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function testPrinter () {
|
|
136
|
+
const command = [
|
|
137
|
+
`wget localhost/PHP/Complex.php?op=testAllPrinter`
|
|
138
|
+
]
|
|
139
|
+
cli.executeInShell(command, program.debug)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function getDatabase () {
|
|
143
|
+
const command = [
|
|
144
|
+
`mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString> transfer.sql`,
|
|
145
|
+
'sudo cp transfer.sql /var/www/html'
|
|
146
|
+
]
|
|
147
|
+
cli.executeInShell(command, program.debug)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getNewDatabase () {
|
|
151
|
+
const command = [
|
|
152
|
+
`mysqldump -uaaden -pInnerken322. --databases aaden --tables Attribute AttributeGroup BonTemplate Category_AttributeGroup DishWithName Dish_AttributeGroup Dishes DishesString DishesCategory DishesCategoryString DishesCategoryType DishesCategoryTypeString ConsumeType_Dishes_Free ConsumeType_Dishes_Show> transfer.sql`,
|
|
153
|
+
'sudo cp transfer.sql /var/www/html'
|
|
154
|
+
]
|
|
155
|
+
cli.executeInShell(command, program.debug)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function debugInfo () {
|
|
159
|
+
console.log(program.opts())
|
|
160
|
+
console.log('')
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function checkTse () {
|
|
164
|
+
cli.executeInShell(['journalctl -f -u aaden-tse.service'], program.debug)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function remountTSE () {
|
|
168
|
+
const files = ['AadenDeploy/mountTSE.sh']
|
|
169
|
+
runMultiple(files)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function enableTSE () {
|
|
173
|
+
const files = ['AadenDeploy/mountTSE.sh', 'AadenDeploy/Utils/tseReady.sh']
|
|
174
|
+
runMultiple(files)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function patch () {
|
|
178
|
+
const configRoot = '/etc/aaden/config'
|
|
179
|
+
const rootPath = __dirname + '/patch'
|
|
180
|
+
const patchRecordFilePath = configRoot + '/patchLog.json'
|
|
181
|
+
const pathList = fs.readdirSync(rootPath)
|
|
182
|
+
|
|
183
|
+
let readyList = []
|
|
184
|
+
try {
|
|
185
|
+
readyList = JSON.parse(fs.readFileSync(patchRecordFilePath))
|
|
186
|
+
} catch (e) {
|
|
187
|
+
console.error(e)
|
|
188
|
+
console.log('Create Patch Log File in :-->>' + patchRecordFilePath)
|
|
189
|
+
fs.openSync(patchRecordFilePath, 'w+')
|
|
190
|
+
}
|
|
191
|
+
const runList = pathList.map(p => 'patch/' + p).filter(p => {
|
|
192
|
+
return !readyList.includes(p)
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
if (runList.length > 0) {
|
|
196
|
+
runMultiple(runList)
|
|
197
|
+
readyList = readyList.concat(runList)
|
|
198
|
+
fs.writeFileSync(patchRecordFilePath, JSON.stringify(readyList))
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
async function runMultiple (files) {
|
|
204
|
+
const command = files.reduce((arr, f) => {
|
|
205
|
+
arr.push(...getPrivilegeCMD(f))
|
|
206
|
+
arr.push('./' + f)
|
|
207
|
+
return arr
|
|
208
|
+
}, [])
|
|
209
|
+
cli.executeInShell(command, program.debug)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async function run (filePath) {
|
|
213
|
+
const command = [
|
|
214
|
+
...getPrivilegeCMD(filePath),
|
|
215
|
+
'./' + filePath
|
|
216
|
+
]
|
|
217
|
+
cli.executeInShell(command, program.debug)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function fullUpdate () {
|
|
221
|
+
const command = [
|
|
222
|
+
'aaden-cli backup',
|
|
223
|
+
'sudo npm update aaden-cli -g',
|
|
224
|
+
'aaden-cli upgrade',
|
|
225
|
+
'aaden-cli update',
|
|
226
|
+
'aaden-cli backup'
|
|
227
|
+
]
|
|
228
|
+
cli.executeInShell(command, program.debug)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function updateNgrokConfig (deviceId) {
|
|
232
|
+
console.log(deviceId)
|
|
233
|
+
if (!deviceId || deviceId === 'notset') {
|
|
234
|
+
const getDeviceId = await prompts({
|
|
235
|
+
type: 'number',
|
|
236
|
+
name: 'id',
|
|
237
|
+
message: '请输入要配置ngrok的设备Id:'
|
|
238
|
+
})
|
|
239
|
+
deviceId = getDeviceId.id
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
console.log('Start to config Ngrok service')
|
|
243
|
+
console.log('开始配置' + deviceId + '设备的Ngrok服务')
|
|
244
|
+
|
|
245
|
+
const command = [
|
|
246
|
+
'cd /etc',
|
|
247
|
+
'sudo mkdir -p aaden',
|
|
248
|
+
'cd aaden',
|
|
249
|
+
'sudo touch ngrok-config.yml',
|
|
250
|
+
'sudo chmod 777 ngrok-config.yml',
|
|
251
|
+
`echo "
|
|
252
|
+
server_addr: ngrok.aaden.io:4443
|
|
253
|
+
trust_host_root_certs: false
|
|
254
|
+
tunnels:
|
|
255
|
+
web:
|
|
256
|
+
proto:
|
|
257
|
+
http: 80
|
|
258
|
+
subdomain: ik${String(deviceId).padStart(4, '0')}
|
|
259
|
+
ssh:
|
|
260
|
+
proto:
|
|
261
|
+
tcp: 22
|
|
262
|
+
remote_port: ${parseInt(deviceId) + 10000}" > ngrok-config.yml`
|
|
263
|
+
]
|
|
264
|
+
cli.executeInShell(command, program.debug)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
async function startNgrokService () {
|
|
268
|
+
const command = [
|
|
269
|
+
...getPrivilegeCMD('AadenDeploy/ngrok/ngrok'),
|
|
270
|
+
'cd AadenDeploy/ngrok',
|
|
271
|
+
'./ngrok -config=/etc/aaden/ngrok-config.yml start web ssh'
|
|
272
|
+
]
|
|
273
|
+
cli.executeInShell(command, program.debug)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
async function backup (noUpload = false) {
|
|
277
|
+
const timeStamp = dayjs().format(InnerKenTimeStampFormat)
|
|
278
|
+
const backupHome = 'appendBackup'
|
|
279
|
+
const command = [
|
|
280
|
+
'cd',
|
|
281
|
+
'sudo mkdir -p backups',
|
|
282
|
+
'sudo chmod 777 backups',
|
|
283
|
+
'sudo mkdir -p backups/' + timeStamp,
|
|
284
|
+
'sudo chmod 777 backups/' + timeStamp,
|
|
285
|
+
'cd backups/' + timeStamp,
|
|
286
|
+
`mysqldump aaden -uaaden -pInnerken322. -c> ${timeStamp}@cli.sql`,
|
|
287
|
+
'cd',
|
|
288
|
+
'sudo mkdir -p ' + backupHome,
|
|
289
|
+
'sudo chmod 777 ' + backupHome,
|
|
290
|
+
'cd ' + backupHome,
|
|
291
|
+
'sudo rsync -av --delete /var/www/html/ .'
|
|
292
|
+
]
|
|
293
|
+
|
|
294
|
+
cli.executeInShell(command, program.debug)
|
|
295
|
+
if(!noUpload){
|
|
296
|
+
setTimeout(() => {
|
|
297
|
+
const homedir = require('os').homedir()
|
|
298
|
+
const fileName = [homedir, 'backups', timeStamp, `${timeStamp}@cli.sql`].join('/')
|
|
299
|
+
uploadFile(fileName)
|
|
300
|
+
}, 8000)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
async function updateCheck (channel = '') {
|
|
308
|
+
const result = {
|
|
309
|
+
version: true,
|
|
310
|
+
file: true
|
|
311
|
+
}
|
|
312
|
+
console.log('正在检查是否有必要进行后台更新..'.bgYellow)
|
|
313
|
+
const localVersion = getBackendVersionOffline()
|
|
314
|
+
console.log('本机版本:' + localVersion.bgRed)
|
|
315
|
+
const remoteVersion = (await hillo.get('https://aaden-backend.s3.eu-central-1.amazonaws.com/raw/package.json')).version
|
|
316
|
+
console.log('服务器最新版本:' + remoteVersion.bgMagenta)
|
|
317
|
+
const localStorageVersion = getStorageBackendFileVersion()
|
|
318
|
+
console.log('本地最新文件版本' + localStorageVersion)
|
|
319
|
+
if (remoteVersion === localVersion) {
|
|
320
|
+
console.log('你已经在使用最新版本,无需更新'.red)
|
|
321
|
+
result.file = true
|
|
322
|
+
} else {
|
|
323
|
+
result.version = false
|
|
324
|
+
if (remoteVersion === localStorageVersion) {
|
|
325
|
+
console.log('文件已经就绪,可以直接更新:' + remoteVersion + '------>' + localVersion.bgRed)
|
|
326
|
+
|
|
327
|
+
} else {
|
|
328
|
+
console.log('缓存文件比较老,需要进行更新:' + remoteVersion + '------>' + localVersion.bgRed)
|
|
329
|
+
result.file = false
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
}
|
|
333
|
+
return result
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
async function convertDataBaseCharset () {
|
|
337
|
+
try {
|
|
338
|
+
const result = await updateCheck()
|
|
339
|
+
if (result.version) {
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
if (!result.file) {
|
|
343
|
+
const command = [
|
|
344
|
+
...getPrivilegeCMD('AadenDeploy/Utils/updateDataBaseCharSet.sh'),
|
|
345
|
+
'cd AadenDeploy/Utils',
|
|
346
|
+
`./updateDataBaseCharSet.sh`
|
|
347
|
+
]
|
|
348
|
+
cli.executeInShell(command, program.debug)
|
|
349
|
+
} else {
|
|
350
|
+
console.log('已经转换完成')
|
|
351
|
+
}
|
|
352
|
+
} catch (e) {
|
|
353
|
+
console.error(e)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
async function loadNewVersion () {
|
|
360
|
+
try {
|
|
361
|
+
const result = await updateCheck()
|
|
362
|
+
if (result.version) {
|
|
363
|
+
return
|
|
364
|
+
}
|
|
365
|
+
if (!result.file) {
|
|
366
|
+
const command = [
|
|
367
|
+
...getPrivilegeCMD('AadenDeploy/files/getFile.sh'),
|
|
368
|
+
'cd AadenDeploy/files',
|
|
369
|
+
`./getFile.sh`
|
|
370
|
+
]
|
|
371
|
+
cli.executeInShell(command, program.debug)
|
|
372
|
+
} else {
|
|
373
|
+
console.log('后端文件已经是最新')
|
|
374
|
+
}
|
|
375
|
+
} catch (e) {
|
|
376
|
+
console.error(e)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
async function update (channel = '') {
|
|
382
|
+
if (channel !== '') {
|
|
383
|
+
channel += '/'
|
|
384
|
+
}
|
|
385
|
+
try {
|
|
386
|
+
const result = await updateCheck(channel)
|
|
387
|
+
const command = []
|
|
388
|
+
if (result.version) {
|
|
389
|
+
return
|
|
390
|
+
}
|
|
391
|
+
if (!result.file) {
|
|
392
|
+
command.push('aaden-cli load-new-version')
|
|
393
|
+
}
|
|
394
|
+
command.push(...[
|
|
395
|
+
...getPrivilegeCMD('AadenDeploy/update.sh'),
|
|
396
|
+
'cd AadenDeploy',
|
|
397
|
+
`./update.sh ${channel}`
|
|
398
|
+
])
|
|
399
|
+
cli.executeInShell(command, program.debug)
|
|
400
|
+
} catch (e) {
|
|
401
|
+
console.error(e)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
async function install (deviceId) {
|
|
407
|
+
const channel = 'stable'
|
|
408
|
+
const installApp = true
|
|
409
|
+
if (!deviceId || deviceId === 'notset') {
|
|
410
|
+
const getId = await prompts({
|
|
411
|
+
type: 'number',
|
|
412
|
+
name: 'deviceId',
|
|
413
|
+
message: '请输入需要安装的设备号:'
|
|
414
|
+
}
|
|
415
|
+
)
|
|
416
|
+
deviceId = getId.deviceId
|
|
417
|
+
}
|
|
418
|
+
if (deviceId) {
|
|
419
|
+
const command = [
|
|
420
|
+
...getPrivilegeCMD('AadenDeploy/aadensetup.sh'),
|
|
421
|
+
'cd AadenDeploy',
|
|
422
|
+
`./aadensetup.sh ${deviceId} ${channel}` + (installApp ? ' b' : '')
|
|
423
|
+
]
|
|
424
|
+
cli.executeInShell(command, program.debug)
|
|
425
|
+
} else {
|
|
426
|
+
console.log('Device Id is invalid.')
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function getMyDeviceId () {
|
|
431
|
+
const loadIniFile = require('read-ini-file')
|
|
432
|
+
try {
|
|
433
|
+
return loadIniFile.sync('/var/www/html/Resource/config/config.ini').Device.DeviceId
|
|
434
|
+
} catch (e) {
|
|
435
|
+
return -1
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
async function autoUpgrade () {
|
|
441
|
+
upgrade()
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function upgrade () {
|
|
445
|
+
const command = [
|
|
446
|
+
...getPrivilegeCMD('AadenDeploy/upgrade.sh'),
|
|
447
|
+
'cd AadenDeploy',
|
|
448
|
+
`./upgrade.sh`
|
|
449
|
+
]
|
|
450
|
+
cli.executeInShell(command, program.debug)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function getStorageBackendFileVersion () {
|
|
454
|
+
const jsonFilePath = '/etc/aaden/updateFiles/backendFiles/package.json'
|
|
455
|
+
let frontVersion
|
|
456
|
+
try {
|
|
457
|
+
frontVersion = require(jsonFilePath).version
|
|
458
|
+
} catch (e) {
|
|
459
|
+
console.log(e)
|
|
460
|
+
frontVersion = '0.0.0'
|
|
461
|
+
}
|
|
462
|
+
return frontVersion
|
|
463
|
+
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function getBackendVersionOffline () {
|
|
467
|
+
const jsonFilePath = '/var/www/html/package.json'
|
|
468
|
+
let frontVersion
|
|
469
|
+
try {
|
|
470
|
+
frontVersion = require(jsonFilePath).version
|
|
471
|
+
} catch (e) {
|
|
472
|
+
frontVersion = '0.0.0'
|
|
473
|
+
}
|
|
474
|
+
return frontVersion
|
|
475
|
+
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async function addDish () {
|
|
479
|
+
console.log('添加菜品需要以下菜品信息:')
|
|
480
|
+
const getDishPath = await prompts({
|
|
481
|
+
type: 'text',
|
|
482
|
+
name: 'dishPath',
|
|
483
|
+
message: '请输入菜品的csv路径:'
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
const dishPath = getDishPath.dishPath
|
|
487
|
+
const getImgPath = await prompts({
|
|
488
|
+
type: 'text',
|
|
489
|
+
name: 'imgPath',
|
|
490
|
+
message: '请输入菜品的图片路径:'
|
|
491
|
+
}
|
|
492
|
+
)
|
|
493
|
+
const imgPath = getImgPath.imgPath
|
|
494
|
+
const judge = await prompts({
|
|
495
|
+
type: 'toggle',
|
|
496
|
+
name: 'add',
|
|
497
|
+
message: '是否有需要添加的菜品属性:',
|
|
498
|
+
initial: false,
|
|
499
|
+
active: 'yes',
|
|
500
|
+
inactive: 'no'
|
|
501
|
+
})
|
|
502
|
+
let attrPath = undefined
|
|
503
|
+
if (judge.add) {
|
|
504
|
+
const getAttrPath = await prompts({
|
|
505
|
+
type: 'text',
|
|
506
|
+
name: 'attrPath',
|
|
507
|
+
message: '请输入菜品的属性路径:'
|
|
508
|
+
}
|
|
509
|
+
)
|
|
510
|
+
attrPath = getAttrPath.attrPath
|
|
511
|
+
}
|
|
512
|
+
console.log('Adding dishes now...')
|
|
513
|
+
if (dishPath !== undefined && imgPath !== undefined) {
|
|
514
|
+
if (attrPath !== undefined) {
|
|
515
|
+
const command = [
|
|
516
|
+
...getPrivilegeCMD('AadenDeploy/add_dish'),
|
|
517
|
+
'cd AadenDeploy/dish_app',
|
|
518
|
+
`sudo python3 app.py -i ${dishPath} -p ${imgPath} -a ${attrPath}`
|
|
519
|
+
]
|
|
520
|
+
cli.executeInShell(command, program.debug)
|
|
521
|
+
console.log('Add Dishes with Attribute success!')
|
|
522
|
+
} else {
|
|
523
|
+
const command = [
|
|
524
|
+
...getPrivilegeCMD('AadenDeploy/add_dish'),
|
|
525
|
+
'cd AadenDeploy/dish_app',
|
|
526
|
+
`sudo python3 app.py -i ${dishPath} -p ${imgPath}`
|
|
527
|
+
]
|
|
528
|
+
cli.executeInShell(command, program.debug)
|
|
529
|
+
console.log('Add Dishes without Attribute success!')
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
console.log('DishPath or ImgPath is required but not valid')
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function findMe () {
|
|
537
|
+
return __dirname
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function goIntoRootDir () {
|
|
541
|
+
return 'cd ' + findMe() + '&& cd ..'
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
async function removeAllData () {
|
|
545
|
+
const start = await prompts({
|
|
546
|
+
type: 'toggle',
|
|
547
|
+
name: 'ok',
|
|
548
|
+
message: `Are your sure you want to remove all data of this customer?
|
|
549
|
+
你确定你要删除这个用户的所有数据吗?
|
|
550
|
+
このユーザーのすべてのデータを削除してもよろしいですか?
|
|
551
|
+
Möchten Sie wirklich alle Daten dieses Benutzers löschen?
|
|
552
|
+
이 사용자의 모든 데이터를 삭제 하시겠습니까?
|
|
553
|
+
Tu Visne vero hanc user notitia omnes delere?
|
|
554
|
+
Êtes-vous sûr de vouloir supprimer toutes les données de cet utilisateur?
|
|
555
|
+
确定?Are you Sure?
|
|
556
|
+
`,
|
|
557
|
+
initial: false,
|
|
558
|
+
active: 'yes(我确定)',
|
|
559
|
+
inactive: 'no(不,我后悔了)'
|
|
560
|
+
})
|
|
561
|
+
if (!start.ok) {
|
|
562
|
+
return
|
|
563
|
+
}
|
|
564
|
+
console.log('你的行为将会被记录在公司服务器上,请谨慎操作。'.bgRed)
|
|
565
|
+
|
|
566
|
+
const response = await prompts({
|
|
567
|
+
type: 'password',
|
|
568
|
+
name: 'value',
|
|
569
|
+
message: '请输入易能科技人员认证密码:'
|
|
570
|
+
})
|
|
571
|
+
const correctPassword = ['yjn.2081214', '728339jhq']
|
|
572
|
+
if (!correctPassword.includes(response.value)) {
|
|
573
|
+
console.log('>密码错误,未认证用户。'.bgYellow)
|
|
574
|
+
return
|
|
575
|
+
}
|
|
576
|
+
console.log('欢迎进入新版AadenCli系统,您的身份已经获得认证'.bgYellow)
|
|
577
|
+
console.log('>现在开始清除用户数据...')
|
|
578
|
+
const command = [
|
|
579
|
+
'aaden-cli backup',
|
|
580
|
+
goIntoRootDir(),
|
|
581
|
+
'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
|
|
582
|
+
'mysql -u aaden -p < AadenDeploy/purge.sql'
|
|
583
|
+
]
|
|
584
|
+
cli.executeInShell(command, program.debug)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async function enableMilePay () {
|
|
588
|
+
cli.executeInShell([
|
|
589
|
+
'cd /home/aaden',
|
|
590
|
+
'mkdir biomace',
|
|
591
|
+
'cd biomace',
|
|
592
|
+
'wget https://innerken.com/biomace/biomace.sh',
|
|
593
|
+
'wget https://innerken.com/biomace/logback-spring-biomace.xml',
|
|
594
|
+
'wget https://innerken.com/biomace/application.yml',
|
|
595
|
+
'axel -n 6 https://innerken.com/biomace/biomace-0.0.1-SNAPSHOT.jar',
|
|
596
|
+
'wget https://innerken.com/biomace/mile-pay-pay-method.sql',
|
|
597
|
+
'mkdir log',
|
|
598
|
+
'cd /etc/systemd/system',
|
|
599
|
+
'sudo wget https://innerken.com/biomace/biomace.service',
|
|
600
|
+
'aaden-cli start-mile-pay'
|
|
601
|
+
], program.debug)
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
async function startService () {
|
|
605
|
+
const deviceId = getMyDeviceId()
|
|
606
|
+
if (deviceId === -1) return
|
|
607
|
+
const filePath = '/home/aaden/biomace/application.yml'
|
|
608
|
+
const res = fs.readFileSync(filePath).toString()
|
|
609
|
+
const out = res.replace('identifier: IK0001', 'identifier: IK' + deviceId)
|
|
610
|
+
fs.writeFileSync(filePath, out)
|
|
611
|
+
|
|
612
|
+
cli.executeInShell([
|
|
613
|
+
'sudo systemctl start biomace.service',
|
|
614
|
+
'sudo systemctl enable biomace.service',
|
|
615
|
+
'sudo service biomace start',
|
|
616
|
+
'echo "请输入数据库密码(和开机密码,sudo密码相同)"',
|
|
617
|
+
'mysql -uaaden -Daaden -p < /home/aaden/biomace/mile-pay-pay-method.sql'
|
|
618
|
+
], program.debug)
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
async function milePayOption (options) {
|
|
622
|
+
const operations = {
|
|
623
|
+
accessKey: (accessKey, res) => res.replace(/access-key: +[a-zA-Z0-9]+/g, 'access-key: ' + accessKey),
|
|
624
|
+
accessSecret: (accessSecret, res) => res.replace(/access-secret: +[a-zA-Z0-9]+/g, 'access-secret: ' + accessSecret),
|
|
625
|
+
merchantNo: (merchantNo, res) => res.replace(/merchant-no: +\d+/g, 'merchant-no: ' + merchantNo)
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
Object.entries(operations).forEach(entry => {
|
|
629
|
+
const [key, value] = entry
|
|
630
|
+
const newValue = options[key]
|
|
631
|
+
if (newValue !== undefined) {
|
|
632
|
+
editMilePaySettings(newValue, value)
|
|
633
|
+
console.log(`${key} 已变更为 ${newValue}`)
|
|
634
|
+
}
|
|
635
|
+
})
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function editMilePaySettings (newValue, transform) {
|
|
639
|
+
const filePath = '/home/aaden/biomace/application.yml'
|
|
640
|
+
const res = fs.readFileSync(filePath).toString()
|
|
641
|
+
const out = transform(newValue, res)
|
|
642
|
+
fs.writeFileSync(filePath, out)
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function returnTerminal () {
|
|
646
|
+
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function getPrivilegeCMD (path, pri = '+x', relativePath = true) {
|
|
650
|
+
const command = []
|
|
651
|
+
if (relativePath) {
|
|
652
|
+
command.push(goIntoRootDir())
|
|
653
|
+
}
|
|
654
|
+
command.push(`echo "Innerken322." | sudo -S chmod ${pri} ${path}`)
|
|
655
|
+
return command
|
|
656
|
+
}
|