aaden-cli 1.6.82 → 1.6.84

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.
@@ -1,24 +1,7 @@
1
1
  #!/bin/bash
2
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
- }
3
+ targetVersion=$1
4
+ tseAdapterDownloadUrl=$2
22
5
 
23
6
  # get tse version via php
24
7
  tseVersionCommand=$(cat <<- 'PHP'
@@ -34,7 +17,7 @@ tseVersion=`php -r "$tseVersionCommand"`
34
17
  # exit if no need to update
35
18
  if [ $tseVersion != 'null' ]; then
36
19
  if [ $targetVersion -le $tseVersion ]; then
37
- sendDeviceLog $deviceId "no need to update tse, current version is ($tseVersion)"
20
+ echo "无需更新TSE, 当前版本已是目标版本($tseVersion)"
38
21
  exit 1
39
22
  fi
40
23
  fi
@@ -52,63 +35,24 @@ PHP
52
35
  )
53
36
  os=`php -r "$osCommand"`
54
37
 
55
- sendDeviceLog $deviceId "user os is ($os)"
56
-
57
38
  # download tse adapter
58
39
  wget -O latest-tse-adapter.jar "$tseAdapterDownloadUrl"
59
40
 
60
41
  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
-
42
+ echo "当前系统为Windows系统,更新TSE请使用 aaden-cli update-win-tse"
43
+ exit 1
105
44
  else
106
45
  sudo cp -f latest-tse-adapter.jar /var/www/html/TseHost/tse-0.0.2.jar
107
46
  sudo service aaden-tse restart
108
47
  fi
109
48
 
110
- echo "sleep 15s to wait service restart"
111
- sleep 15s
49
+ echo "正在等待TSE服务重启"
50
+ sleep 5s
51
+ echo "还剩10秒"
52
+ sleep 5s
53
+ echo "还剩5秒"
54
+ sleep 5s
55
+ echo "开始检查新TSE版本"
112
56
 
