mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-07 07:09:46 +00:00
add migration tool
This commit is contained in:
parent
03d6f8721c
commit
1c9ad4c63e
1
UI
1
UI
@ -1 +0,0 @@
|
|||||||
Subproject commit bca27426e1f398c31fb6c5c23885482326514f6e
|
|
||||||
@ -1,3 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.org
|
||||||
|
* @Date: 2022-08-23 18:09:11
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-08-24 18:02:59
|
||||||
|
* @FilePath: /CasaOS/cmd/migration-tool/main.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -5,17 +15,78 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS/types"
|
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
||||||
|
"github.com/IceWhaleTech/CasaOS-Common/utils/systemctl"
|
||||||
|
"github.com/IceWhaleTech/CasaOS-Gateway/common"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
casaosServiceName = "casaos.service"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
versionFlag := flag.Bool("v", false, "version")
|
versionFlag := flag.Bool("v", false, "version")
|
||||||
|
debugFlag := flag.Bool("d", true, "debug")
|
||||||
|
forceFlag := flag.Bool("f", false, "force")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *versionFlag {
|
if *versionFlag {
|
||||||
fmt.Println(types.CURRENTVERSION)
|
fmt.Println(common.Version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("This migration tool is not implemented yet.")
|
if os.Getuid() != 0 {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if *debugFlag {
|
||||||
|
// _logger.DebugMode = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if !*forceFlag {
|
||||||
|
serviceEnabled, err := systemctl.IsServiceEnabled(casaosServiceName)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if serviceEnabled {
|
||||||
|
//_logger.Info("%s is already enabled. If migration is still needed, try with -f.", userServiceName)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
migrationTools := []interfaces.MigrationTool{
|
||||||
|
NewMigrationToolFor_035(),
|
||||||
|
}
|
||||||
|
|
||||||
|
var selectedMigrationTool interfaces.MigrationTool
|
||||||
|
|
||||||
|
// look for the right migration tool matching current version
|
||||||
|
for _, tool := range migrationTools {
|
||||||
|
migrationNeeded, err := tool.IsMigrationNeeded()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if migrationNeeded {
|
||||||
|
selectedMigrationTool = tool
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if selectedMigrationTool == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := selectedMigrationTool.PreMigrate(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := selectedMigrationTool.Migrate(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := selectedMigrationTool.PostMigrate(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
52
cmd/migration-tool/migration-035.go
Normal file
52
cmd/migration-tool/migration-035.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.org
|
||||||
|
* @Date: 2022-08-24 17:36:00
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-08-24 18:11:16
|
||||||
|
* @FilePath: /CasaOS/cmd/migration-tool/migration-035.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
interfaces "github.com/IceWhaleTech/CasaOS-Common"
|
||||||
|
"github.com/IceWhaleTech/CasaOS-Common/utils/version"
|
||||||
|
)
|
||||||
|
|
||||||
|
type migrationTool struct{}
|
||||||
|
|
||||||
|
func (u *migrationTool) IsMigrationNeeded() (bool, error) {
|
||||||
|
|
||||||
|
minorVersion, err := version.DetectMinorVersion()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if minorVersion != 3 {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is the best way to tell if CasaOS version is between 0.3.3 and 0.3.5
|
||||||
|
|
||||||
|
//return true, nil
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *migrationTool) PreMigrate() error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *migrationTool) Migrate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *migrationTool) PostMigrate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewMigrationToolFor_035() interfaces.MigrationTool {
|
||||||
|
return &migrationTool{}
|
||||||
|
}
|
||||||
1
go.mod
1
go.mod
@ -4,6 +4,7 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
|
||||||
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811222508-6c2a1d77be66
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha1
|
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha1
|
||||||
github.com/Microsoft/go-winio v0.5.0 // indirect
|
github.com/Microsoft/go-winio v0.5.0 // indirect
|
||||||
github.com/ambelovsky/go-structs v1.1.0 // indirect
|
github.com/ambelovsky/go-structs v1.1.0 // indirect
|
||||||
|
|||||||
5
go.sum
5
go.sum
@ -83,6 +83,7 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
|
|||||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d h1:62lEBImTxZ83pgzywgDNIrPPuQ+j4ep9QjqrWBn1hrU=
|
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d h1:62lEBImTxZ83pgzywgDNIrPPuQ+j4ep9QjqrWBn1hrU=
|
||||||
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d/go.mod h1:lW9x+yEjqKdPbE3+cf2fGPJXCw/hChX3Omi9QHTLFsQ=
|
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d/go.mod h1:lW9x+yEjqKdPbE3+cf2fGPJXCw/hChX3Omi9QHTLFsQ=
|
||||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||||
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811222508-6c2a1d77be66 h1:JXzgOmP4HCWbZ7qCl6gr2nRB5RnUN0oTFF8ohv05sZk=
|
||||||
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811222508-6c2a1d77be66/go.mod h1:XGqdbedN9UlF3/rylcXKJ2BW4ayugBmEMa4Z0tk2KbQ=
|
github.com/IceWhaleTech/CasaOS-Common v0.0.0-20220811222508-6c2a1d77be66/go.mod h1:XGqdbedN9UlF3/rylcXKJ2BW4ayugBmEMa4Z0tk2KbQ=
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha1 h1:VTjFhgaDy+yDZZOkGACLoynp2fxCL1PJuwYM+tLL68o=
|
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha1 h1:VTjFhgaDy+yDZZOkGACLoynp2fxCL1PJuwYM+tLL68o=
|
||||||
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha1/go.mod h1:wWBJTVHt0P0AGNfoOgI2+HhZ5bGZU4d5xbz/dXNBzAY=
|
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6-alpha1/go.mod h1:wWBJTVHt0P0AGNfoOgI2+HhZ5bGZU4d5xbz/dXNBzAY=
|
||||||
@ -276,9 +277,11 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
|
|||||||
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20161114122254-48702e0da86b/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||||
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||||
|
github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI=
|
||||||
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
@ -419,8 +422,10 @@ github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
|
|||||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
||||||
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
github.com/godbus/dbus v0.0.0-20180201030542-885f9cc04c9c/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
|
||||||
|
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e h1:BWhy2j3IXJhjCbC68FptL43tDKIq8FladmaTs3Xs7Z8=
|
||||||
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
|
github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
|
||||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
|
github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA=
|
||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
|
|||||||
18
interfaces/migrationTool.go
Normal file
18
interfaces/migrationTool.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.org
|
||||||
|
* @Date: 2022-08-24 17:37:36
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-08-24 17:38:48
|
||||||
|
* @FilePath: /CasaOS/interfaces/migrationTool.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package interfaces
|
||||||
|
|
||||||
|
type MigrationTool interface {
|
||||||
|
IsMigrationNeeded() (bool, error)
|
||||||
|
PostMigrate() error
|
||||||
|
Migrate() error
|
||||||
|
PreMigrate() error
|
||||||
|
}
|
||||||
1
main.go
1
main.go
@ -140,7 +140,6 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("注册成功")
|
|
||||||
// s := &http.Server{
|
// s := &http.Server{
|
||||||
// Addr: listener.Addr().String(), //fmt.Sprintf(":%v", config.ServerInfo.HttpPort),
|
// Addr: listener.Addr().String(), //fmt.Sprintf(":%v", config.ServerInfo.HttpPort),
|
||||||
// Handler: r,
|
// Handler: r,
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.org
|
* @Author: LinkLeong link@icewhale.org
|
||||||
* @Date: 2022-08-12 14:22:28
|
* @Date: 2022-08-12 14:22:28
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-08-12 18:41:14
|
* @LastEditTime: 2022-08-24 18:52:36
|
||||||
* @FilePath: /CasaOS/route/darwin.go
|
* @FilePath: /CasaOS/route/darwin.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
package route
|
package route
|
||||||
|
|
||||||
func MonitoryUSB() {
|
// func MonitoryUSB() {
|
||||||
|
|
||||||
}
|
// }
|
||||||
func SendAllHardwareStatusBySocket() {
|
// func SendAllHardwareStatusBySocket() {
|
||||||
|
|
||||||
}
|
// }
|
||||||
func SendUSBBySocket() {
|
// func SendUSBBySocket() {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
//go:build !darwin
|
|
||||||
// +build !darwin
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2022-07-01 15:11:36
|
* @Date: 2022-07-01 15:11:36
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-08-18 16:58:00
|
* @LastEditTime: 2022-08-24 18:54:03
|
||||||
* @FilePath: /CasaOS/route/periodical.go
|
* @FilePath: /CasaOS/route/periodical.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -535,6 +536,13 @@ func GetSystemProxy(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
for k, v := range c.Request.Header {
|
||||||
|
c.Header(k, v[0])
|
||||||
|
}
|
||||||
rda, _ := ioutil.ReadAll(resp.Body)
|
rda, _ := ioutil.ReadAll(resp.Body)
|
||||||
json.NewEncoder(c.Writer).Encode(json.RawMessage(string(rda)))
|
// json.NewEncoder(c.Writer).Encode(json.RawMessage(string(rda)))
|
||||||
|
// 响应状态码
|
||||||
|
c.Writer.WriteHeader(resp.StatusCode)
|
||||||
|
// 复制转发的响应Body到响应Body
|
||||||
|
io.Copy(c.Writer, ioutil.NopCloser(bytes.NewBuffer(rda)))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -306,7 +306,7 @@ func (s *systemService) GetCPUTemperature() int {
|
|||||||
outPut = "0"
|
outPut = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
celsius, _ := strconv.Atoi(outPut)
|
celsius, _ := strconv.Atoi(strings.TrimSpace(outPut))
|
||||||
|
|
||||||
if celsius > 1000 {
|
if celsius > 1000 {
|
||||||
celsius = celsius / 1000
|
celsius = celsius / 1000
|
||||||
@ -316,8 +316,8 @@ func (s *systemService) GetCPUTemperature() int {
|
|||||||
func (s *systemService) GetCPUPower() map[string]string {
|
func (s *systemService) GetCPUPower() map[string]string {
|
||||||
data := make(map[string]string, 2)
|
data := make(map[string]string, 2)
|
||||||
data["timestamp"] = strconv.FormatInt(time.Now().Unix(), 10)
|
data["timestamp"] = strconv.FormatInt(time.Now().Unix(), 10)
|
||||||
if file.Exists(`/sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj`) {
|
if file.Exists("/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj") {
|
||||||
data["value"] = string(file.ReadFullFile(`/sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj`))
|
data["value"] = strings.TrimSpace(string(file.ReadFullFile("/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj")))
|
||||||
} else {
|
} else {
|
||||||
data["value"] = "0"
|
data["value"] = "0"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user