mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-12-23 21:14:41 +00:00
Compare commits
6 Commits
v0.3.3
...
v0.3.3-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd73141ddf | ||
|
|
346b0f5d97 | ||
|
|
d4b4b75012 | ||
|
|
cb33ffbb46 | ||
|
|
85188d0b05 | ||
|
|
1e60c26920 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,6 +31,7 @@ gen
|
|||||||
/docs/
|
/docs/
|
||||||
/web/
|
/web/
|
||||||
/conf/conf.ini
|
/conf/conf.ini
|
||||||
|
/conf/conf.conf
|
||||||
/conf/conf.json
|
/conf/conf.json
|
||||||
__debug_bin
|
__debug_bin
|
||||||
main
|
main
|
||||||
|
|||||||
4
alpha.md
4
alpha.md
@@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2022-06-27 11:37:26
|
* @Date: 2022-06-27 11:37:26
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-06-30 14:16:31
|
* @LastEditTime: 2022-07-01 15:51:29
|
||||||
* @FilePath: /CasaOS/alpha.md
|
* @FilePath: /CasaOS/alpha.md
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@@ -17,7 +17,7 @@ There is a risk of data loss in non-release versions, so please be careful to ba
|
|||||||
|
|
||||||
## Install/Update
|
## Install/Update
|
||||||
|
|
||||||
``` curl -fsSL https://get.casaos.io | bash -v v0.3.3-alpha ```
|
``` curl -fsSL https://get.casaos.io | bash -s -- -v v0.3.3-alpha ```
|
||||||
|
|
||||||
## Check change log
|
## Check change log
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
[app]
|
|
||||||
PAGE_SIZE = 10
|
|
||||||
RuntimeRootPath = runtime/
|
|
||||||
LogPath = ./CasaOS/logs/server/
|
|
||||||
LogSaveName = log
|
|
||||||
LogFileExt = log
|
|
||||||
DateStrFormat = 20060102
|
|
||||||
DateTimeFormat = 2006-01-02 15:04:05
|
|
||||||
TimeFormat = 15:04:05
|
|
||||||
DateFormat = 2006-01-02
|
|
||||||
DBPath = ./CasaOS/server/db
|
|
||||||
ShellPath = ./CasaOS/server/shell
|
|
||||||
UserDataPath = ./CasaOS/conf
|
|
||||||
TempPath = ./CasaOS/temp
|
|
||||||
|
|
||||||
[server]
|
|
||||||
HttpPort = 8089
|
|
||||||
UDPPort = 54216
|
|
||||||
RunMode = release
|
|
||||||
;ServerApi = https://api.casaos.io/casaos-api
|
|
||||||
ServerApi = http://127.0.0.1:8091
|
|
||||||
Handshake = socket.casaos.io
|
|
||||||
Token = af268e4f-9f3a-408a-b59b-cf1a4f7f88c8
|
|
||||||
USBAutoMount =
|
|
||||||
SocketPort = 58313
|
|
||||||
|
|
||||||
[system]
|
|
||||||
ConfigStr = {"auto_update":false,"background":"","background_type":"","search_engine":"https://duckduckgo.com/?q=","search_switch":false,"shortcuts_switch":false,"widgets_switch":false,"lang":"en_us"}
|
|
||||||
WidgetList = [{"name":"clock","show":true},{"name":"cpu","show":true},{"name":"disks","show":true},{"name":"network","show":true}]
|
|
||||||
|
|
||||||
[file]
|
|
||||||
ShareDir =
|
|
||||||
DownloadDir = ./CasaOS/DATA/Downloads
|
|
||||||
|
|
||||||
[user]
|
|
||||||
Description = nothing
|
|
||||||
UserName = casaos
|
|
||||||
Initialized = true
|
|
||||||
PWD = 123456
|
|
||||||
|
|
||||||
@@ -524,3 +524,26 @@ func DirSizeB(path string) (int64, error) {
|
|||||||
})
|
})
|
||||||
return size, err
|
return size, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MoveFile(sourcePath, destPath string) error {
|
||||||
|
inputFile, err := os.Open(sourcePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Couldn't open source file: %s", err)
|
||||||
|
}
|
||||||
|
outputFile, err := os.Create(destPath)
|
||||||
|
if err != nil {
|
||||||
|
inputFile.Close()
|
||||||
|
return fmt.Errorf("Couldn't open dest file: %s", err)
|
||||||
|
}
|
||||||
|
defer outputFile.Close()
|
||||||
|
_, err = io.Copy(outputFile, inputFile)
|
||||||
|
inputFile.Close()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Writing to output file failed: %s", err)
|
||||||
|
}
|
||||||
|
err = os.Remove(sourcePath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed removing original file: %s", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2022-06-17 14:01:25
|
* @Date: 2022-06-17 14:01:25
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-06-24 10:13:52
|
* @LastEditTime: 2022-07-04 16:26:22
|
||||||
* @FilePath: /CasaOS/pkg/utils/jwt/jwt_helper.go
|
* @FilePath: /CasaOS/pkg/utils/jwt/jwt_helper.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@@ -11,12 +11,10 @@
|
|||||||
package jwt
|
package jwt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS/model"
|
"github.com/IceWhaleTech/CasaOS/model"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
|
||||||
loger2 "github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -109,7 +107,7 @@ func GetToken(username, pwd string) string {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return token
|
return token
|
||||||
} else {
|
} else {
|
||||||
loger2.NewOLoger().Fatal(fmt.Sprintf("Get Token Fail: %V", err))
|
//loger2.NewOLoger().Fatal(fmt.Sprintf("Get Token Fail: %V", err))
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
package loger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
|
||||||
file2 "github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
|
||||||
)
|
|
||||||
|
|
||||||
//定义一个int的别名
|
|
||||||
type Level int
|
|
||||||
|
|
||||||
type OLog interface {
|
|
||||||
Debug(v ...interface{})
|
|
||||||
Info(v ...interface{})
|
|
||||||
Warn(v ...interface{})
|
|
||||||
Error(v ...interface{})
|
|
||||||
Fatal(v ...interface{})
|
|
||||||
Path() string
|
|
||||||
}
|
|
||||||
|
|
||||||
type oLog struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
F *os.File
|
|
||||||
DefaultPrefix = ""
|
|
||||||
DefaultCallerDepth = 2
|
|
||||||
logger *log.Logger
|
|
||||||
logPrefix = ""
|
|
||||||
levelFlags = []string{"DEBUG", "INFO", "WARN", "ERROR", "FATAL"}
|
|
||||||
)
|
|
||||||
|
|
||||||
//iota在const关键字出现时将被重置为0(const内部的第一行之前),const中每新增一行常量声明将使iota计数一次(iota可理解为const语句块中的行索引)。
|
|
||||||
const (
|
|
||||||
DEBUG Level = iota
|
|
||||||
INFO
|
|
||||||
WARN
|
|
||||||
ERROR
|
|
||||||
FATAL
|
|
||||||
)
|
|
||||||
|
|
||||||
//日志初始化
|
|
||||||
func LogSetupOld() {
|
|
||||||
var err error
|
|
||||||
filePath := fmt.Sprintf("%s", config.AppInfo.LogPath)
|
|
||||||
fileName := fmt.Sprintf("%s.%s",
|
|
||||||
config.AppInfo.LogSaveName,
|
|
||||||
config.AppInfo.LogFileExt,
|
|
||||||
)
|
|
||||||
F, err = file2.MustOpen(fileName, filePath)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("logging.Setup err: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
logger = log.New(F, DefaultPrefix, log.LstdFlags)
|
|
||||||
|
|
||||||
}
|
|
||||||
func (o *oLog) Path() string {
|
|
||||||
filePath := fmt.Sprintf("%s", config.AppInfo.LogPath)
|
|
||||||
fileName := fmt.Sprintf("%s.%s",
|
|
||||||
config.AppInfo.LogSaveName,
|
|
||||||
config.AppInfo.LogFileExt,
|
|
||||||
)
|
|
||||||
return filePath + fileName
|
|
||||||
}
|
|
||||||
func (o *oLog) Debug(v ...interface{}) {
|
|
||||||
setPrefix(DEBUG)
|
|
||||||
logger.Println(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *oLog) Info(v ...interface{}) {
|
|
||||||
setPrefix(INFO)
|
|
||||||
logger.Println(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *oLog) Warn(v ...interface{}) {
|
|
||||||
setPrefix(WARN)
|
|
||||||
logger.Println(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *oLog) Error(v ...interface{}) {
|
|
||||||
setPrefix(ERROR)
|
|
||||||
logger.Println(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (o *oLog) Fatal(v ...interface{}) {
|
|
||||||
setPrefix(FATAL)
|
|
||||||
logger.Println(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
func setPrefix(level Level) {
|
|
||||||
_, file, line, ok := runtime.Caller(DefaultCallerDepth)
|
|
||||||
if ok {
|
|
||||||
logPrefix = fmt.Sprintf("[%s][%s:%d]", levelFlags[level], filepath.Base(file), line)
|
|
||||||
} else {
|
|
||||||
logPrefix = fmt.Sprintf("[%s]", levelFlags[level])
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.SetPrefix(logPrefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewOLoger() OLog {
|
|
||||||
return &oLog{}
|
|
||||||
}
|
|
||||||
@@ -518,7 +518,6 @@ func PostOperateFileOrDir(c *gin.Context) {
|
|||||||
uid := uuid.NewV4().String()
|
uid := uuid.NewV4().String()
|
||||||
service.FileQueue.Store(uid, list)
|
service.FileQueue.Store(uid, list)
|
||||||
service.OpStrArr = append(service.OpStrArr, uid)
|
service.OpStrArr = append(service.OpStrArr, uid)
|
||||||
|
|
||||||
if len(service.OpStrArr) == 1 {
|
if len(service.OpStrArr) == 1 {
|
||||||
go service.ExecOpFile()
|
go service.ExecOpFile()
|
||||||
go service.CheckFileStatus()
|
go service.CheckFileStatus()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* @Author: LinkLeong link@icewhale.com
|
* @Author: LinkLeong link@icewhale.com
|
||||||
* @Date: 2021-12-20 14:15:46
|
* @Date: 2021-12-20 14:15:46
|
||||||
* @LastEditors: LinkLeong
|
* @LastEditors: LinkLeong
|
||||||
* @LastEditTime: 2022-06-16 16:47:46
|
* @LastEditTime: 2022-07-04 16:18:23
|
||||||
* @FilePath: /CasaOS/service/file.go
|
* @FilePath: /CasaOS/service/file.go
|
||||||
* @Description:
|
* @Description:
|
||||||
* @Website: https://www.casaos.io
|
* @Website: https://www.casaos.io
|
||||||
@@ -101,12 +101,16 @@ func FileOperate(k string) {
|
|||||||
os.RemoveAll(temp.To + "/" + lastPath)
|
os.RemoveAll(temp.To + "/" + lastPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := os.Rename(v.From, temp.To+"/"+lastPath)
|
err := os.Rename(v.From, temp.To+"/"+lastPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
loger.Debug("file move error", zap.Any("err", err))
|
loger.Error("file move error", zap.Any("err", err))
|
||||||
|
err = file.MoveFile(v.From, temp.To+"/"+lastPath)
|
||||||
|
if err != nil {
|
||||||
|
loger.Error("MoveFile error", zap.Any("err", err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} else if temp.Type == "copy" {
|
} else if temp.Type == "copy" {
|
||||||
err := file.CopyDir(v.From, temp.To, temp.Style)
|
err := file.CopyDir(v.From, temp.To, temp.Style)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user