mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-07 07:09:46 +00:00
switch branch
This commit is contained in:
parent
6343e889e8
commit
493c1170f9
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,6 +31,7 @@ gen
|
|||||||
/docs/
|
/docs/
|
||||||
/web/
|
/web/
|
||||||
/conf/conf.ini
|
/conf/conf.ini
|
||||||
|
/conf/conf.json
|
||||||
__debug_bin
|
__debug_bin
|
||||||
main
|
main
|
||||||
CasaOS
|
CasaOS
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
[app]
|
[app]
|
||||||
PAGE_SIZE = 10
|
PAGE_SIZE = 10
|
||||||
RuntimeRootPath = runtime/
|
RuntimeRootPath = runtime/
|
||||||
LogSavePath = /casaOS/logs/server/
|
LogSavePath = /var/log/casaos/
|
||||||
LogSaveName = log
|
LogSaveName = log
|
||||||
LogFileExt = log
|
LogFileExt = log
|
||||||
DateStrFormat = 20060102
|
DateStrFormat = 20060102
|
||||||
DateTimeFormat = 2006-01-02 15:04:05
|
DateTimeFormat = 2006-01-02 15:04:05
|
||||||
TimeFormat = 15:04:05
|
TimeFormat = 15:04:05
|
||||||
DateFormat = 2006-01-02
|
DateFormat = 2006-01-02
|
||||||
ProjectPath = /casaOS/server
|
DBPath = /var/lib/casaos
|
||||||
RootPath = /casaOS
|
ShellPath = /usr/share/casaos/shell
|
||||||
|
UserDataPath = /var/lib/casaos/conf
|
||||||
|
TempPath = /var/lib/casaos/temp
|
||||||
|
|
||||||
[server]
|
[server]
|
||||||
HttpPort = 8089
|
HttpPort = 8089
|
||||||
2
main.go
2
main.go
@ -30,7 +30,7 @@ func init() {
|
|||||||
config.UpdateSetup()
|
config.UpdateSetup()
|
||||||
loger.LogInit()
|
loger.LogInit()
|
||||||
if len(*dbFlag) == 0 {
|
if len(*dbFlag) == 0 {
|
||||||
*dbFlag = config.AppInfo.ProjectPath + "/db"
|
*dbFlag = config.AppInfo.DBPath + "/db"
|
||||||
}
|
}
|
||||||
sqliteDB = sqlite.GetDb(*dbFlag)
|
sqliteDB = sqlite.GetDb(*dbFlag)
|
||||||
//gredis.GetRedisConn(config.RedisInfo),
|
//gredis.GetRedisConn(config.RedisInfo),
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2022-05-13 18:15:46
|
* @Date: 2022-05-13 18:15:46
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-05-30 16:43:59
|
* @LastEditTime: 2022-06-16 17:50:56
|
||||||
* @FilePath: /CasaOS/model/sys_common.go
|
* @FilePath: /CasaOS/model/sys_common.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@ -46,15 +46,17 @@ type ServerModel struct {
|
|||||||
|
|
||||||
//服务配置
|
//服务配置
|
||||||
type APPModel struct {
|
type APPModel struct {
|
||||||
LogSavePath string
|
LogPath string
|
||||||
LogSaveName string
|
LogSaveName string
|
||||||
LogFileExt string
|
LogFileExt string
|
||||||
DateStrFormat string
|
DateStrFormat string
|
||||||
DateTimeFormat string
|
DateTimeFormat string
|
||||||
|
UserDataPath string
|
||||||
TimeFormat string
|
TimeFormat string
|
||||||
DateFormat string
|
DateFormat string
|
||||||
ProjectPath string
|
DBPath string
|
||||||
RootPath string
|
ShellPath string
|
||||||
|
TempPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
//公共返回模型
|
//公共返回模型
|
||||||
|
|||||||
@ -1,5 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.com
|
||||||
|
* @Date: 2021-09-30 18:18:14
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-06-16 18:11:41
|
||||||
|
* @FilePath: /CasaOS/pkg/config/config.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
package config
|
package config
|
||||||
|
|
||||||
const (
|
const (
|
||||||
USERCONFIGURL = "conf/conf.ini"
|
USERCONFIGURL = "conf/conf.json"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.com
|
||||||
|
* @Date: 2022-05-13 18:15:46
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-06-16 17:44:23
|
||||||
|
* @FilePath: /CasaOS/pkg/config/init.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -57,6 +67,21 @@ func InitSetup(config string) {
|
|||||||
mapTo("system", SystemConfigInfo)
|
mapTo("system", SystemConfigInfo)
|
||||||
mapTo("file", FileSettingInfo)
|
mapTo("file", FileSettingInfo)
|
||||||
SystemConfigInfo.ConfigPath = configDir
|
SystemConfigInfo.ConfigPath = configDir
|
||||||
|
if len(AppInfo.DBPath) == 0 {
|
||||||
|
AppInfo.DBPath = "/var/lib/casaos"
|
||||||
|
}
|
||||||
|
if len(AppInfo.LogPath) == 0 {
|
||||||
|
AppInfo.LogPath = "/var/log/casaos/"
|
||||||
|
}
|
||||||
|
if len(AppInfo.ShellPath) == 0 {
|
||||||
|
AppInfo.ShellPath = "/usr/share/casaos/shell"
|
||||||
|
}
|
||||||
|
if len(AppInfo.UserDataPath) == 0 {
|
||||||
|
AppInfo.UserDataPath = "/var/lib/casaos/conf"
|
||||||
|
}
|
||||||
|
if len(AppInfo.TempPath) == 0 {
|
||||||
|
AppInfo.TempPath = "/var/lib/casaos/temp"
|
||||||
|
}
|
||||||
// AppInfo.ProjectPath = getCurrentDirectory() //os.Getwd()
|
// AppInfo.ProjectPath = getCurrentDirectory() //os.Getwd()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ const (
|
|||||||
PWD_IS_TOO_SIMPLE = 10005
|
PWD_IS_TOO_SIMPLE = 10005
|
||||||
USER_NOT_EXIST = 10006
|
USER_NOT_EXIST = 10006
|
||||||
USER_EXIST = 10007
|
USER_EXIST = 10007
|
||||||
|
KEY_NOT_EXIST = 10008
|
||||||
|
|
||||||
//system
|
//system
|
||||||
DIR_ALREADY_EXISTS = 20001
|
DIR_ALREADY_EXISTS = 20001
|
||||||
@ -69,6 +70,7 @@ var MsgFlags = map[int]string{
|
|||||||
PWD_IS_TOO_SIMPLE: "Password is too simple",
|
PWD_IS_TOO_SIMPLE: "Password is too simple",
|
||||||
USER_NOT_EXIST: "User does not exist",
|
USER_NOT_EXIST: "User does not exist",
|
||||||
USER_EXIST: "User already exists",
|
USER_EXIST: "User already exists",
|
||||||
|
KEY_NOT_EXIST: "Key does not exist",
|
||||||
|
|
||||||
//system
|
//system
|
||||||
DIR_ALREADY_EXISTS: "Folder already exists",
|
DIR_ALREADY_EXISTS: "Folder already exists",
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2021-09-30 18:18:14
|
* @Date: 2021-09-30 18:18:14
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-06-15 15:07:16
|
* @LastEditTime: 2022-06-16 18:05:00
|
||||||
* @FilePath: /CasaOS/pkg/utils/jwt/jwt.go
|
* @FilePath: /CasaOS/pkg/utils/jwt/jwt.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@ -19,16 +19,18 @@ import (
|
|||||||
type Claims struct {
|
type Claims struct {
|
||||||
UserName string `json:"username"`
|
UserName string `json:"username"`
|
||||||
PassWord string `json:"password"`
|
PassWord string `json:"password"`
|
||||||
|
Id int `json:"id"`
|
||||||
jwt.RegisteredClaims
|
jwt.RegisteredClaims
|
||||||
}
|
}
|
||||||
|
|
||||||
var jwtSecret []byte
|
var jwtSecret []byte
|
||||||
|
|
||||||
//创建token
|
//创建token
|
||||||
func GenerateToken(username, password string, issuer string, t time.Duration) (string, error) {
|
func GenerateToken(username, password string, id int, issuer string, t time.Duration) (string, error) {
|
||||||
clims := Claims{
|
clims := Claims{
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
id,
|
||||||
jwt.RegisteredClaims{
|
jwt.RegisteredClaims{
|
||||||
ExpiresAt: jwt.NewNumericDate(time.Now().Add(t)),
|
ExpiresAt: jwt.NewNumericDate(time.Now().Add(t)),
|
||||||
IssuedAt: jwt.NewNumericDate(time.Now()),
|
IssuedAt: jwt.NewNumericDate(time.Now()),
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package jwt
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS/model"
|
"github.com/IceWhaleTech/CasaOS/model"
|
||||||
@ -30,6 +31,7 @@ func JWT(swagHandler gin.HandlerFunc) gin.HandlerFunc {
|
|||||||
} else if claims.VerifyExpiresAt(time.Now(), true) || claims.VerifyIssuer("casaos", true) {
|
} else if claims.VerifyExpiresAt(time.Now(), true) || claims.VerifyIssuer("casaos", true) {
|
||||||
code = common_err.ERROR_AUTH_TOKEN
|
code = common_err.ERROR_AUTH_TOKEN
|
||||||
}
|
}
|
||||||
|
c.Header("user_id", strconv.Itoa(claims.Id))
|
||||||
}
|
}
|
||||||
|
|
||||||
if code != common_err.SUCCESS {
|
if code != common_err.SUCCESS {
|
||||||
@ -37,13 +39,14 @@ func JWT(swagHandler gin.HandlerFunc) gin.HandlerFunc {
|
|||||||
c.Abort()
|
c.Abort()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get AccessToken
|
//get AccessToken
|
||||||
func GetAccessToken(username, pwd string) string {
|
func GetAccessToken(username, pwd string, id int) string {
|
||||||
token, err := GenerateToken(username, pwd, "casaos", 3*time.Hour*time.Duration(1))
|
token, err := GenerateToken(username, pwd, id, "casaos", 3*time.Hour*time.Duration(1))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return token
|
return token
|
||||||
} else {
|
} else {
|
||||||
@ -52,8 +55,8 @@ func GetAccessToken(username, pwd string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRefreshToken(username, pwd string) string {
|
func GetRefreshToken(username, pwd string, id int) string {
|
||||||
token, err := GenerateToken(username, pwd, "fresh", 7*24*time.Hour*time.Duration(1))
|
token, err := GenerateToken(username, pwd, id, "fresh", 7*24*time.Hour*time.Duration(1))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return token
|
return token
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2022-06-02 15:09:38
|
* @Date: 2022-06-02 15:09:38
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-06-02 17:43:38
|
* @LastEditTime: 2022-06-16 18:15:58
|
||||||
* @FilePath: /CasaOS/pkg/utils/loger/log.go
|
* @FilePath: /CasaOS/pkg/utils/loger/log.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@ -28,7 +28,7 @@ var loggers *zap.Logger
|
|||||||
func getFileLogWriter() (writeSyncer zapcore.WriteSyncer) {
|
func getFileLogWriter() (writeSyncer zapcore.WriteSyncer) {
|
||||||
// 使用 lumberjack 实现 log rotate
|
// 使用 lumberjack 实现 log rotate
|
||||||
lumberJackLogger := &lumberjack.Logger{
|
lumberJackLogger := &lumberjack.Logger{
|
||||||
Filename: filepath.Join(config.AppInfo.LogSavePath, fmt.Sprintf("%s.%s",
|
Filename: filepath.Join(config.AppInfo.LogPath, fmt.Sprintf("%s.%s",
|
||||||
config.AppInfo.LogSaveName,
|
config.AppInfo.LogSaveName,
|
||||||
config.AppInfo.LogFileExt,
|
config.AppInfo.LogFileExt,
|
||||||
)),
|
)),
|
||||||
|
|||||||
@ -47,7 +47,7 @@ const (
|
|||||||
//日志初始化
|
//日志初始化
|
||||||
func LogSetupOld() {
|
func LogSetupOld() {
|
||||||
var err error
|
var err error
|
||||||
filePath := fmt.Sprintf("%s", config.AppInfo.LogSavePath)
|
filePath := fmt.Sprintf("%s", config.AppInfo.LogPath)
|
||||||
fileName := fmt.Sprintf("%s.%s",
|
fileName := fmt.Sprintf("%s.%s",
|
||||||
config.AppInfo.LogSaveName,
|
config.AppInfo.LogSaveName,
|
||||||
config.AppInfo.LogFileExt,
|
config.AppInfo.LogFileExt,
|
||||||
@ -61,7 +61,7 @@ func LogSetupOld() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
func (o *oLog) Path() string {
|
func (o *oLog) Path() string {
|
||||||
filePath := fmt.Sprintf("%s", config.AppInfo.LogSavePath)
|
filePath := fmt.Sprintf("%s", config.AppInfo.LogPath)
|
||||||
fileName := fmt.Sprintf("%s.%s",
|
fileName := fmt.Sprintf("%s.%s",
|
||||||
config.AppInfo.LogSaveName,
|
config.AppInfo.LogSaveName,
|
||||||
config.AppInfo.LogFileExt,
|
config.AppInfo.LogFileExt,
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package route
|
|||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -197,10 +198,10 @@ func CheckSerialDiskMount() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
service.MyService.Disk().RemoveLSBLKCache()
|
service.MyService.Disk().RemoveLSBLKCache()
|
||||||
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;AutoRemoveUnuseDir")
|
command.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;AutoRemoveUnuseDir")
|
||||||
}
|
}
|
||||||
func Update2_3() {
|
func Update2_3() {
|
||||||
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/assist.sh")
|
command.OnlyExec("source " + config.AppInfo.ShellPath + "/assist.sh")
|
||||||
|
|
||||||
}
|
}
|
||||||
func CheckToken2_11() {
|
func CheckToken2_11() {
|
||||||
@ -210,11 +211,6 @@ func CheckToken2_11() {
|
|||||||
config.Cfg.Section("server").Key("Token").SetValue(token())
|
config.Cfg.Section("server").Key("Token").SetValue(token())
|
||||||
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||||
}
|
}
|
||||||
if len(config.AppInfo.RootPath) == 0 {
|
|
||||||
config.Cfg.Section("app").Key("RootPath").SetValue("/casaOS")
|
|
||||||
config.AppInfo.RootPath = "/casaOS"
|
|
||||||
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
sysType := runtime.GOOS
|
sysType := runtime.GOOS
|
||||||
if len(config.FileSettingInfo.DownloadDir) == 0 {
|
if len(config.FileSettingInfo.DownloadDir) == 0 {
|
||||||
@ -305,6 +301,12 @@ func MoveUserToDB() {
|
|||||||
user.NickName = config.UserInfo.NickName
|
user.NickName = config.UserInfo.NickName
|
||||||
user.Password = encryption.GetMD5ByStr(config.UserInfo.PWD)
|
user.Password = encryption.GetMD5ByStr(config.UserInfo.PWD)
|
||||||
user.Role = "admin"
|
user.Role = "admin"
|
||||||
service.MyService.User().CreateUser(user)
|
user = service.MyService.User().CreateUser(user)
|
||||||
|
if user.Id > 0 {
|
||||||
|
userPath := config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id)
|
||||||
|
file.MkDir(userPath)
|
||||||
|
os.Rename("/casaOS/server/conf/app_order.json", userPath+"/app_order.json")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,12 +57,12 @@ func InitRouter() *gin.Engine {
|
|||||||
//chang head
|
//chang head
|
||||||
//v1UserGroup.POST("/head", v1.PostUserHead)
|
//v1UserGroup.POST("/head", v1.PostUserHead)
|
||||||
//chang user name
|
//chang user name
|
||||||
v1UserGroup.PUT("/username:/id", v1.PutUserName)
|
v1UserGroup.PUT("/username/:id", v1.PutUserName)
|
||||||
//chang pwd
|
//chang pwd
|
||||||
v1UserGroup.PUT("/password/:id", v1.PutUserPwd)
|
v1UserGroup.PUT("/password/:id", v1.PutUserPwd)
|
||||||
//edit user info
|
//edit user info
|
||||||
//v1UserGroup.POST("/info", v1.PostUserChangeInfo)
|
//v1UserGroup.POST("/info", v1.PostUserChangeInfo)
|
||||||
v1UserGroup.PUT("/nick:/id", v1.PutUserNick)
|
v1UserGroup.PUT("/nick/:id", v1.PutUserNick)
|
||||||
v1UserGroup.PUT("/desc/:id", v1.PutUserDesc)
|
v1UserGroup.PUT("/desc/:id", v1.PutUserDesc)
|
||||||
v1UserGroup.GET("/v1/user/info/:id", v1.GetUserInfo)
|
v1UserGroup.GET("/v1/user/info/:id", v1.GetUserInfo)
|
||||||
//v1UserGroup.POST("/person/info", v1.PostUserPersonInfo)
|
//v1UserGroup.POST("/person/info", v1.PostUserPersonInfo)
|
||||||
|
|||||||
@ -1050,7 +1050,8 @@ func PutAppUpdate(c *gin.Context) {
|
|||||||
// @Success 200 {string} string "ok"
|
// @Success 200 {string} string "ok"
|
||||||
// @Router /app/order [get]
|
// @Router /app/order [get]
|
||||||
func GetAppOrder(c *gin.Context) {
|
func GetAppOrder(c *gin.Context) {
|
||||||
data := service.MyService.System().GetAppOrderFile()
|
id := c.GetHeader("user_id")
|
||||||
|
data := service.MyService.System().GetAppOrderFile(id)
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json.RawMessage(data)})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json.RawMessage(data)})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1063,7 +1064,8 @@ func GetAppOrder(c *gin.Context) {
|
|||||||
// @Router /app/order [post]
|
// @Router /app/order [post]
|
||||||
func PostAppOrder(c *gin.Context) {
|
func PostAppOrder(c *gin.Context) {
|
||||||
data := c.PostForm("data")
|
data := c.PostForm("data")
|
||||||
service.MyService.System().UpAppOrderFile(data)
|
id := c.GetHeader("user_id")
|
||||||
|
service.MyService.System().UpAppOrderFile(data, id)
|
||||||
c.JSON(http.StatusOK,
|
c.JSON(http.StatusOK,
|
||||||
model.Result{
|
model.Result{
|
||||||
Success: common_err.SUCCESS,
|
Success: common_err.SUCCESS,
|
||||||
|
|||||||
@ -392,7 +392,7 @@ func GetFileUpload(c *gin.Context) {
|
|||||||
path := c.Query("path")
|
path := c.Query("path")
|
||||||
dirPath := ""
|
dirPath := ""
|
||||||
hash := file.GetHashByContent([]byte(fileName))
|
hash := file.GetHashByContent([]byte(fileName))
|
||||||
tempDir := config.AppInfo.RootPath + "/temp/" + hash + strconv.Itoa(totalChunks) + "/"
|
tempDir := config.AppInfo.TempPath + "/" + hash + strconv.Itoa(totalChunks) + "/"
|
||||||
if fileName != relative {
|
if fileName != relative {
|
||||||
dirPath = strings.TrimSuffix(relative, fileName)
|
dirPath = strings.TrimSuffix(relative, fileName)
|
||||||
tempDir += dirPath
|
tempDir += dirPath
|
||||||
@ -431,7 +431,7 @@ func PostFileUpload(c *gin.Context) {
|
|||||||
c.JSON(common_err.INVALID_PARAMS, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
c.JSON(common_err.INVALID_PARAMS, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
tempDir := config.AppInfo.RootPath + "/temp/" + hash + strconv.Itoa(totalChunks) + "/"
|
tempDir := config.AppInfo.TempPath + "/" + hash + strconv.Itoa(totalChunks) + "/"
|
||||||
|
|
||||||
if fileName != relative {
|
if fileName != relative {
|
||||||
dirPath = strings.TrimSuffix(relative, fileName)
|
dirPath = strings.TrimSuffix(relative, fileName)
|
||||||
|
|||||||
@ -181,7 +181,7 @@ func GetPersonDownloadList(c *gin.Context) {
|
|||||||
//if it is downloading, it need to add 'already'
|
//if it is downloading, it need to add 'already'
|
||||||
for i := 0; i < len(list); i++ {
|
for i := 0; i < len(list); i++ {
|
||||||
if list[i].State == types.DOWNLOADING {
|
if list[i].State == types.DOWNLOADING {
|
||||||
tempDir := config.AppInfo.RootPath + "/temp" + "/" + list[i].UUID
|
tempDir := config.AppInfo.TempPath + "/" + list[i].UUID
|
||||||
files, err := ioutil.ReadDir(tempDir)
|
files, err := ioutil.ReadDir(tempDir)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
list[i].Already = len(files)
|
list[i].Already = len(files)
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import (
|
|||||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||||
"github.com/IceWhaleTech/CasaOS/types"
|
"github.com/IceWhaleTech/CasaOS/types"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Summary check version
|
// @Summary check version
|
||||||
@ -222,19 +223,21 @@ func PutCasaOSPort(c *gin.Context) {
|
|||||||
// @Tags sys
|
// @Tags sys
|
||||||
// @Security ApiKeyAuth
|
// @Security ApiKeyAuth
|
||||||
// @Success 200 {string} string "ok"
|
// @Success 200 {string} string "ok"
|
||||||
// @Router /guide/check [get]
|
// @Router /sys/init/check [get]
|
||||||
func GetGuideCheck(c *gin.Context) {
|
func GetGuideCheck(c *gin.Context) {
|
||||||
initUser := false
|
data := make(map[string]interface{}, 2)
|
||||||
if !config.UserInfo.Initialized {
|
|
||||||
initUser = true
|
if service.MyService.User().GetUserCount() > 0 {
|
||||||
|
data["initialized"] = true
|
||||||
|
} else {
|
||||||
|
data["key"] = uuid.NewV4().String()
|
||||||
|
data["initialized"] = false
|
||||||
}
|
}
|
||||||
data := make(map[string]interface{}, 1)
|
|
||||||
data["need_init_user"] = initUser
|
|
||||||
c.JSON(http.StatusOK,
|
c.JSON(http.StatusOK,
|
||||||
model.Result{
|
model.Result{
|
||||||
Success: common_err.SUCCESS,
|
Success: common_err.SUCCESS,
|
||||||
Message: common_err.GetMsg(common_err.SUCCESS),
|
Message: common_err.GetMsg(common_err.SUCCESS),
|
||||||
Data: data,
|
Data: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,14 +550,14 @@ func PostSystemRefreshToken(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.VERIFICATION_FAILURE, Message: common_err.GetMsg(common_err.VERIFICATION_FAILURE)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newToken := jwt.GetAccessToken(claims.UserName, claims.PassWord)
|
newToken := jwt.GetAccessToken(claims.UserName, claims.PassWord, claims.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR), Data: err.Error()})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR), Data: err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
verifyInfo := system_model.VerifyInformation{}
|
verifyInfo := system_model.VerifyInformation{}
|
||||||
verifyInfo.AccessToken = newToken
|
verifyInfo.AccessToken = newToken
|
||||||
verifyInfo.RefreshToken = jwt.GetRefreshToken(claims.UserName, claims.PassWord)
|
verifyInfo.RefreshToken = jwt.GetRefreshToken(claims.UserName, claims.PassWord, claims.Id)
|
||||||
verifyInfo.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Format("2006-01-02 15:04:05")
|
verifyInfo.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Format("2006-01-02 15:04:05")
|
||||||
|
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: verifyInfo})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: verifyInfo})
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS/model"
|
"github.com/IceWhaleTech/CasaOS/model"
|
||||||
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/encryption"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/encryption"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/jwt"
|
||||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||||
|
|
||||||
@ -25,8 +26,11 @@ func PostUserRegister(c *gin.Context) {
|
|||||||
username := json["user_name"]
|
username := json["user_name"]
|
||||||
pwd := json["password"]
|
pwd := json["password"]
|
||||||
key := c.GetHeader("key")
|
key := c.GetHeader("key")
|
||||||
//TODO:检查hash
|
if _, ok := service.UserRegisterHash[key]; !ok {
|
||||||
fmt.Println(key)
|
c.JSON(http.StatusOK,
|
||||||
|
model.Result{Success: common_err.KEY_NOT_EXIST, Message: common_err.GetMsg(common_err.KEY_NOT_EXIST)})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(username) == 0 || len(pwd) == 0 {
|
if len(username) == 0 || len(pwd) == 0 {
|
||||||
c.JSON(http.StatusOK,
|
c.JSON(http.StatusOK,
|
||||||
@ -55,7 +59,8 @@ func PostUserRegister(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR)})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR)})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//TODO:创建文件夹
|
file.MkDir(config.AppInfo.UserDataPath + "/" + strconv.Itoa(user.Id))
|
||||||
|
delete(service.UserRegisterHash, key)
|
||||||
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS)})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -96,8 +101,8 @@ func Login(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
user.Password = ""
|
user.Password = ""
|
||||||
token := system_model.VerifyInformation{}
|
token := system_model.VerifyInformation{}
|
||||||
token.AccessToken = jwt.GetAccessToken(user.UserName, user.Password)
|
token.AccessToken = jwt.GetAccessToken(user.UserName, user.Password, user.Id)
|
||||||
token.RefreshToken = jwt.GetRefreshToken(user.UserName, user.Password)
|
token.RefreshToken = jwt.GetRefreshToken(user.UserName, user.Password, user.Id)
|
||||||
token.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Format("2006-01-02 15:04:05")
|
token.ExpiresAt = time.Now().Add(3 * time.Hour * time.Duration(1)).Format("2006-01-02 15:04:05")
|
||||||
data := make(map[string]interface{}, 2)
|
data := make(map[string]interface{}, 2)
|
||||||
data["token"] = token
|
data["token"] = token
|
||||||
|
|||||||
32
route/v1/zima_info.go
Normal file
32
route/v1/zima_info.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.com
|
||||||
|
* @Date: 2021-09-30 18:18:14
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-06-16 17:54:10
|
||||||
|
* @FilePath: /CasaOS/route/v1/zima_info.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
|
package v1
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/IceWhaleTech/CasaOS/model"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// @Summary 获取信息系统信息
|
||||||
|
// @Produce application/json
|
||||||
|
// @Accept application/json
|
||||||
|
// @Tags zima
|
||||||
|
// @Security ApiKeyAuth
|
||||||
|
// @Success 200 {string} string "ok"
|
||||||
|
// @Router /zima/sysinfo [get]
|
||||||
|
func SysInfo(c *gin.Context) {
|
||||||
|
info := service.MyService.ZiMa().GetSysInfo()
|
||||||
|
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: info})
|
||||||
|
}
|
||||||
@ -403,7 +403,7 @@ func (a *appStruct) UpdateApp(m model2.AppListDBModel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *appStruct) DelAppConfigDir(path string) {
|
func (a *appStruct) DelAppConfigDir(path string) {
|
||||||
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;DelAppConfigDir " + path)
|
command.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;DelAppConfigDir " + path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *appStruct) DeleteApp(id string) {
|
func (a *appStruct) DeleteApp(id string) {
|
||||||
|
|||||||
@ -74,31 +74,31 @@ func (d *diskService) SmartCTL(path string) model.SmartctlA {
|
|||||||
|
|
||||||
//通过脚本获取外挂磁盘
|
//通过脚本获取外挂磁盘
|
||||||
func (d *diskService) GetPlugInDisk() []string {
|
func (d *diskService) GetPlugInDisk() []string {
|
||||||
return command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetPlugInDisk")
|
return command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetPlugInDisk")
|
||||||
}
|
}
|
||||||
|
|
||||||
//格式化硬盘
|
//格式化硬盘
|
||||||
func (d *diskService) FormatDisk(path, format string) []string {
|
func (d *diskService) FormatDisk(path, format string) []string {
|
||||||
r := command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;FormatDisk " + path + " " + format)
|
r := command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;FormatDisk " + path + " " + format)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
//移除挂载点,删除目录
|
//移除挂载点,删除目录
|
||||||
func (d *diskService) UmountPointAndRemoveDir(path string) []string {
|
func (d *diskService) UmountPointAndRemoveDir(path string) []string {
|
||||||
r := command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;UMountPorintAndRemoveDir " + path)
|
r := command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;UMountPorintAndRemoveDir " + path)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除分区
|
//删除分区
|
||||||
func (d *diskService) DelPartition(path, num string) string {
|
func (d *diskService) DelPartition(path, num string) string {
|
||||||
r := command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;DelPartition " + path + " " + num)
|
r := command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;DelPartition " + path + " " + num)
|
||||||
fmt.Println(r)
|
fmt.Println(r)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
//part
|
//part
|
||||||
func (d *diskService) AddPartition(path string) string {
|
func (d *diskService) AddPartition(path string) string {
|
||||||
command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;AddPartition " + path)
|
command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;AddPartition " + path)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ func (d *diskService) LSBLK(isUseCache bool) []model.LSBLKModel {
|
|||||||
fsused = 0
|
fsused = 0
|
||||||
for _, child := range i.Children {
|
for _, child := range i.Children {
|
||||||
if child.RM {
|
if child.RM {
|
||||||
child.Health = strings.TrimSpace(command2.ExecResultStr("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetDiskHealthState " + child.Path))
|
child.Health = strings.TrimSpace(command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetDiskHealthState " + child.Path))
|
||||||
if strings.ToLower(strings.TrimSpace(child.State)) != "ok" {
|
if strings.ToLower(strings.TrimSpace(child.State)) != "ok" {
|
||||||
health = false
|
health = false
|
||||||
}
|
}
|
||||||
@ -163,7 +163,7 @@ func (d *diskService) LSBLK(isUseCache bool) []model.LSBLKModel {
|
|||||||
}
|
}
|
||||||
c = append(c, child)
|
c = append(c, child)
|
||||||
}
|
}
|
||||||
i.Format = strings.TrimSpace(command2.ExecResultStr("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetDiskType " + i.Path))
|
i.Format = strings.TrimSpace(command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetDiskType " + i.Path))
|
||||||
if health {
|
if health {
|
||||||
i.Health = "OK"
|
i.Health = "OK"
|
||||||
}
|
}
|
||||||
@ -208,7 +208,7 @@ func (d *diskService) GetDiskInfo(path string) model.LSBLKModel {
|
|||||||
return m
|
return m
|
||||||
// 下面为计算是否可以继续分区的部分,暂时不需要
|
// 下面为计算是否可以继续分区的部分,暂时不需要
|
||||||
chiArr := make(map[string]string)
|
chiArr := make(map[string]string)
|
||||||
chiList := command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetPartitionSectors " + m.Path)
|
chiList := command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetPartitionSectors " + m.Path)
|
||||||
if len(chiList) == 0 {
|
if len(chiList) == 0 {
|
||||||
loger.Error("chiList length error", zap.Any("err", "chiList length error"))
|
loger.Error("chiList length error", zap.Any("err", "chiList length error"))
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ func (d *diskService) GetDiskInfo(path string) model.LSBLKModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
diskEndSector := command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetDiskSizeAndSectors " + m.Path)
|
diskEndSector := command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetDiskSizeAndSectors " + m.Path)
|
||||||
|
|
||||||
if len(diskEndSector) < 2 {
|
if len(diskEndSector) < 2 {
|
||||||
loger.Error("diskEndSector length error", zap.Any("err", "diskEndSector length error"))
|
loger.Error("diskEndSector length error", zap.Any("err", "diskEndSector length error"))
|
||||||
@ -242,7 +242,7 @@ func (d *diskService) GetDiskInfo(path string) model.LSBLKModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *diskService) MountDisk(path, volume string) {
|
func (d *diskService) MountDisk(path, volume string) {
|
||||||
r := command2.ExecResultStr("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;do_mount " + path + " " + volume)
|
r := command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;do_mount " + path + " " + volume)
|
||||||
fmt.Print(r)
|
fmt.Print(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ func (d *diskService) DeleteMountPoint(path, mountPoint string) {
|
|||||||
|
|
||||||
d.db.Where("path = ? AND mount_point = ?", path, mountPoint).Delete(&model2.SerialDisk{})
|
d.db.Where("path = ? AND mount_point = ?", path, mountPoint).Delete(&model2.SerialDisk{})
|
||||||
|
|
||||||
command2.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;do_umount " + path)
|
command2.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;do_umount " + path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *diskService) GetSerialAll() []model2.SerialDisk {
|
func (d *diskService) GetSerialAll() []model2.SerialDisk {
|
||||||
|
|||||||
@ -310,7 +310,7 @@ func (s *shareDirService) UpConfig() {
|
|||||||
} else {
|
} else {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
f.WriteString(str)
|
f.WriteString(str)
|
||||||
command.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;ReloadSamba")
|
command.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;ReloadSamba")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func (s *shareDirService) Info(id string) model.ShareDirDBModel {
|
func (s *shareDirService) Info(id string) model.ShareDirDBModel {
|
||||||
|
|||||||
@ -26,8 +26,8 @@ type SystemService interface {
|
|||||||
GetTimeZone() string
|
GetTimeZone() string
|
||||||
UpdateUSBAutoMount(state string)
|
UpdateUSBAutoMount(state string)
|
||||||
ExecUSBAutoMountShell(state string)
|
ExecUSBAutoMountShell(state string)
|
||||||
UpAppOrderFile(str string)
|
UpAppOrderFile(str, id string)
|
||||||
GetAppOrderFile() []byte
|
GetAppOrderFile(id string) []byte
|
||||||
GetNet(physics bool) []string
|
GetNet(physics bool) []string
|
||||||
GetNetInfo() []net.IOCountersStat
|
GetNetInfo() []net.IOCountersStat
|
||||||
GetCpuCoreNum() int
|
GetCpuCoreNum() int
|
||||||
@ -64,34 +64,34 @@ func (c *systemService) GetNet(physics bool) []string {
|
|||||||
if physics {
|
if physics {
|
||||||
t = "2"
|
t = "2"
|
||||||
}
|
}
|
||||||
return command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetNetCard " + t)
|
return command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetNetCard " + t)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) UpdateSystemVersion(version string) {
|
func (s *systemService) UpdateSystemVersion(version string) {
|
||||||
//command2.OnlyExec(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
//command2.OnlyExec(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
||||||
//s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
//s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
|
||||||
s.log.Error(command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/tools.sh ;update " + version))
|
s.log.Error(command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/tools.sh ;update " + version))
|
||||||
//s.log.Error(command2.ExecResultStr(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version))
|
//s.log.Error(command2.ExecResultStr(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version))
|
||||||
}
|
}
|
||||||
func (s *systemService) UpdateAssist() {
|
func (s *systemService) UpdateAssist() {
|
||||||
s.log.Error(command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/assist.sh"))
|
s.log.Error(command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/assist.sh"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) GetTimeZone() string {
|
func (s *systemService) GetTimeZone() string {
|
||||||
return command2.ExecResultStr("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetTimeZone")
|
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetTimeZone")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) ExecUSBAutoMountShell(state string) {
|
func (s *systemService) ExecUSBAutoMountShell(state string) {
|
||||||
if state == "False" {
|
if state == "False" {
|
||||||
command2.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;USB_Remove_File")
|
command2.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;USB_Remove_File")
|
||||||
} else {
|
} else {
|
||||||
command2.OnlyExec("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;USB_Move_File")
|
command2.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;USB_Move_File")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) GetSystemConfigDebug() []string {
|
func (s *systemService) GetSystemConfigDebug() []string {
|
||||||
return command2.ExecResultStrArray("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetSysInfo")
|
return command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/helper.sh ;GetSysInfo")
|
||||||
}
|
}
|
||||||
func (s *systemService) UpSystemConfig(str string, widget string) {
|
func (s *systemService) UpSystemConfig(str string, widget string) {
|
||||||
if len(str) > 0 && str != config.SystemConfigInfo.ConfigStr {
|
if len(str) > 0 && str != config.SystemConfigInfo.ConfigStr {
|
||||||
@ -104,11 +104,11 @@ func (s *systemService) UpSystemConfig(str string, widget string) {
|
|||||||
}
|
}
|
||||||
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
config.Cfg.SaveTo(config.SystemConfigInfo.ConfigPath)
|
||||||
}
|
}
|
||||||
func (s *systemService) UpAppOrderFile(str string) {
|
func (s *systemService) UpAppOrderFile(str, id string) {
|
||||||
file.WriteToPath([]byte(str), config.AppInfo.ProjectPath+"/conf", "app_order.json")
|
file.WriteToPath([]byte(str), config.AppInfo.DBPath+"/"+id, "app_order.json")
|
||||||
}
|
}
|
||||||
func (s *systemService) GetAppOrderFile() []byte {
|
func (s *systemService) GetAppOrderFile(id string) []byte {
|
||||||
return file.ReadFullFile(config.AppInfo.ProjectPath + "/conf/app_order.json")
|
return file.ReadFullFile(config.AppInfo.UserDataPath + "/" + id + "/app_order.json")
|
||||||
}
|
}
|
||||||
func (s *systemService) UpdateUSBAutoMount(state string) {
|
func (s *systemService) UpdateUSBAutoMount(state string) {
|
||||||
config.ServerInfo.USBAutoMount = state
|
config.ServerInfo.USBAutoMount = state
|
||||||
|
|||||||
@ -186,7 +186,7 @@ func ReadContent(stream quic.Stream) {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
time.Sleep(time.Second * 1)
|
time.Sleep(time.Second * 1)
|
||||||
for k, v := range CancelList {
|
for k, v := range CancelList {
|
||||||
tempPath := config.AppInfo.RootPath + "/temp" + "/" + v
|
tempPath := config.AppInfo.TempPath + "/" + v
|
||||||
fmt.Println(file.RMDir(tempPath))
|
fmt.Println(file.RMDir(tempPath))
|
||||||
delete(CancelList, k)
|
delete(CancelList, k)
|
||||||
}
|
}
|
||||||
@ -445,7 +445,7 @@ func SaveFile(m model.MessageModel, stream quic.Stream) bool {
|
|||||||
fmt.Println("hash不匹配", hash, dataModel.Hash)
|
fmt.Println("hash不匹配", hash, dataModel.Hash)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
tempPath := config.AppInfo.RootPath + "/temp" + "/" + m.UUId
|
tempPath := config.AppInfo.TempPath + "/" + m.UUId
|
||||||
file.IsNotExistMkDir(tempPath)
|
file.IsNotExistMkDir(tempPath)
|
||||||
filepath := tempPath + "/" + strconv.Itoa(dataModel.Index)
|
filepath := tempPath + "/" + strconv.Itoa(dataModel.Index)
|
||||||
_, err = os.Stat(filepath)
|
_, err = os.Stat(filepath)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2022-03-18 11:40:55
|
* @Date: 2022-03-18 11:40:55
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-06-15 17:09:20
|
* @LastEditTime: 2022-06-16 19:08:09
|
||||||
* @FilePath: /CasaOS/service/user.go
|
* @FilePath: /CasaOS/service/user.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@ -31,6 +31,8 @@ type UserService interface {
|
|||||||
GetAllUserName() (list []model.UserDBModel)
|
GetAllUserName() (list []model.UserDBModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var UserRegisterHash = make(map[string]string)
|
||||||
|
|
||||||
type userService struct {
|
type userService struct {
|
||||||
db *gorm.DB
|
db *gorm.DB
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,12 +115,12 @@ func (c *zima) GetSysInfo() host.InfoStat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *zima) GetDeviceTree() string {
|
func (c *zima) GetDeviceTree() string {
|
||||||
return command2.ExecResultStr("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;GetDeviceTree")
|
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;GetDeviceTree")
|
||||||
}
|
}
|
||||||
|
|
||||||
//shell脚本参数 { 网卡名称 }
|
//shell脚本参数 { 网卡名称 }
|
||||||
func (c *zima) GetNetState(name string) string {
|
func (c *zima) GetNetState(name string) string {
|
||||||
return command2.ExecResultStr("source " + config.AppInfo.ProjectPath + "/shell/helper.sh ;CatNetCardState " + name)
|
return command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;CatNetCardState " + name)
|
||||||
}
|
}
|
||||||
|
|
||||||
//mkdir
|
//mkdir
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user