mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-11-06 14:49:52 +00:00
Merge branch 'heads/v0.3.7'
This commit is contained in:
commit
8a37f9c879
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -67,3 +67,5 @@ jobs:
|
|||||||
dist/linux-arm64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
dist/linux-arm64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-arm64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
||||||
dist/linux-amd64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
dist/linux-amd64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz:/IceWhaleTech/CasaOS/releases/download/${{ steps.get_version.outputs.VERSION }}/linux-amd64-casaos-migration-tool-${{ steps.get_version.outputs.VERSION }}.tar.gz
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -39,4 +39,4 @@ dist
|
|||||||
CasaOS
|
CasaOS
|
||||||
|
|
||||||
# System Files
|
# System Files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
22
CHANGELOG.md
22
CHANGELOG.md
@ -18,7 +18,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
## [0.3.7] - 2022-10-28
|
## [0.3.7.1] 2022-11-04
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix memory leak issue ([#658](https://github.com/IceWhaleTech/CasaOS/issues/658)[#646](https://github.com/IceWhaleTech/CasaOS/issues/646))
|
||||||
|
- Solve the problem of local application import failure ([#490](https://github.com/IceWhaleTech/CasaOS/issues/490))
|
||||||
|
|
||||||
|
## [0.3.7] 2022-10-28
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- [Storage] Disk merge (Beta), you can merge multiple disks into a single storage space (currently you need to enable this feature from the command line)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- [Files] Changed the cache file storage location, now the file upload size is not limited by the system disk capacity.
|
||||||
|
- [Scripts] Updated installation and upgrade scripts to support more Debian-based Linux distributions.
|
||||||
|
- [Engineering] Refactored Local Storage into a standalone service as part of CasaOS modularization.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- [Apps] App list update mechanism improved, now you can see the latest apps in App Store immediately.
|
||||||
|
- [Storage] Fixed a lot of known issues
|
||||||
|
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- [Storage] Disk merge (Beta), you can merge multiple disks into a single storage space (currently you need to enable this feature from the command line)
|
- [Storage] Disk merge (Beta), you can merge multiple disks into a single storage space (currently you need to enable this feature from the command line)
|
||||||
|
|||||||
@ -1,4 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
###
|
||||||
|
# @Author: LinkLeong link@icewhale.org
|
||||||
|
# @Date: 2022-11-15 15:51:44
|
||||||
|
# @LastEditors: LinkLeong
|
||||||
|
# @LastEditTime: 2022-11-15 15:53:37
|
||||||
|
# @FilePath: /CasaOS/build/sysroot/usr/share/casaos/cleanup/script.d/03-cleanup-casaos.sh
|
||||||
|
# @Description:
|
||||||
|
# @Website: https://www.casaos.io
|
||||||
|
# Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
###
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@ -44,4 +54,3 @@ readonly SETUP_SCRIPT_FILEPATH="${SETUP_SCRIPT_DIRECTORY}/${SETUP_SCRIPT_FILENAM
|
|||||||
|
|
||||||
echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..."
|
echo "🟩 Running ${SETUP_SCRIPT_FILENAME}..."
|
||||||
$SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}"
|
$SHELL "${SETUP_SCRIPT_FILEPATH}" "${BUILD_PATH}"
|
||||||
|
|
||||||
|
|||||||
89
common/notify.go
Normal file
89
common/notify.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
CasaOSURLFilename = "casaos.url"
|
||||||
|
APICasaOSNotify = "/v1/notify"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NotifyService interface {
|
||||||
|
SendNotify(path string, message map[string]interface{}) error
|
||||||
|
SendSystemStatusNotify(message map[string]interface{}) error
|
||||||
|
}
|
||||||
|
type notifyService struct {
|
||||||
|
address string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *notifyService) SendNotify(path string, message map[string]interface{}) error {
|
||||||
|
|
||||||
|
url := strings.TrimSuffix(n.address, "/") + APICasaOSNotify + "/" + path
|
||||||
|
body, err := json.Marshal(message)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
response, err := http.Post(url, "application/json", bytes.NewBuffer(body))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if response.StatusCode != http.StatusOK {
|
||||||
|
return errors.New("failed to send notify (status code: " + fmt.Sprint(response.StatusCode) + ")")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// disk: "sys_disk":{"size":56866869248,"avail":5855485952,"health":true,"used":48099700736}
|
||||||
|
// usb: "sys_usb":[{"name": "sdc","size": 7747397632,"model": "DataTraveler_2.0","avail": 7714418688,"children": null}]
|
||||||
|
func (n *notifyService) SendSystemStatusNotify(message map[string]interface{}) error {
|
||||||
|
|
||||||
|
url := strings.TrimSuffix(n.address, "/") + APICasaOSNotify + "/system_status"
|
||||||
|
fmt.Println(url)
|
||||||
|
body, err := json.Marshal(message)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
response, err := http.Post(url, "application/json", bytes.NewBuffer(body))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if response.StatusCode != http.StatusOK {
|
||||||
|
return errors.New("failed to send notify (status code: " + fmt.Sprint(response.StatusCode) + ")")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
func NewNotifyService(runtimePath string) (NotifyService, error) {
|
||||||
|
casaosAddressFile := filepath.Join(runtimePath, CasaOSURLFilename)
|
||||||
|
|
||||||
|
buf, err := os.ReadFile(casaosAddressFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
address := string(buf)
|
||||||
|
|
||||||
|
response, err := http.Get(address + "/ping")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if response.StatusCode != 200 {
|
||||||
|
return nil, errors.New("failed to ping casaos service")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ¬ifyService{
|
||||||
|
address: address,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
29
common/notify_test.go
Normal file
29
common/notify_test.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestSendNotify(t *testing.T) {
|
||||||
|
notify, err := NewNotifyService("/var/run/casaos")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = notify.SendNotify("test", map[string]interface{}{
|
||||||
|
"test": "test",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSendSystemStatusNotify(t *testing.T) {
|
||||||
|
notify, err := NewNotifyService("/var/run/casaos")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = notify.SendSystemStatusNotify(map[string]interface{}{
|
||||||
|
"sys_usb": `[{"name": "sdc","size": 7747397632,"model": "DataTraveler_2.0","avail": 7714418688,"children": null}]`,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
78
common/share.go
Normal file
78
common/share.go
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
APICasaOSShare = "/v1/samba/shares"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ShareService interface {
|
||||||
|
DeleteShare(id string) error
|
||||||
|
}
|
||||||
|
type shareService struct {
|
||||||
|
address string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *shareService) DeleteShare(id string) error {
|
||||||
|
url := strings.TrimSuffix(n.address, "/") + APICasaOSShare + "/" + id
|
||||||
|
fmt.Println(url)
|
||||||
|
message := "{}"
|
||||||
|
body, err := json.Marshal(message)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
// Create request
|
||||||
|
req, err := http.NewRequest("DELETE", url, bytes.NewBuffer(body))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch Request
|
||||||
|
response, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
|
if response.StatusCode != http.StatusOK {
|
||||||
|
return errors.New("failed to send share (status code: " + fmt.Sprint(response.StatusCode) + ")")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewShareService(runtimePath string) (ShareService, error) {
|
||||||
|
casaosAddressFile := filepath.Join(runtimePath, CasaOSURLFilename)
|
||||||
|
|
||||||
|
buf, err := os.ReadFile(casaosAddressFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
address := string(buf)
|
||||||
|
|
||||||
|
response, err := http.Get(address + "/ping")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if response.StatusCode != 200 {
|
||||||
|
return nil, errors.New("failed to ping casaos service")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &shareService{
|
||||||
|
address: address,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
14
common/share_test.go
Normal file
14
common/share_test.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestDeleteShare(t *testing.T) {
|
||||||
|
share, err := NewShareService("/var/run/casaos")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = share.DeleteShare("1")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -74,3 +74,8 @@ type FileSetting struct {
|
|||||||
ShareDir []string `json:"share_dir" delim:"|"`
|
ShareDir []string `json:"share_dir" delim:"|"`
|
||||||
DownloadDir string `json:"download_dir"`
|
DownloadDir string `json:"download_dir"`
|
||||||
}
|
}
|
||||||
|
type BaseInfo struct {
|
||||||
|
Hash string `json:"i"`
|
||||||
|
Version string `json:"v"`
|
||||||
|
Channel string `json:"c,omitempty"`
|
||||||
|
}
|
||||||
|
|||||||
@ -1,21 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.org
|
||||||
|
* @Date: 2022-11-15 15:51:44
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-11-15 15:55:16
|
||||||
|
* @FilePath: /CasaOS/route/init.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
package route
|
package route
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/IceWhaleTech/CasaOS/model"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/samba"
|
"github.com/IceWhaleTech/CasaOS/pkg/samba"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/encryption"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
|
||||||
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
"github.com/IceWhaleTech/CasaOS/pkg/utils/loger"
|
||||||
"github.com/IceWhaleTech/CasaOS/service"
|
"github.com/IceWhaleTech/CasaOS/service"
|
||||||
|
"github.com/IceWhaleTech/CasaOS/types"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitFunction() {
|
func InitFunction() {
|
||||||
go InitNetworkMount()
|
go InitNetworkMount()
|
||||||
|
go InitInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func InitInfo() {
|
||||||
|
mb := model.BaseInfo{}
|
||||||
|
if file.Exists(config.AppInfo.DBPath + "/baseinfo.conf") {
|
||||||
|
err := json.Unmarshal(file.ReadFullFile(config.AppInfo.DBPath+"/baseinfo.conf"), &mb)
|
||||||
|
if err != nil {
|
||||||
|
loger.Error("baseinfo.conf", zap.String("error", err.Error()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if file.Exists("/etc/CHANNEL") {
|
||||||
|
channel := file.ReadFullFile("/etc/CHANNEL")
|
||||||
|
mb.Channel = string(channel)
|
||||||
|
}
|
||||||
|
mac, err := service.MyService.System().GetMacAddress()
|
||||||
|
if err != nil {
|
||||||
|
loger.Error("GetMacAddress", zap.String("error", err.Error()))
|
||||||
|
}
|
||||||
|
mb.Hash = encryption.GetMD5ByStr(mac)
|
||||||
|
mb.Version = types.CURRENTVERSION
|
||||||
|
os.Remove(config.AppInfo.DBPath + "/baseinfo.conf")
|
||||||
|
by, err := json.Marshal(mb)
|
||||||
|
if err != nil {
|
||||||
|
loger.Error("init info err", zap.Any("err", err))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
file.WriteToFullPath(by, config.AppInfo.DBPath+"/baseinfo.conf", 0o666)
|
||||||
|
}
|
||||||
|
|
||||||
func InitNetworkMount() {
|
func InitNetworkMount() {
|
||||||
time.Sleep(time.Second * 10)
|
time.Sleep(time.Second * 10)
|
||||||
connections := service.MyService.Connections().GetConnectionsList()
|
connections := service.MyService.Connections().GetConnectionsList()
|
||||||
|
|||||||
@ -560,6 +560,7 @@ func (ds *dockerService) DockerContainerCreate(m model.CustomizationPostData, id
|
|||||||
//container, err := cli.ContainerCreate(context.Background(), info.Config, info.HostConfig, &network.NetworkingConfig{info.NetworkSettings.Networks}, nil, info.Name)
|
//container, err := cli.ContainerCreate(context.Background(), info.Config, info.HostConfig, &network.NetworkingConfig{info.NetworkSettings.Networks}, nil, info.Name)
|
||||||
|
|
||||||
hostConfig.Mounts = volumes
|
hostConfig.Mounts = volumes
|
||||||
|
hostConfig.Binds = []string{}
|
||||||
hostConfig.Privileged = m.Privileged
|
hostConfig.Privileged = m.Privileged
|
||||||
hostConfig.CapAdd = m.CapAdd
|
hostConfig.CapAdd = m.CapAdd
|
||||||
hostConfig.NetworkMode = container.NetworkMode(m.NetworkModel)
|
hostConfig.NetworkMode = container.NetworkMode(m.NetworkModel)
|
||||||
|
|||||||
@ -50,9 +50,18 @@ type SystemService interface {
|
|||||||
IsServiceRunning(name string) bool
|
IsServiceRunning(name string) bool
|
||||||
GetCPUTemperature() int
|
GetCPUTemperature() int
|
||||||
GetCPUPower() map[string]string
|
GetCPUPower() map[string]string
|
||||||
|
GetMacAddress() (string, error)
|
||||||
}
|
}
|
||||||
type systemService struct{}
|
type systemService struct{}
|
||||||
|
|
||||||
|
func (c *systemService) GetMacAddress() (string, error) {
|
||||||
|
interfaces, err := net.Interfaces()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
inter := interfaces[0]
|
||||||
|
return inter.HardwareAddr, nil
|
||||||
|
}
|
||||||
func (c *systemService) MkdirAll(path string) (int, error) {
|
func (c *systemService) MkdirAll(path string) (int, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@ -1,3 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* @Author: LinkLeong link@icewhale.org
|
||||||
|
* @Date: 2022-11-15 15:51:44
|
||||||
|
* @LastEditors: LinkLeong
|
||||||
|
* @LastEditTime: 2022-11-15 15:56:03
|
||||||
|
* @FilePath: /CasaOS/types/system.go
|
||||||
|
* @Description:
|
||||||
|
* @Website: https://www.casaos.io
|
||||||
|
* Copyright (c) 2022 by icewhale, All Rights Reserved.
|
||||||
|
*/
|
||||||
/*@Author: LinkLeong link@icewhale.com
|
/*@Author: LinkLeong link@icewhale.com
|
||||||
*@Date: 2022-02-17 18:53:22
|
*@Date: 2022-02-17 18:53:22
|
||||||
*@LastEditors: LinkLeong
|
*@LastEditors: LinkLeong
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user