Compare commits

..

7 Commits

Author SHA1 Message Date
link
86380d912d Allow specific special characters (#823) 2023-01-16 14:10:39 +08:00
link
9123974811 Update CHANGELOG.md
Signed-off-by: link <a624669980@163.com>
2023-01-09 18:08:47 +08:00
link
be50579544 add update type (#812) 2023-01-09 15:16:04 +08:00
link
91bb0cba6f Update CHANGELOG.md
Signed-off-by: link <a624669980@163.com>
2023-01-08 15:33:48 +08:00
link
b9946db854 repair the error of version number display after successful update (#805) 2023-01-05 15:16:54 +08:00
老竭力
9eb650b444 Add download triage for download migration-tool (#793)
Co-authored-by: Tiger Wang <tigerwang@outlook.com>
2023-01-05 10:47:44 +08:00
Tiger Wang
84f17b4c4b add upx as part of building step to shrink the size of binary files (#797) 2022-12-29 18:24:36 -05:00
13 changed files with 237 additions and 894 deletions

View File

@@ -17,7 +17,7 @@ jobs:
run: | run: |
sudo apt update sudo apt update
sudo apt-get --no-install-recommends --yes install \ sudo apt-get --no-install-recommends --yes install \
libc6-dev-amd64-cross \ upx libc6-dev-amd64-cross \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \ gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
- -

View File

@@ -25,9 +25,6 @@ builds:
- linux - linux
goarch: goarch:
- amd64 - amd64
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-arm64 - id: casaos-arm64
binary: build/sysroot/usr/bin/casaos binary: build/sysroot/usr/bin/casaos
env: env:
@@ -44,9 +41,6 @@ builds:
- linux - linux
goarch: goarch:
- arm64 - arm64
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-arm-7 - id: casaos-arm-7
binary: build/sysroot/usr/bin/casaos binary: build/sysroot/usr/bin/casaos
env: env:
@@ -65,9 +59,6 @@ builds:
- arm - arm
goarm: goarm:
- "7" - "7"
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-migration-tool-amd64 - id: casaos-migration-tool-amd64
binary: build/sysroot/usr/bin/casaos-migration-tool binary: build/sysroot/usr/bin/casaos-migration-tool
main: ./cmd/migration-tool main: ./cmd/migration-tool

View File

@@ -11,9 +11,14 @@ before:
builds: builds:
- id: casaos-amd64 - id: casaos-amd64
binary: build/sysroot/usr/bin/casaos binary: build/sysroot/usr/bin/casaos
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env: env:
- CC=x86_64-linux-gnu-gcc - CC=x86_64-linux-gnu-gcc
ldflags: ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s - -s
- -w - -w
- -extldflags "-static" - -extldflags "-static"
@@ -25,14 +30,16 @@ builds:
- linux - linux
goarch: goarch:
- amd64 - amd64
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-arm64 - id: casaos-arm64
binary: build/sysroot/usr/bin/casaos binary: build/sysroot/usr/bin/casaos
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env: env:
- CC=aarch64-linux-gnu-gcc - CC=aarch64-linux-gnu-gcc
ldflags: ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s - -s
- -w - -w
- -extldflags "-static" - -extldflags "-static"
@@ -44,14 +51,16 @@ builds:
- linux - linux
goarch: goarch:
- arm64 - arm64
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-arm-7 - id: casaos-arm-7
binary: build/sysroot/usr/bin/casaos binary: build/sysroot/usr/bin/casaos
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
env: env:
- CC=arm-linux-gnueabihf-gcc - CC=arm-linux-gnueabihf-gcc
ldflags: ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s - -s
- -w - -w
- -extldflags "-static" - -extldflags "-static"
@@ -65,15 +74,17 @@ builds:
- arm - arm
goarm: goarm:
- "7" - "7"
hooks:
post:
- find build/sysroot -type f | xargs -L 1 realpath --relative-to=build/sysroot > build/sysroot.manifest
- id: casaos-migration-tool-amd64 - id: casaos-migration-tool-amd64
binary: build/sysroot/usr/bin/casaos-migration-tool binary: build/sysroot/usr/bin/casaos-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool main: ./cmd/migration-tool
env: env:
- CC=x86_64-linux-gnu-gcc - CC=x86_64-linux-gnu-gcc
ldflags: ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s - -s
- -w - -w
- -extldflags "-static" - -extldflags "-static"
@@ -87,10 +98,15 @@ builds:
- amd64 - amd64
- id: casaos-migration-tool-arm64 - id: casaos-migration-tool-arm64
binary: build/sysroot/usr/bin/casaos-migration-tool binary: build/sysroot/usr/bin/casaos-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool main: ./cmd/migration-tool
env: env:
- CC=aarch64-linux-gnu-gcc - CC=aarch64-linux-gnu-gcc
ldflags: ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s - -s
- -w - -w
- -extldflags "-static" - -extldflags "-static"
@@ -104,10 +120,15 @@ builds:
- arm64 - arm64
- id: casaos-migration-tool-arm-7 - id: casaos-migration-tool-arm-7
binary: build/sysroot/usr/bin/casaos-migration-tool binary: build/sysroot/usr/bin/casaos-migration-tool
hooks:
post:
- upx --best --lzma -v --no-progress "{{ .Path }}"
main: ./cmd/migration-tool main: ./cmd/migration-tool
env: env:
- CC=arm-linux-gnueabihf-gcc - CC=arm-linux-gnueabihf-gcc
ldflags: ldflags:
- -X main.commit={{.Commit}}
- -X main.date={{.Date}}
- -s - -s
- -w - -w
- -extldflags "-static" - -extldflags "-static"

View File

@@ -16,6 +16,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security ### Security
## [0.4.1-alpha] - 2023-1-8
### Added
- [Disj] Added disk merging feature in storage management (beta) that allows for multiple disks to be merged into a single storage space
- [System] Added option for startpage.com search engine
- [APP] Added app cloning feature in the app's context menu.
-
### Changed
- [APP] Improved app installation process, including display of the installation process, checks for successful installation, and prompts
## [0.4.0] - 2022-12-13 ## [0.4.0] - 2022-12-13
### Added ### Added

View File

@@ -56,6 +56,22 @@ __is_migration_needed() {
__is_version_gt "${version2}" "${version1}" __is_version_gt "${version2}" "${version1}"
} }
__get_download_domain(){
local region
# Use ipconfig.io/country and https://ifconfig.io/country_code to get the country code
region=$(curl --connect-timeout 2 -s ipconfig.io/country || echo "")
if [ "${region}" = "" ]; then
region=$(curl --connect-timeout 2 -s https://ifconfig.io/country_code || echo "")
fi
if [[ "${region}" = "China" ]] || [[ "${region}" = "CN" ]]; then
echo "https://casaos.oss-cn-shanghai.aliyuncs.com/"
else
echo "https://github.com/"
fi
}
DOWNLOAD_DOMAIN=$(__get_download_domain)
BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../.. BUILD_PATH=$(dirname "${BASH_SOURCE[0]}")/../../..
SOURCE_ROOT=${BUILD_PATH}/sysroot SOURCE_ROOT=${BUILD_PATH}/sysroot
@@ -143,7 +159,8 @@ fi
pushd "${MIGRATION_SERVICE_DIR}" pushd "${MIGRATION_SERVICE_DIR}"
{ for URL in "${MIGRATION_PATH[@]}"; do {
for URL in "${MIGRATION_PATH[@]}"; do
MIGRATION_TOOL_FILE=$(basename "${URL}") MIGRATION_TOOL_FILE=$(basename "${URL}")
if [ -f "${MIGRATION_TOOL_FILE}" ]; then if [ -f "${MIGRATION_TOOL_FILE}" ]; then

View File

@@ -1,3 +1,3 @@
LEGACY_WITHOUT_VERSION https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz LEGACY_WITHOUT_VERSION ${DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz
v0.3.5 https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz v0.3.5 ${DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz
v0.3.5.1 https://github.com/IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz v0.3.5.1 ${DOWNLOAD_DOMAIN}IceWhaleTech/CasaOS/releases/download/v0.3.6/linux-${ARCH}-casaos-migration-tool-v0.3.6.tar.gz

View File

@@ -17,10 +17,10 @@ import (
interfaces "github.com/IceWhaleTech/CasaOS-Common" interfaces "github.com/IceWhaleTech/CasaOS-Common"
"github.com/IceWhaleTech/CasaOS-Common/utils/systemctl" "github.com/IceWhaleTech/CasaOS-Common/utils/systemctl"
"github.com/IceWhaleTech/CasaOS-Gateway/common"
"github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/config"
"github.com/IceWhaleTech/CasaOS/pkg/sqlite" "github.com/IceWhaleTech/CasaOS/pkg/sqlite"
"github.com/IceWhaleTech/CasaOS/service" "github.com/IceWhaleTech/CasaOS/service"
"github.com/IceWhaleTech/CasaOS/types"
"gorm.io/gorm" "gorm.io/gorm"
) )
@@ -29,40 +29,35 @@ const (
) )
var ( var (
commit = "private build"
date = "private build"
_logger *Logger _logger *Logger
sqliteDB *gorm.DB sqliteDB *gorm.DB
)
var (
configFlag = "" configFlag = ""
dbFlag = "" dbFlag = ""
) )
func init() { func init() {
config.InitSetup(configFlag)
if len(dbFlag) == 0 {
dbFlag = config.AppInfo.DBPath + "/db"
}
sqliteDB = sqlite.GetDb(dbFlag)
// gredis.GetRedisConn(config.RedisInfo),
service.MyService = service.NewService(sqliteDB, "", nil)
}
func main() {
versionFlag := flag.Bool("v", false, "version") versionFlag := flag.Bool("v", false, "version")
debugFlag := flag.Bool("d", true, "debug") debugFlag := flag.Bool("d", true, "debug")
forceFlag := flag.Bool("f", true, "force") forceFlag := flag.Bool("f", true, "force")
flag.Parse() flag.Parse()
_logger = NewLogger()
if *versionFlag { if *versionFlag {
fmt.Println(common.Version) fmt.Println("v" + types.CURRENTVERSION)
os.Exit(0) os.Exit(0)
} }
println("git commit:", commit)
println("build date:", date)
_logger = NewLogger()
if os.Getuid() != 0 { if os.Getuid() != 0 {
_logger.Info("Root privileges are required to run this program.")
os.Exit(1) os.Exit(1)
} }
@@ -82,6 +77,19 @@ func main() {
} }
} }
config.InitSetup(configFlag)
if len(dbFlag) == 0 {
dbFlag = config.AppInfo.DBPath + "/db"
}
sqliteDB = sqlite.GetDb(dbFlag)
// gredis.GetRedisConn(config.RedisInfo),
service.MyService = service.NewService(sqliteDB, "", nil)
}
func main() {
migrationTools := []interfaces.MigrationTool{ migrationTools := []interfaces.MigrationTool{
// nothing to migrate from last version // nothing to migrate from last version
} }

View File

@@ -55,6 +55,6 @@ func (u *migrationTool) PostMigrate() error {
return nil return nil
} }
func NewMigrationToolFor_036() interfaces.MigrationTool { func NewMigrationDummy() interfaces.MigrationTool {
return &migrationTool{} return &migrationTool{}
} }

35
go.mod
View File

@@ -4,34 +4,33 @@ go 1.16
require ( require (
github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d github.com/Curtis-Milo/nat-type-identifier-go v0.0.0-20220215191915-18d42168c63d
github.com/IceWhaleTech/CasaOS-Common v0.4.1-alpha2 github.com/IceWhaleTech/CasaOS-Common v0.4.1-alpha3
github.com/IceWhaleTech/CasaOS-Gateway v0.3.6 github.com/benbjohnson/clock v1.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/disintegration/imaging v1.6.2 github.com/disintegration/imaging v1.6.2
github.com/dsoprea/go-exif/v3 v3.0.0-20210625224831-a6301f85c82b github.com/dsoprea/go-exif/v3 v3.0.0-20221012082141-d21ac8e2de85
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/gin-contrib/gzip v0.0.6 github.com/gin-contrib/gzip v0.0.6
github.com/gin-gonic/gin v1.8.1 github.com/gin-gonic/gin v1.8.2
github.com/glebarez/sqlite v1.5.0 github.com/glebarez/sqlite v1.6.0
github.com/go-ini/ini v1.62.0 github.com/go-ini/ini v1.67.0
github.com/golang/mock v1.6.0 github.com/golang/mock v1.6.0
github.com/gomodule/redigo v1.8.5 github.com/golang/snappy v0.0.4 // indirect
github.com/gomodule/redigo v1.8.9
github.com/google/go-github/v36 v36.0.0 github.com/google/go-github/v36 v36.0.0
github.com/googollee/go-socket.io v1.6.2 github.com/googollee/go-socket.io v1.6.2
github.com/gorilla/websocket v1.5.0 github.com/gorilla/websocket v1.5.0
github.com/hirochachacha/go-smb2 v1.1.0 github.com/hirochachacha/go-smb2 v1.1.0
github.com/klauspost/compress v1.15.13 // indirect
github.com/mholt/archiver/v3 v3.5.1 github.com/mholt/archiver/v3 v3.5.1
github.com/patrickmn/go-cache v2.1.0+incompatible github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/robfig/cron v1.2.0 github.com/robfig/cron v1.2.0
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shirou/gopsutil/v3 v3.22.7 github.com/shirou/gopsutil/v3 v3.22.11
github.com/smartystreets/assertions v1.2.0 // indirect github.com/stretchr/testify v1.8.1
github.com/smartystreets/goconvey v1.6.4 // indirect github.com/tidwall/gjson v1.14.4
github.com/stretchr/testify v1.8.0 go.uber.org/zap v1.24.0
github.com/tidwall/gjson v1.10.2 golang.org/x/crypto v0.4.0
go.uber.org/zap v1.21.0 golang.org/x/oauth2 v0.3.0
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 gorm.io/gorm v1.24.2
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
gorm.io/gorm v1.24.0
gotest.tools v2.2.0+incompatible gotest.tools v2.2.0+incompatible
) )

916
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -32,6 +32,9 @@ const LOCALHOST = "127.0.0.1"
var sqliteDB *gorm.DB var sqliteDB *gorm.DB
var ( var (
commit = "private build"
date = "private build"
configFlag = flag.String("c", "", "config address") configFlag = flag.String("c", "", "config address")
dbFlag = flag.String("db", "", "db path") dbFlag = flag.String("db", "", "db path")
versionFlag = flag.Bool("v", false, "version") versionFlag = flag.Bool("v", false, "version")
@@ -43,6 +46,10 @@ func init() {
fmt.Println("v" + types.CURRENTVERSION) fmt.Println("v" + types.CURRENTVERSION)
return return
} }
println("git commit:", commit)
println("build date:", date)
config.InitSetup(*configFlag) config.InitSetup(*configFlag)
logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt) logger.LogInit(config.AppInfo.LogPath, config.AppInfo.LogSaveName, config.AppInfo.LogFileExt)

View File

@@ -131,11 +131,11 @@ func PostSambaConnectionsCreate(c *gin.Context) {
return return
} }
if ok, _ := regexp.MatchString("^[a-zA-Z0-9]{4,30}$", connection.Password); !ok { if ok, _ := regexp.MatchString(`^[\w@#*.]{4,30}$`, connection.Password); !ok {
c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.CHARACTER_LIMIT, Message: common_err.GetMsg(common_err.CHARACTER_LIMIT)}) c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.CHARACTER_LIMIT, Message: common_err.GetMsg(common_err.CHARACTER_LIMIT)})
return return
} }
if ok, _ := regexp.MatchString("^[a-zA-Z0-9]{4,30}$", connection.Username); !ok { if ok, _ := regexp.MatchString(`^[\w@#*.]{4,30}$`, connection.Username); !ok {
c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)}) c.JSON(common_err.CLIENT_ERROR, model.Result{Success: common_err.INVALID_PARAMS, Message: common_err.GetMsg(common_err.INVALID_PARAMS)})
return return
} }

