|
|
@@ -1,6 +1,7 @@
|
|
|
import { io } from "socket.io-client"
|
|
|
import axios from "axios"
|
|
|
import { setTimeout } from "timers/promises"
|
|
|
+import chalk from "chalk"
|
|
|
const axiosInstance = axios.create({
|
|
|
baseURL: "http://47.98.225.28/api",
|
|
|
headers: {
|
|
|
@@ -16,20 +17,42 @@ const {
|
|
|
search: { where: { online: true }, order: { name: "ASC" } }
|
|
|
})
|
|
|
|
|
|
-for (let d of devices) {
|
|
|
- if (parseInt(d.version) < 136) {
|
|
|
- await axiosInstance.post(
|
|
|
+for (let device of devices) {
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ data: { out }
|
|
|
+ } = await axiosInstance.post(
|
|
|
`/device/${device.id}/sendMessage`,
|
|
|
{
|
|
|
- action: "installApk",
|
|
|
+ action: "runScript",
|
|
|
data: {
|
|
|
- apkUrl: ""
|
|
|
+ script: "dumpsys package com.example.modifiermodule | grep versionName"
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
timeout: 2000
|
|
|
}
|
|
|
)
|
|
|
- await setTimeout(500)
|
|
|
+ if (!out.includes("versionName=1.0.1")) {
|
|
|
+ console.log(chalk.blue(device.id, device.name, "update"))
|
|
|
+ // axiosInstance
|
|
|
+ // .post(
|
|
|
+ // `/device/${device.id}/sendMessage`,
|
|
|
+ // {
|
|
|
+ // action: "installApk",
|
|
|
+ // data: {
|
|
|
+ // apkUrl: "https://nebuai.oss-cn-hangzhou.aliyuncs.com/application/20241016/iblg9jp0.apk"
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // timeout: 180000
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ // .catch(e => console.log(e.message))
|
|
|
+ } else {
|
|
|
+ console.log(device.id, device.name, "OK")
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(device.id, device.name, e.message)
|
|
|
}
|
|
|
}
|