aaden-cli 1.6.77 → 1.6.79
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/Utils/sendTeaMakerTaskService.sh +25 -0
- package/AadenDeploy/Utils/updateAadenTse.sh +130 -0
- package/AadenDeploy/purge.sql +2 -0
- package/dist/index.js +25 -15
- package/index.js +6 -0
- package/modules/firebase.js +18 -14
- package/package.json +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
ServiceFileName=/etc/systemd/system/aaden-tee-maker.service
|
|
4
|
+
|
|
5
|
+
sudo touch $ServiceFileName
|
|
6
|
+
sudo chmod 777 $ServiceFileName
|
|
7
|
+
echo -e "
|
|
8
|
+
[Unit]
|
|
9
|
+
Description=Tee Maker Service For Aaden
|
|
10
|
+
|
|
11
|
+
[Service]
|
|
12
|
+
Type=simple
|
|
13
|
+
Restart=always
|
|
14
|
+
RestartSec=1
|
|
15
|
+
User=root
|
|
16
|
+
ExecStart=/usr/bin/php /var/www/html/PHP/autoSendTeaMakerTask.php
|
|
17
|
+
|
|
18
|
+
[Install]
|
|
19
|
+
WantedBy=multi-user.target
|
|
20
|
+
" > $ServiceFileName
|
|
21
|
+
|
|
22
|
+
sudo systemctl start aaden-tee-maker.service
|
|
23
|
+
sudo systemctl enable aaden-tee-maker.service
|
|
24
|
+
echo 'tee maker task auto send start'
|
|
25
|
+
sudo service aaden-tee-maker start
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
deviceId=$1
|
|
4
|
+
targetVersion=$2
|
|
5
|
+
tseAdapterDownloadUrl=$3
|
|
6
|
+
|
|
7
|
+
function sendDeviceLog() {
|
|
8
|
+
_deviceId=$1
|
|
9
|
+
_content=$2
|
|
10
|
+
echo "<<< create log: $_content"
|
|
11
|
+
curl --location 'https://cloud-v2.aaden.io/deviceLog/createEvent' \
|
|
12
|
+
--header 'Content-Type: application/json' \
|
|
13
|
+
--data "{
|
|
14
|
+
\"deviceId\": \"$_deviceId\",
|
|
15
|
+
\"content\": \"$_content\",
|
|
16
|
+
\"type\": \"维护状态更新\",
|
|
17
|
+
\"appendUrl\": \"\",
|
|
18
|
+
\"operator\": \"updateAadenTse.sh\"
|
|
19
|
+
}"
|
|
20
|
+
return 0
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# get tse version via php
|
|
24
|
+
tseVersionCommand=$(cat <<- 'PHP'
|
|
25
|
+
$ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
|
|
26
|
+
$tseUrl = $ini['TSE']['TseHost'] ?? 'http://localhost:8014';
|
|
27
|
+
$versionResp = file_get_contents("$tseUrl/adapterVersion");
|
|
28
|
+
$version = json_decode($versionResp, true)['major'] ?? 'null';
|
|
29
|
+
echo $version;
|
|
30
|
+
PHP
|
|
31
|
+
)
|
|
32
|
+
tseVersion=`php -r "$tseVersionCommand"`
|
|
33
|
+
|
|
34
|
+
# exit if no need to update
|
|
35
|
+
if [ $tseVersion != 'null' ]; then
|
|
36
|
+
if [ $targetVersion -le $tseVersion ]; then
|
|
37
|
+
sendDeviceLog $deviceId "no need to update tse, current version is ($tseVersion)"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
# get os version via php
|
|
43
|
+
osCommand=$(cat <<- 'PHP'
|
|
44
|
+
$osVersion = shell_exec('cat /proc/version');
|
|
45
|
+
if (strpos($osVersion, 'microsoft') !== false || strpos($osVersion, 'WSL2') !== false) {
|
|
46
|
+
$os = 'windows';
|
|
47
|
+
} else {
|
|
48
|
+
$os = 'linux';
|
|
49
|
+
}
|
|
50
|
+
echo $os;
|
|
51
|
+
PHP
|
|
52
|
+
)
|
|
53
|
+
os=`php -r "$osCommand"`
|
|
54
|
+
|
|
55
|
+
sendDeviceLog $deviceId "user os is ($os)"
|
|
56
|
+
|
|
57
|
+
# download tse adapter
|
|
58
|
+
wget -O latest-tse-adapter.jar "$tseAdapterDownloadUrl"
|
|
59
|
+
|
|
60
|
+
if [ $os == 'windows' ]; then
|
|
61
|
+
# find tse dir
|
|
62
|
+
tseDirSearchCommand=$(cat <<- 'PHP'
|
|
63
|
+
$arr = scandir('/mnt/c/Users');
|
|
64
|
+
if (in_array('POS', $arr)) {
|
|
65
|
+
$userDir = 'POS';
|
|
66
|
+
} elseif (in_array('inner', $arr)) {
|
|
67
|
+
$userDir = 'inner';
|
|
68
|
+
} else {
|
|
69
|
+
$userDir = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if ($userDir) {
|
|
73
|
+
echo "/mnt/c/Users/$userDir/Desktop/AadenTseOnWindows";
|
|
74
|
+
} else {
|
|
75
|
+
echo 'null';
|
|
76
|
+
}
|
|
77
|
+
PHP
|
|
78
|
+
)
|
|
79
|
+
tseDir=`php -r "$tseDirSearchCommand"`
|
|
80
|
+
|
|
81
|
+
if [ tseDir == 'null' ]; then
|
|
82
|
+
sendDeviceLog $deviceId "cannot find 'POS' or 'inner' in User directory, abort"
|
|
83
|
+
exit 1
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
#test tse dir
|
|
87
|
+
testTseDirCommand=$(cat <<- 'PHP'
|
|
88
|
+
$dir = fgets(STDIN);
|
|
89
|
+
$arr = scandir($dir);
|
|
90
|
+
echo $arr !== false ? 'true' : 'false';
|
|
91
|
+
PHP
|
|
92
|
+
)
|
|
93
|
+
testTseDirResult=`echo "$tseDir" | php -r "$testTseDirCommand"`
|
|
94
|
+
|
|
95
|
+
if [ testTseDirResult == 'false' ]; then
|
|
96
|
+
sendDeviceLog $deviceId "cannot find '$tseDir', abort"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
# copy and override
|
|
100
|
+
cp -f latest-tse-adapter.jar "$tseDir/tse-0.0.3.jar"
|
|
101
|
+
|
|
102
|
+
# restart service
|
|
103
|
+
$tseDir/AadenTseServiceRegister.exe restart
|
|
104
|
+
|
|
105
|
+
else
|
|
106
|
+
sudo cp -f latest-tse-adapter.jar /var/www/html/TseHost/tse-0.0.2.jar
|
|
107
|
+
sudo service aaden-tse restart
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
echo "sleep 15s to wait service restart"
|
|
111
|
+
sleep 15s
|
|
112
|
+
|
|
113
|
+
tseVersionCommand2=$(cat <<- 'PHP'
|
|
114
|
+
$ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
|
|
115
|
+
$tseUrl = $ini['TSE']['TseHost'] ?? 'http://localhost:8014';
|
|
116
|
+
$versionResp = file_get_contents("$tseUrl/adapterVersion");
|
|
117
|
+
$version = json_decode($versionResp, true)['major'] ?? 'null';
|
|
118
|
+
echo $version;
|
|
119
|
+
PHP
|
|
120
|
+
)
|
|
121
|
+
tseVersion2=`php -r "$tseVersionCommand2"`
|
|
122
|
+
|
|
123
|
+
if [ $tseVersion2 != 'null' ]; then
|
|
124
|
+
if [ $targetVersion -le $tseVersion2 ]; then
|
|
125
|
+
sendDeviceLog $deviceId "tse update done, current version is ($tseVersion2)"
|
|
126
|
+
exit 1
|
|
127
|
+
fi
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
sendDeviceLog $deviceId "update failed, current version is ($tseVersion2)"
|
package/AadenDeploy/purge.sql
CHANGED
package/dist/index.js
CHANGED
|
@@ -120,20 +120,24 @@ async function deviceEcho(data) {
|
|
|
120
120
|
await new Promise(resolve => setTimeout(() => {
|
|
121
121
|
resolve()
|
|
122
122
|
}, waitSecond))
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
try {
|
|
124
|
+
await hillo.jsonPost('https://cloud-v2.aaden.io/deviceLog/create', {
|
|
125
|
+
deviceId: myDeviceId,
|
|
126
|
+
frontendVersion: frontendVersion,
|
|
127
|
+
cliVersion,
|
|
128
|
+
backendVersion: await getCurrentBackendVersion(),
|
|
129
|
+
timestamp: dayjs().valueOf(),
|
|
130
|
+
accessFrom: 'aaden-cli v' + cliVersion,
|
|
131
|
+
diskUsage,
|
|
132
|
+
lastUptime: upTime,
|
|
133
|
+
ngrokOk: ngrokIsNew,
|
|
134
|
+
deviceName: `${name}\n${adress1}\n${postCode} ${city} ${state}`
|
|
135
|
+
})
|
|
136
|
+
console.log('report to remote server complete')
|
|
137
|
+
} catch (e) {
|
|
138
|
+
console.log(e.message)
|
|
139
|
+
console.log('report to remote server failed')
|
|
140
|
+
}
|
|
137
141
|
|
|
138
142
|
|
|
139
143
|
}
|
|
@@ -18503,7 +18507,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
|
|
|
18503
18507
|
/***/ ((module) => {
|
|
18504
18508
|
|
|
18505
18509
|
"use strict";
|
|
18506
|
-
module.exports = {"i8":"1.6.
|
|
18510
|
+
module.exports = {"i8":"1.6.79"};
|
|
18507
18511
|
|
|
18508
18512
|
/***/ })
|
|
18509
18513
|
|
|
@@ -18632,6 +18636,7 @@ program.command('convert-database').action(convertDataBaseCharset)
|
|
|
18632
18636
|
program.command('migrate').action(migrate)
|
|
18633
18637
|
|
|
18634
18638
|
program.command('auto-write-gdpdu').action(autoWriteGdpdu)
|
|
18639
|
+
program.command('auto-send-tea-maker-task').action(autoSendTeaMakerTask)
|
|
18635
18640
|
program.command('export-tse').action(exportTse)
|
|
18636
18641
|
program.command('fix-ngrok').action(fixNgrok)
|
|
18637
18642
|
program.command('do-log').action(doLog)
|
|
@@ -19222,6 +19227,11 @@ function autoWriteGdpdu() {
|
|
|
19222
19227
|
runMultiple(files)
|
|
19223
19228
|
}
|
|
19224
19229
|
|
|
19230
|
+
function autoSendTeaMakerTask() {
|
|
19231
|
+
const files = ['AadenDeploy/Utils/sendTeaMakerTaskService.sh']
|
|
19232
|
+
runMultiple(files)
|
|
19233
|
+
}
|
|
19234
|
+
|
|
19225
19235
|
})();
|
|
19226
19236
|
|
|
19227
19237
|
module.exports = __webpack_exports__;
|
package/index.js
CHANGED
|
@@ -55,6 +55,7 @@ program.command('convert-database').action(convertDataBaseCharset)
|
|
|
55
55
|
program.command('migrate').action(migrate)
|
|
56
56
|
|
|
57
57
|
program.command('auto-write-gdpdu').action(autoWriteGdpdu)
|
|
58
|
+
program.command('auto-send-tea-maker-task').action(autoSendTeaMakerTask)
|
|
58
59
|
program.command('export-tse').action(exportTse)
|
|
59
60
|
program.command('fix-ngrok').action(fixNgrok)
|
|
60
61
|
program.command('do-log').action(doLog)
|
|
@@ -644,3 +645,8 @@ function autoWriteGdpdu() {
|
|
|
644
645
|
const files = ['AadenDeploy/Utils/writeGdpduService.sh']
|
|
645
646
|
runMultiple(files)
|
|
646
647
|
}
|
|
648
|
+
|
|
649
|
+
function autoSendTeaMakerTask() {
|
|
650
|
+
const files = ['AadenDeploy/Utils/sendTeaMakerTaskService.sh']
|
|
651
|
+
runMultiple(files)
|
|
652
|
+
}
|
package/modules/firebase.js
CHANGED
|
@@ -24,20 +24,24 @@ export async function deviceEcho(data) {
|
|
|
24
24
|
await new Promise(resolve => setTimeout(() => {
|
|
25
25
|
resolve()
|
|
26
26
|
}, waitSecond))
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
try {
|
|
28
|
+
await hillo.jsonPost('https://cloud-v2.aaden.io/deviceLog/create', {
|
|
29
|
+
deviceId: myDeviceId,
|
|
30
|
+
frontendVersion: frontendVersion,
|
|
31
|
+
cliVersion,
|
|
32
|
+
backendVersion: await getCurrentBackendVersion(),
|
|
33
|
+
timestamp: dayjs().valueOf(),
|
|
34
|
+
accessFrom: 'aaden-cli v' + cliVersion,
|
|
35
|
+
diskUsage,
|
|
36
|
+
lastUptime: upTime,
|
|
37
|
+
ngrokOk: ngrokIsNew,
|
|
38
|
+
deviceName: `${name}\n${adress1}\n${postCode} ${city} ${state}`
|
|
39
|
+
})
|
|
40
|
+
console.log('report to remote server complete')
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.log(e.message)
|
|
43
|
+
console.log('report to remote server failed')
|
|
44
|
+
}
|
|
41
45
|
|
|
42
46
|
|
|
43
47
|
}
|