View File

@@ -13,12 +13,13 @@ import (
"strings" "strings"
"time" "time"
"github.com/IceWhaleTech/CasaOS-Common/utils/file"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/IceWhaleTech/CasaOS/model" "github.com/IceWhaleTech/CasaOS/model"
"github.com/IceWhaleTech/CasaOS/pkg/config" "github.com/IceWhaleTech/CasaOS/pkg/config"
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command" command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
"github.com/IceWhaleTech/CasaOS/pkg/utils/common_err" "github.com/IceWhaleTech/CasaOS/pkg/utils/common_err"
"github.com/IceWhaleTech/CasaOS/pkg/utils/file"
"github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/cpu"
"github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/disk"
"github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/host"
@@ -232,6 +233,8 @@ func (c *systemService) GetNet(physics bool) []string {
} }
func (s *systemService) UpdateSystemVersion(version string) { func (s *systemService) UpdateSystemVersion(version string) {
keyName := "casa_version"
Cache.Delete(keyName)
if file.Exists(config.AppInfo.LogPath + "/upgrade.log") { if file.Exists(config.AppInfo.LogPath + "/upgrade.log") {
os.Remove(config.AppInfo.LogPath + "/upgrade.log") os.Remove(config.AppInfo.LogPath + "/upgrade.log")
} }
@@ -240,7 +243,8 @@ func (s *systemService) UpdateSystemVersion(version string) {
if len(config.ServerInfo.UpdateUrl) > 0 { if len(config.ServerInfo.UpdateUrl) > 0 {
go command2.OnlyExec("curl -fsSL " + config.ServerInfo.UpdateUrl + " | bash") go command2.OnlyExec("curl -fsSL " + config.ServerInfo.UpdateUrl + " | bash")
} else { } else {
go command2.OnlyExec("curl -fsSL https://get.casaos.io/update | bash") osRelease, _ := file.ReadOSRelease()
go command2.OnlyExec("curl -fsSL https://get.casaos.io/update?t=" + osRelease["MANUFACTURER"] + " | bash")
} }
// s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version) // s.log.Error(config.AppInfo.ProjectPath + "/shell/tool.sh -r " + version)