diff --git a/.gitignore b/.gitignore index 51d11d0..411aba3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ __debug_bin main github.com .all-contributorsrc -dist \ No newline at end of file +dist +CasaOS \ No newline at end of file diff --git a/build/scripts/migration/script.d/03-migrate-casaos.sh b/build/scripts/migration/script.d/03-migrate-casaos.sh index ba64e4d..a48c437 100644 --- a/build/scripts/migration/script.d/03-migrate-casaos.sh +++ b/build/scripts/migration/script.d/03-migrate-casaos.sh @@ -60,8 +60,8 @@ BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. SOURCE_ROOT=${BUILD_PATH}/sysroot APP_NAME="casaos" -# APP_NAME_FORMAL="CasaOS" -APP_NAME_FORMAL="casaos-alpha" +APP_NAME_FORMAL="CasaOS" +#APP_NAME_FORMAL="casaos-alpha" # check if migration is needed SOURCE_BIN_PATH=${SOURCE_ROOT}/usr/bin @@ -153,7 +153,8 @@ pushd "${MIGRATION_SERVICE_DIR}" continue fi - MIGRATION_TOOL_URL=https://github.com/LinkLeong/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz + # MIGRATION_TOOL_URL=http://192.168.2.197:8000/v1/package/migration?type=release&name="${APP_NAME_FORMAL}"&version=${VER2}&arch=${ARCH} + MIGRATION_TOOL_URL=https://github.com/IceWhaleTech/"${APP_NAME_FORMAL}"/releases/download/"${VER2}"/linux-"${ARCH}"-"${APP_NAME}"-migration-tool-"${VER2}".tar.gz echo "Dowloading ${MIGRATION_TOOL_URL}..." curl -sL -O "${MIGRATION_TOOL_URL}" done diff --git a/build/sysroot/etc/casaos/casaos.conf.sample b/build/sysroot/etc/casaos/casaos.conf.sample index 3e64508..e51f0fa 100644 --- a/build/sysroot/etc/casaos/casaos.conf.sample +++ b/build/sysroot/etc/casaos/casaos.conf.sample @@ -11,7 +11,6 @@ DateFormat = 2006-01-02 DBPath = /var/lib/casaos ShellPath = /usr/share/casaos/shell UserDataPath = /var/lib/casaos/conf -TempPath = /var/lib/casaos/temp [server] RunMode = release diff --git a/conf/conf.conf.sample b/conf/conf.conf.sample index 5ce1d0e..1364418 100644 --- a/conf/conf.conf.sample +++ b/conf/conf.conf.sample @@ -11,7 +11,6 @@ DateFormat = 2006-01-02 DBPath = /var/lib/casaos ShellPath = /usr/share/casaos/shell UserDataPath = /var/lib/casaos/conf -TempPath = /var/lib/casaos/temp [server] RunMode = release diff --git a/model/sys_common.go b/model/sys_common.go index 1a78867..73316b0 100644 --- a/model/sys_common.go +++ b/model/sys_common.go @@ -12,12 +12,12 @@ package model import "time" -//系统配置 +// 系统配置 type SysInfoModel struct { Name string //系统名称 } -//服务配置 +// 服务配置 type ServerModel struct { HttpPort string RunMode string @@ -28,7 +28,7 @@ type ServerModel struct { SocketPort string } -//服务配置 +// 服务配置 type APPModel struct { LogPath string LogSaveName string @@ -40,20 +40,19 @@ type APPModel struct { DateFormat string DBPath string ShellPath string - TempPath string } type CommonModel struct { RuntimePath string } -//公共返回模型 +// 公共返回模型 type Result struct { Success int `json:"success" example:"200"` Message string `json:"message" example:"ok"` Data interface{} `json:"data" example:"返回结果"` } -//redis配置文件 +// redis配置文件 type RedisModel struct { Host string Password string diff --git a/pkg/config/init.go b/pkg/config/init.go index c79d71f..b2de00f 100644 --- a/pkg/config/init.go +++ b/pkg/config/init.go @@ -23,17 +23,17 @@ import ( "github.com/go-ini/ini" ) -//系统配置 +// 系统配置 var SysInfo = &model.SysInfoModel{} -//用户相关 +// 用户相关 var AppInfo = &model.APPModel{} var CommonInfo = &model.CommonModel{} //var RedisInfo = &model.RedisModel{} -//server相关 +// server相关 var ServerInfo = &model.ServerModel{} var SystemConfigInfo = &model.SystemConfig{} @@ -44,7 +44,7 @@ var FileSettingInfo = &model.FileSetting{} var Cfg *ini.File -//初始化设置,获取系统的部分信息。 +// 初始化设置,获取系统的部分信息。 func InitSetup(config string) { var configDir = USERCONFIGURL @@ -86,9 +86,6 @@ func InitSetup(config string) { if len(AppInfo.UserDataPath) == 0 { AppInfo.UserDataPath = "/var/lib/casaos/conf" } - if len(AppInfo.TempPath) == 0 { - AppInfo.TempPath = "/var/lib/casaos/temp" - } if len(CommonInfo.RuntimePath) == 0 { CommonInfo.RuntimePath = "/var/run/casaos" } @@ -97,7 +94,7 @@ func InitSetup(config string) { } -//映射 +// 映射 func mapTo(section string, v interface{}) { err := Cfg.Section(section).MapTo(v) if err != nil { diff --git a/route/v1/docker.go b/route/v1/docker.go index 8c1254f..4b7d4a4 100644 --- a/route/v1/docker.go +++ b/route/v1/docker.go @@ -761,7 +761,7 @@ func ChangAppState(c *gin.Context) { func ContainerLog(c *gin.Context) { appId := c.Param("id") log, _ := service.MyService.Docker().DockerContainerLog(appId) - c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: log}) + c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: string(log)}) } // @Summary 获取容器状态 diff --git a/route/v1/file.go b/route/v1/file.go index 548ee4a..396074d 100644 --- a/route/v1/file.go +++ b/route/v1/file.go @@ -16,7 +16,6 @@ import ( "sync" "github.com/IceWhaleTech/CasaOS/model" - "github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/utils/common_err" "github.com/IceWhaleTech/CasaOS/pkg/utils/file" "github.com/IceWhaleTech/CasaOS/service" @@ -267,6 +266,9 @@ func DirPath(c *gin.Context) { pathList := []model.Path{} for i := 0; i < len(info); i++ { + if info[i].Name == ".temp" && info[i].IsDir { + continue + } if _, ok := fileQueue[info[i].Path]; !ok { pathList = append(pathList, info[i]) } @@ -367,7 +369,7 @@ func GetFileUpload(c *gin.Context) { path := c.Query("path") dirPath := "" hash := file.GetHashByContent([]byte(fileName)) - tempDir := config.AppInfo.TempPath + "/" + hash + strconv.Itoa(totalChunks) + "/" + tempDir := filepath.Join(path, ".temp", hash+strconv.Itoa(totalChunks)) + "/" if fileName != relative { dirPath = strings.TrimSuffix(relative, fileName) tempDir += dirPath @@ -406,7 +408,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)}) return } - tempDir := config.AppInfo.TempPath + "/" + hash + strconv.Itoa(totalChunks) + "/" + tempDir := filepath.Join(path, ".temp", hash+strconv.Itoa(totalChunks)) + "/" if fileName != relative { dirPath = strings.TrimSuffix(relative, fileName) diff --git a/service/casa.go b/service/casa.go index f5a71d3..4d80bf4 100644 --- a/service/casa.go +++ b/service/casa.go @@ -130,10 +130,6 @@ func (o *casaService) AsyncGetServerList() (collection model.ServerAppListCollec errr := json2.Unmarshal(results, &collection) if errr != nil { loger.Error("marshal error", zap.Any("err", err), zap.Any("content", string(results))) - } else { - if collection.Version == o.GetCasaosVersion().Version { - return collection, err - } } head := make(map[string]string) @@ -204,10 +200,6 @@ func (o *casaService) AsyncGetServerCategoryList() ([]model.CategoryList, error) err := json2.Unmarshal(results, &list) if err != nil { loger.Error("marshal error", zap.Any("err", err), zap.Any("content", string(results))) - } else { - if list.Version == o.GetCasaosVersion().Version { - return list.Item, nil - } } item := []model.CategoryList{} head := make(map[string]string) diff --git a/service/docker.go b/service/docker.go index 812fb8a..f453c0b 100644 --- a/service/docker.go +++ b/service/docker.go @@ -52,7 +52,7 @@ type DockerService interface { DockerContainerStop(id string) error DockerContainerUpdateName(name, id string) (err error) DockerContainerUpdate(m model.CustomizationPostData, id string) (err error) - DockerContainerLog(name string) (string, error) + DockerContainerLog(name string) ([]byte, error) DockerContainerCommit(name string) DockerContainerList() []types.Container DockerNetworkModelList() []types.NetworkResource @@ -677,23 +677,26 @@ func (ds *dockerService) DockerContainerStart(name string) error { } // 查看日志 -func (ds *dockerService) DockerContainerLog(name string) (string, error) { +func (ds *dockerService) DockerContainerLog(name string) ([]byte, error) { cli, err := client2.NewClientWithOpts(client2.FromEnv) if err != nil { - return "", err + return []byte(""), err } defer cli.Close() - body, err := cli.ContainerLogs(context.Background(), name, types.ContainerLogsOptions{ShowStderr: true, ShowStdout: true}) + //body, err := cli.ContainerAttach(context.Background(), name, types.ContainerAttachOptions{Logs: true, Stream: false, Stdin: false, Stdout: false, Stderr: false}) + body, err := cli.ContainerLogs(context.Background(), name, types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true}) + if err != nil { - return "", err + return []byte(""), err } defer body.Close() content, err := ioutil.ReadAll(body) + //content, err := ioutil.ReadAll(body) if err != nil { - return "", err + return []byte(""), err } - return string(content), nil + return content, nil } func DockerContainerStats1() error {