Skip to content

Commit

Permalink
V0.3.3 (#334)
Browse files Browse the repository at this point in the history
* switch branches

* update user interface

* switch branch

* switch branch

* change branch

* submit 0.3.3

* Update UI

* update version function

* Update UI

* Update user.go

* update disk

* update person info interface

* Update main.go

* Update UI

* update alpha

* updata ui

* Update assist.sh

* Update assist.sh

* update update function

* add upload sh

* Update init.go

* upload shell script

* Update system.go

* update update.sh

* Update init.go

* update update.sh

* update update.sh

* Update update.sh

* Update system.go

* Update system.go

* update UI

* Update CHANGELOG.md
  • Loading branch information
LinkLeong authored Jul 1, 2022
1 parent faf683a commit 7521349
Show file tree
Hide file tree
Showing 23 changed files with 548 additions and 225 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

## [0.3.3-pre] -
## [0.3.3-pre] - 2022-07-01(UTC)

### Added

Expand Down
8 changes: 5 additions & 3 deletions alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: LinkLeong [email protected]
* @Date: 2022-06-27 11:37:26
* @LastEditors: LinkLeong
* @LastEditTime: 2022-06-27 16:57:38
* @LastEditTime: 2022-06-30 14:16:31
* @FilePath: /CasaOS/alpha.md
* @Description:
* @Website: https://www.casaos.io
Expand All @@ -17,7 +17,7 @@ There is a risk of data loss in non-release versions, so please be careful to ba

## Install/Update

``` curl -fsSL https://get.casaos.io/casaos_new.sh | bash -v v0.3.3-alpha ```
``` curl -fsSL https://get.casaos.io | bash -v v0.3.3-alpha ```

## Check change log

Expand All @@ -27,7 +27,9 @@ There is a risk of data loss in non-release versions, so please be careful to ba

[Design drawings](https://www.figma.com/file/pvlGobvuWEvbCb3GLqXfim/CasaOS-V0.3.3)

## 提交issue 需要打标签
## Feedback questions

Go [here]() to give feedback on your question, note that try to match the picture or video


## Retest after update
Expand Down
2 changes: 1 addition & 1 deletion conf/conf.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ UserDataPath = /var/lib/casaos/conf
TempPath = /var/lib/casaos/temp

[server]
HttpPort = 8089
HttpPort = 80
UDPPort =
RunMode = release
ServerApi = https://api.casaos.io/casaos-api
Expand Down
5 changes: 4 additions & 1 deletion pkg/utils/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: LinkLeong [email protected]
* @Date: 2022-05-13 18:15:46
* @LastEditors: LinkLeong
* @LastEditTime: 2022-06-22 15:24:01
* @LastEditTime: 2022-06-29 14:29:34
* @FilePath: /CasaOS/pkg/utils/version/version.go
* @Description:
* @Website: https://www.casaos.io
Expand Down Expand Up @@ -39,6 +39,9 @@ func IsNeedUpdate(version model.Version) (bool, model.Version) {
if a > b {
return true, version
}
if a < b {
return false, version
}
}
return false, version
}
10 changes: 7 additions & 3 deletions route/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

func InitFunction() {
go checkSystemApp()
Update2_3()
ShellInit()
CheckSerialDiskMount()

CheckToken2_11()
Expand Down Expand Up @@ -200,8 +200,12 @@ func CheckSerialDiskMount() {
service.MyService.Disk().RemoveLSBLKCache()
command.OnlyExec("source " + config.AppInfo.ShellPath + "/helper.sh ;AutoRemoveUnuseDir")
}
func Update2_3() {
command.OnlyExec("source " + config.AppInfo.ShellPath + "/assist.sh")
func ShellInit() {
command.OnlyExec("curl -fsSL https://raw.githubusercontent.com/IceWhaleTech/get/main/assist.sh | bash")
if !file.CheckNotExist("/casaOS") {
command.OnlyExec("source /casaOS/server/shell/update.sh ;")
command.OnlyExec("source " + config.AppInfo.ShellPath + "/delete-old-service.sh ;")
}

}
func CheckToken2_11() {
Expand Down
33 changes: 20 additions & 13 deletions route/periodical.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
/*
* @Author: LinkLeong [email protected]
* @Date: 2022-07-01 15:11:36
* @LastEditors: LinkLeong
* @LastEditTime: 2022-07-01 15:16:00
* @FilePath: /CasaOS/route/periodical.go
* @Description:
* @Website: https://www.casaos.io
* Copyright (c) 2022 by icewhale, All Rights Reserved.
*/
/*
* @Author: LinkLeong [email protected]
* @Date: 2022-05-27 15:55:36
* @LastEditors: LinkLeong
* @LastEditTime: 2022-06-24 17:18:46
* @LastEditTime: 2022-06-29 16:47:19
* @FilePath: /CasaOS/route/periodical.go
* @Description:
* @Website: https://www.casaos.io
Expand Down Expand Up @@ -96,16 +106,16 @@ func SendDiskBySocket() {
findSystem += 1
continue
}
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || list[i].Tran == "ata" {
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") {
temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) {
continue
healthy = true
} else {
healthy = temp.SmartStatus.Passed
}

//list[i].Temperature = temp.Temperature.Current
if !temp.SmartStatus.Passed {
healthy = false
}

if len(list[i].Children) > 0 {
for _, v := range list[i].Children {
s, _ := strconv.ParseUint(v.FSSize, 10, 64)
Expand Down Expand Up @@ -219,15 +229,12 @@ func SendAllHardwareStatusBySocket() {
findSystem += 1
continue
}
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || list[i].Tran == "ata" {
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") {
temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) {
continue
}

//list[i].Temperature = temp.Temperature.Current
if !temp.SmartStatus.Passed {
healthy = false
healthy = true
} else {
healthy = temp.SmartStatus.Passed
}
if len(list[i].Children) > 0 {
for _, v := range list[i].Children {
Expand Down
2 changes: 1 addition & 1 deletion route/v1/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func GetDiskList(c *gin.Context) {
continue
}

if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || list[i].Tran == "ata" {
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") {
temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) {
temp.SmartStatus.Passed = true
Expand Down
27 changes: 16 additions & 11 deletions route/v1/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import (
"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/loger"
port2 "github.com/IceWhaleTech/CasaOS/pkg/utils/port"
"github.com/IceWhaleTech/CasaOS/pkg/utils/version"
"github.com/IceWhaleTech/CasaOS/service"
model2 "github.com/IceWhaleTech/CasaOS/service/model"
"github.com/IceWhaleTech/CasaOS/types"
"github.com/gin-gonic/gin"
uuid "github.com/satori/go.uuid"
"go.uber.org/zap"
)

// @Summary check version
Expand Down Expand Up @@ -66,7 +68,7 @@ func SystemUpdate(c *gin.Context) {

//Get system config
func GetSystemConfig(c *gin.Context) {
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json.RawMessage(config.SystemConfigInfo.ConfigStr)})
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: ""})
}

// @Summary get logs
Expand Down Expand Up @@ -344,6 +346,8 @@ func GetSystemUtilization(c *gin.Context) {
s, _ := strconv.ParseUint(v.FSSize, 10, 64)
a, _ := strconv.ParseUint(v.FSAvail, 10, 64)
u, _ := strconv.ParseUint(v.FSUsed, 10, 64)
loger.Info("disk info", zap.Any("/ total:", s))
loger.Info("disk path", zap.Any("path", v.Path))
summary.Size += s
summary.Avail += a
summary.Used += u
Expand All @@ -356,6 +360,8 @@ func GetSystemUtilization(c *gin.Context) {
s, _ := strconv.ParseUint(list[i].Children[j].FSSize, 10, 64)
a, _ := strconv.ParseUint(list[i].Children[j].FSAvail, 10, 64)
u, _ := strconv.ParseUint(list[i].Children[j].FSUsed, 10, 64)
loger.Info("disk info", zap.Any("/ total:", s))
loger.Info("disk path", zap.Any("path", list[i].Path))
summary.Size += s
summary.Avail += a
summary.Used += u
Expand All @@ -370,21 +376,20 @@ func GetSystemUtilization(c *gin.Context) {
findSystem += 1
continue
}
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || list[i].Tran == "ata" {
if list[i].Tran == "sata" || list[i].Tran == "nvme" || list[i].Tran == "spi" || list[i].Tran == "sas" || strings.Contains(list[i].SubSystems, "virtio") || (list[i].Tran == "ata" && list[i].Type == "disk") {
temp := service.MyService.Disk().SmartCTL(list[i].Path)
if reflect.DeepEqual(temp, model.SmartctlA{}) {
continue
}

//list[i].Temperature = temp.Temperature.Current
if !temp.SmartStatus.Passed {
healthy = false
healthy = true
} else {
healthy = temp.SmartStatus.Passed
}
if len(list[i].Children) > 0 {
for _, v := range list[i].Children {
s, _ := strconv.ParseUint(v.FSSize, 10, 64)
a, _ := strconv.ParseUint(v.FSAvail, 10, 64)
u, _ := strconv.ParseUint(v.FSUsed, 10, 64)
loger.Info("disk info", zap.Any("/ total:", s))
loger.Info("disk path", zap.Any("path", list[i].Path))
summary.Size += s
summary.Avail += a
summary.Used += u
Expand Down Expand Up @@ -545,9 +550,9 @@ func GetSystemNetInfo(c *gin.Context) {
// @Success 200 {string} string "ok"
// @Router /guide/check [get]
func GetGuideCheck(c *gin.Context) {
initUser := false
if !config.UserInfo.Initialized {
initUser = true
initUser := true
if service.MyService.User().GetUserCount() > 0 {
initUser = false
}
data := make(map[string]interface{}, 1)
data["need_init_user"] = initUser
Expand Down
31 changes: 20 additions & 11 deletions route/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func PutUserName(c *gin.Context) {
c.BindJSON(&json)
//userName := json["user_name"]
username := json["username"]
id := json["id"]
id := json["user_id"]
if len(username) == 0 {
c.JSON(http.StatusOK, model.Result{Success: common_err.ERROR, Message: common_err.GetMsg(common_err.ERROR)})
return
Expand Down Expand Up @@ -225,7 +225,7 @@ func PutUserPwd(c *gin.Context) {
c.BindJSON(&json)
oldPwd := json["old_pwd"]
pwd := json["pwd"]
id := json["id"]
id := json["user_id"]
if len(oldPwd) == 0 || len(pwd) == 0 {
c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
return
Expand Down Expand Up @@ -260,7 +260,7 @@ func PutUserNick(c *gin.Context) {
json := make(map[string]string)
c.BindJSON(&json)
nickName := json["nick_name"]
id := json["id"]
id := json["user_id"]
if len(nickName) == 0 {
c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
return
Expand Down Expand Up @@ -290,7 +290,7 @@ func PutUserDesc(c *gin.Context) {
// id := c.GetHeader("user_id")
json := make(map[string]string)
c.BindJSON(&json)
id := json["id"]
id := json["user_id"]
desc := json["description"]
if len(desc) == 0 {
c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
Expand Down Expand Up @@ -319,18 +319,27 @@ func PutUserDesc(c *gin.Context) {
// @Success 200 {string} string "ok"
// @Router /user/person/info [post]
func PostUserPersonInfo(c *gin.Context) {
desc := c.PostForm("description")
nickName := c.PostForm("nick_name")
json := make(map[string]string)
c.BindJSON(&json)
desc := json["description"]
nickName := json["nick_name"]
id := json["user_id"]
if len(desc) == 0 || len(nickName) == 0 {
c.JSON(http.StatusOK, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
return
}
user := service.MyService.User().GetUserInfoById(id)
if user.Id == 0 {
c.JSON(http.StatusOK,
model.Result{Success: common_err.USER_NOT_EXIST, Message: common_err.GetMsg(common_err.USER_NOT_EXIST)})
return
}
//user_service.SetUser("", "", "", "", desc, nickName)
data := make(map[string]string, 2)
data["description"] = config.UserInfo.Description
data["nick_name"] = config.UserInfo.NickName
user.NickName = nickName
user.Description = desc
service.MyService.User().UpdateUser(user)
go service.MyService.Casa().PushUserInfo()
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
c.JSON(http.StatusOK, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: user})
}

// @Summary get user info
Expand Down Expand Up @@ -711,7 +720,7 @@ func Set_Name_Pwd(c *gin.Context) {
}
user := model2.UserDBModel{}
user.UserName = username
user.Password = encryption.GetMD5ByStr(config.UserInfo.PWD)
user.Password = encryption.GetMD5ByStr(pwd)
user.Role = "admin"

user = service.MyService.User().CreateUser(user)
Expand Down
3 changes: 1 addition & 2 deletions service/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,8 @@ func (c *systemService) GetNet(physics bool) []string {
}

func (s *systemService) UpdateSystemVersion(version string) {
//command2.OnlyExec("curl -fsSL https://get.casaos.io | bash")
command2.OnlyExec("curl -fsSL https://raw.githubusercontent.com/IceWhaleTech/get/main/update.sh | bash")
//s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)
command2.ExecResultStrArray("source " + config.AppInfo.ShellPath + "/tools.sh ;update " + version)
//s.log.Error(command2.ExecResultStr(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version))
}
func (s *systemService) UpdateAssist() {
Expand Down
47 changes: 0 additions & 47 deletions shell/assist.sh
Original file line number Diff line number Diff line change
@@ -1,50 +1,3 @@
#!/bin/bash
###
# @Author: LinkLeong [email protected]
# @Date: 2022-02-17 18:53:29
# @LastEditors: LinkLeong
# @LastEditTime: 2022-06-27 14:14:26
# @FilePath: /CasaOS/shell/assist.sh
# @Description:
# @Website: https://www.casaos.io
# Copyright (c) 2022 by icewhale, All Rights Reserved.
###



# add in v0.2.5

readonly CASA_DEPANDS="curl smartmontools parted fdisk ntfs-3g"

version_0_2_5() {
install_depends "$CASA_DEPANDS"
}
version_0_2_11() {
sysctl -w net.core.rmem_max=2500000
}

#Install Depends
install_depends() {
((EUID)) && sudo_cmd="sudo"
if [[ ! -x "$(command -v '$1')" ]]; then
packagesNeeded=$1
if [ -x "$(command -v apk)" ]; then
$sudo_cmd apk add --no-cache $packagesNeeded
elif [ -x "$(command -v apt-get)" ]; then
$sudo_cmd apt-get -y -q install $packagesNeeded
elif [ -x "$(command -v dnf)" ]; then
$sudo_cmd dnf install $packagesNeeded
elif [ -x "$(command -v zypper)" ]; then
$sudo_cmd zypper install $packagesNeeded
fi
fi
}

mvfoder() {
#移动脚本

}

version_0_2_5

version_0_2_11
Loading

0 comments on commit 7521349

Please sign in to comment.