aaden-cli 1.6.81 → 1.6.83

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.
@@ -58,50 +58,8 @@ sendDeviceLog $deviceId "user os is ($os)"
58
58
  wget -O latest-tse-adapter.jar "$tseAdapterDownloadUrl"
59
59
 
60
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
-
61
+ sendDeviceLog $deviceId "this is a Windows system, abort"
62
+ exit 1
105
63
  else
106
64
  sudo cp -f latest-tse-adapter.jar /var/www/html/TseHost/tse-0.0.2.jar
107
65
  sudo service aaden-tse restart
@@ -0,0 +1,120 @@
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
+ $userDirs = scandir('/mnt/c/Users');
64
+
65
+ $tseDir = null;
66
+ foreach ($userDirs as $userDir) {
67
+ $tryDir = "/mnt/c/Users/$userDir/Desktop/AadenTseOnWindows";
68
+ if (file_exists($tryDir)) {
69
+ $tseDir = $tryDir;
70
+ break;
71
+ }
72
+ }
73
+
74
+ if ($tseDir) {
75
+ echo $tseDir;
76
+ } else {
77
+ echo 'null';
78
+ }
79
+ PHP
80
+ )
81
+ tseDir=`php -r "$tseDirSearchCommand"`
82
+
83
+ if [ tseDir == 'null' ]; then
84
+ sendDeviceLog $deviceId "no TSE directory, abort"
85
+ exit 1
86
+ fi
87
+
88
+ # copy and override
89
+ cp -f latest-tse-adapter.jar "$tseDir/tse-0.0.3.jar"
90
+
91
+ echo "新TSE文件覆盖完成。请客服注意引导老板,接受弹出来的框"
92
+
93
+ # restart service
94
+ $tseDir/AadenTseServiceRegister.exe restart
95
+
96
+ else
97
+ sendDeviceLog $deviceId "this is a Linux system, abort"
98
+ exit 1
99
+ fi
100
+
101
+ echo "流程结束"
102
+
103
+ #tseVersionCommand2=$(cat <<- 'PHP'
104
+ #$ini = parse_ini_file('/var/www/html/Resource/config/config.ini', true);
105
+ #$tseUrl = $ini['TSE']['TseHost'] ?? 'http://localhost:8014';
106
+ #$versionResp = file_get_contents("$tseUrl/adapterVersion");
107
+ #$version = json_decode($versionResp, true)['major'] ?? 'null';
108
+ #echo $version;
109
+ #PHP
110
+ #)
111
+ #tseVersion2=`php -r "$tseVersionCommand2"`
112
+ #
113
+ #if [ $tseVersion2 != 'null' ]; then
114
+ # if [ $targetVersion -le $tseVersion2 ]; then
115
+ # sendDeviceLog $deviceId "tse update done, current version is ($tseVersion2)"
116
+ # exit 1
117
+ # fi
118
+ #fi
119
+ #
120
+ #sendDeviceLog $deviceId "update failed, current version is ($tseVersion2)"
@@ -92,6 +92,7 @@ sudo mysql -uroot < backendFiles/new.sql
92
92
 
93
93
  echoWithWait "Uploading PHP Files"
94
94
  sudo mv backendFiles/* /var/www/html/
95
+ sudo service apache2 restart
95
96
  sudo chown -hR www-data:www-data /var/www/html
96
97
 
97
98
  sudo chmod -R 777 /var/www/html/Resource
@@ -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.81"};
18510
+ module.exports = {"i8":"1.6.83"};
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,30 @@ 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 deviceId = getMyDeviceId()
19262
+ const targetVersion = 4
19263
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
19264
+ command.push(`./${scriptPath} ${deviceId} ${targetVersion} ${tseAdapterDownloadUrl}`)
19265
+
19266
+ cli.executeInShell(command, program.debug)
19267
+ }
19268
+
19269
+ function updateTse() {
19270
+ const scriptPath = 'AadenDeploy/Utils/updateAadenTse.sh'
19271
+ const command = getPrivilegeCMD(scriptPath)
19272
+
19273
+ const deviceId = getMyDeviceId()
19274
+ const targetVersion = 4
19275
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
19276
+ command.push(`./${scriptPath} ${deviceId} ${targetVersion} ${tseAdapterDownloadUrl}`)
19277
+
19278
+ cli.executeInShell(command, program.debug)
19279
+ }
19280
+
19255
19281
  })();
19256
19282
 
19257
19283
  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,27 @@ 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 deviceId = getMyDeviceId()
681
+ const targetVersion = 4
682
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
683
+ command.push(`./${scriptPath} ${deviceId} ${targetVersion} ${tseAdapterDownloadUrl}`)
684
+
685
+ cli.executeInShell(command, program.debug)
686
+ }
687
+
688
+ function updateTse() {
689
+ const scriptPath = 'AadenDeploy/Utils/updateAadenTse.sh'
690
+ const command = getPrivilegeCMD(scriptPath)
691
+
692
+ const deviceId = getMyDeviceId()
693
+ const targetVersion = 4
694
+ const tseAdapterDownloadUrl = 'https://innerken.com/Download/tse-0.0.4.jar'
695
+ command.push(`./${scriptPath} ${deviceId} ${targetVersion} ${tseAdapterDownloadUrl}`)
696
+
697
+ cli.executeInShell(command, program.debug)
698
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aaden-cli",
3
- "version": "1.6.81",
3
+ "version": "1.6.83",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {