aaden-cli 1.2.28 → 1.2.30

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