113
57
  tseVersionCommand2=$(cat <<- 'PHP'
114
58
  $ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
@@ -122,9 +66,9 @@ tseVersion2=`php -r "$tseVersionCommand2"`
122
66
 
123
67
  if [ $tseVersion2 != 'null' ]; then
124
68
  if [ $targetVersion -le $tseVersion2 ]; then
125
- sendDeviceLog $deviceId "tse update done, current version is ($tseVersion2)"
69
+ echo "TSE升级完成,当前版本为($tseVersion2)"
126
70
  exit 1
127
71
  fi
128
72
  fi
129
73
 
130
- sendDeviceLog $deviceId "update failed, current version is ($tseVersion2)"
74
+ echo "TSE升级失败,当前版本为($tseVersion2)"
@@ -0,0 +1,83 @@
1
+ #!/bin/bash
2
+
3
+ targetVersion=$1
4
+ tseAdapterDownloadUrl=$2
5
+
6
+ # get tse version via php
7
+ tseVersionCommand=$(cat <<- 'PHP'
8
+ $ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
9
+ $tseUrl = $ini['TSE']['TseHost'] ?? 'http://localhost:8014';
10
+ $versionResp = file_get_contents("$tseUrl/adapterVersion");
11
+ $version = json_decode($versionResp, true)['major'] ?? 'null';
12
+ echo $version;
13
+ PHP
14
+ )
15
+ tseVersion=`php -r "$tseVersionCommand"`
16
+
17
+ # exit if no need to update
18
+ if [ $tseVersion != 'null' ]; then
19
+ if [ $targetVersion -le $tseVersion ]; then
20
+ echo "无需更新TSE, 当前版本已是目标版本($tseVersion)"
21
+ exit 1
22
+ fi
23
+ fi
24
+
25
+ # get os version via php
26
+ osCommand=$(cat <<- 'PHP'
27
+ $osVersion = shell_exec('cat /proc/version');
28
+ if (strpos($osVersion, 'microsoft') !== false || strpos($osVersion, 'WSL2') !== false) {
29
+ $os = 'windows';
30
+ } else {
31
+ $os = 'linux';
32
+ }
33
+ echo $os;
34
+ PHP
35
+ )
36
+ os=`php -r "$osCommand"`
37
+
38
+ # download tse adapter
39
+ wget -O latest-tse-adapter.jar "$tseAdapterDownloadUrl"
40
+
41
+ if [ $os == 'windows' ]; then
42
+ # find tse dir
43
+ tseDirSearchCommand=$(cat <<- 'PHP'
44
+ $userDirs = scandir('/mnt/c/Users');
45
+
46
+ $tseDir = null;
47
+ foreach ($userDirs as $userDir) {
48
+ $tryDir = "/mnt/c/Users/$userDir/Desktop/AadenTseOnWindows";
49
+ if (file_exists($tryDir)) {
50
+ $tseDir = $tryDir;
51
+ break;
52
+ }
53
+ }
54
+
55
+ if ($tseDir) {
56
+ echo $tseDir;
57
+ } else {
58
+ echo 'null';
59
+ }
60
+ PHP
61
+ )
62
+ tseDir=`php -r "$tseDirSearchCommand"`
63
+
64
+ if [ tseDir == 'null' ]; then
65
+ echo "未找到TSE文件夹,自动更新失败"
66
+ exit 1
67
+ fi
68
+
69
+ # copy and override
70
+ cp -f latest-tse-adapter.jar "$tseDir/tse-0.0.3.jar"
71
+
72
+ echo "新TSE文件覆盖完成。请客服注意引导老板,接受弹出来的框"
73
+ echo "可以使用此命令检查tse版本:curl --location 'localhost:8014/adapterVersion'"
74
+
75
+ # restart service
76
+ $tseDir/AadenTseServiceRegister.exe restart
77
+
78
+ else
79
+ echo "当前系统为Windows系统,更新TSE请使用 aaden-cli update-tse"
80
+ exit 1
81
+ fi
82
+
83
+ echo "自动更新脚本结束"
@@ -1,12 +1,32 @@
1
1
  #!/bin/bash
2
2
 
3
- sudo mkdir -p "/media/aaden/SWISSBIT"
4
- cd
5
- sudo touch tmp
6
- sudo chmod 777 tmp
7
- sudo cat /etc/fstab >tmp
8
- echo "UUID=5AFD-8706 /media/aaden/SWISSBIT vfat defaults 0 2" >>tmp
9
- sudo mv /etc/fstab /etc/fstab.backup
10
- sudo mv tmp /etc/fstab
11
- echo 'END AUTO CONFIG'
3
+ # Check if running in WSL
4
+ if grep -q "microsoft" /proc/version || grep -q "Microsoft" /proc/version; then
5
+ echo "This script cannot be run in a WSL environment. Aborting."
6
+ exit 1
7
+ fi
8
+
9
+
10
+ UUID="5AFD-8706"
11
+ MOUNT_POINT="/media/aaden/SWISSBIT"
12
+ NEW_ENTRY="UUID=$UUID $MOUNT_POINT vfat defaults,nofail 0 2"
13
+
14
+ # Ensure the directory exists
15
+ sudo mkdir -p "$MOUNT_POINT"
16
+
17
+ # Backup the current /etc/fstab
18
+ sudo cp /etc/fstab /etc/fstab.backup
19
+
20
+ # Check if the UUID already exists in /etc/fstab
21
+ if grep -q "UUID=$UUID" /etc/fstab; then
22
+ # If it exists, replace the line
23
+ sudo sed -i "s|.*UUID=$UUID.*|$NEW_ENTRY|" /etc/fstab
24
+ else
25
+ # If it doesn't exist, add the new entry
26
+ echo "$NEW_ENTRY" | sudo tee -a /etc/fstab > /dev/null
27
+ fi
28
+
29
+ # Confirm the changes with mount -a
12
30
  sudo mount -a
31
+
32
+ echo "END AUTO CONFIG"
package/dist/index.js CHANGED
@@ -18507,7 +18507,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.19.2","description":"P
18507
18507
  /***/ ((module) => {
18508
18508
 
18509
18509
  "use strict";
18510
- module.exports = {"i8":"1.6.82"};
18510
+ module.exports = {"i8":"1.6.84"};
18511
18511
 
18512
18512
  /***/ })
18513
18513
 
@@ -18626,6 +18626,8 @@ program.command('patch').action(patch)
18626
18626
  program.command('check-tse').action(checkTse)
18627
18627
  program.command('check-win-tse').action(checkWinTse)
18628
18628
  program.command('setup-tse').action(enableTSE)
18629
+ program.command('update-tse').action(updateTse)
18630
+ program.command('update-win-tse').action(updateWindowsTse)
18629
18631
  program.command('check-version').action(getBackendVersionOffline)
18630
18632
  program.command('full-update').action(fullUpdate)
18631
18633
 
@@ -19252,6 +19254,28 @@ function autoSendTeaMakerTask() {
19252
19254
  runMultiple(files)
19253
19255
  }
19254
19256
 
19257
+ function updateWindowsTse() {
19258
+ const scriptPath = 'AadenDeploy/Utils/updateAadenTseOnWindows.sh'
19259
+ const command = getPrivilegeCMD(scriptPath)
19260
+
19261
+ const targetVersion = 4
19262
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
19263
+ command.push(`./${scriptPath} ${targetVersion} ${tseAdapterDownloadUrl}`)
19264
+
19265
+ cli.executeInShell(command, program.debug)
19266
+ }
19267
+
19268
+ function updateTse() {
19269
+ const scriptPath = 'AadenDeploy/Utils/updateAadenTse.sh'
19270
+ const command = getPrivilegeCMD(scriptPath)
19271
+
19272
+ const targetVersion = 4
19273
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
19274
+ command.push(`./${scriptPath} ${targetVersion} ${tseAdapterDownloadUrl}`)
19275
+
19276
+ cli.executeInShell(command, program.debug)
19277
+ }
19278
+
19255
19279
  })();
