mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
fix: 版本升级适配 armv7 (#1236)
This commit is contained in:
parent
a8b7c3d8c5
commit
d89f823bef
@ -93,9 +93,13 @@ func (u *UpgradeService) Upgrade(req dto.Upgrade) error {
|
|||||||
if err := os.MkdirAll(originalDir, os.ModePerm); err != nil {
|
if err := os.MkdirAll(originalDir, os.ModePerm); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
itemArch, err := loadArch()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
downloadPath := fmt.Sprintf("%s/%s/%s/release", global.CONF.System.RepoUrl, global.CONF.System.Mode, req.Version)
|
downloadPath := fmt.Sprintf("%s/%s/%s/release", global.CONF.System.RepoUrl, global.CONF.System.Mode, req.Version)
|
||||||
fileName := fmt.Sprintf("1panel-%s-%s-%s.tar.gz", req.Version, "linux", runtime.GOARCH)
|
fileName := fmt.Sprintf("1panel-%s-%s-%s.tar.gz", req.Version, "linux", itemArch)
|
||||||
_ = settingRepo.Update("SystemStatus", "Upgrading")
|
_ = settingRepo.Update("SystemStatus", "Upgrading")
|
||||||
go func() {
|
go func() {
|
||||||
if err := fileOp.DownloadFile(downloadPath+"/"+fileName, rootDir+"/"+fileName); err != nil {
|
if err := fileOp.DownloadFile(downloadPath+"/"+fileName, rootDir+"/"+fileName); err != nil {
|
||||||
@ -237,3 +241,21 @@ func (u *UpgradeService) loadReleaseNotes(path string) (string, error) {
|
|||||||
}
|
}
|
||||||
return string(release), nil
|
return string(release), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadArch() (string, error) {
|
||||||
|
switch runtime.GOARCH {
|
||||||
|
case "amd64", "ppc64le", "s390x", "arm64":
|
||||||
|
return runtime.GOARCH, nil
|
||||||
|
case "arm":
|
||||||
|
std, err := cmd.Exec("uname -m")
|
||||||
|
if err != nil {
|
||||||
|
return "", fmt.Errorf("std: %s, err: %s", std, err.Error())
|
||||||
|
}
|
||||||
|
if std == "armv7l\n" {
|
||||||
|
return "armv7", nil
|
||||||
|
}
|
||||||
|
return "", fmt.Errorf("unsupport such arch: arm-%s", std)
|
||||||
|
default:
|
||||||
|
return "", fmt.Errorf("unsupport such arch: %s", runtime.GOARCH)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user