19256
19280
 
19257
19281
  module.exports = __webpack_exports__;
package/index.js CHANGED
@@ -45,6 +45,8 @@ program.command('patch').action(patch)
45
45
  program.command('check-tse').action(checkTse)
46
46
  program.command('check-win-tse').action(checkWinTse)
47
47
  program.command('setup-tse').action(enableTSE)
48
+ program.command('update-tse').action(updateTse)
49
+ program.command('update-win-tse').action(updateWindowsTse)
48
50
  program.command('check-version').action(getBackendVersionOffline)
49
51
  program.command('full-update').action(fullUpdate)
50
52
 
@@ -670,3 +672,25 @@ function autoSendTeaMakerTask() {
670
672
  const files = ['AadenDeploy/Utils/sendTeaMakerTaskService.sh']
671
673
  runMultiple(files)
672
674
  }
675
+
676
+ function updateWindowsTse() {
677
+ const scriptPath = 'AadenDeploy/Utils/updateAadenTseOnWindows.sh'
678
+ const command = getPrivilegeCMD(scriptPath)
679
+
680
+ const targetVersion = 4
681
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
682
+ command.push(`./${scriptPath} ${targetVersion} ${tseAdapterDownloadUrl}`)
683
+
684
+ cli.executeInShell(command, program.debug)
685
+ }
686
+
687
+ function updateTse() {
688
+ const scriptPath = 'AadenDeploy/Utils/updateAadenTse.sh'
689
+ const command = getPrivilegeCMD(scriptPath)
690
+
691
+ const targetVersion = 4
692
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
693
+ command.push(`./${scriptPath} ${targetVersion} ${tseAdapterDownloadUrl}`)
694
+
695
+ cli.executeInShell(command, program.debug)
696
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aaden-cli",
3
- "version": "1.6.82",
3
+ "version": "1.6.84",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {