From d2dff968fbb4cc113037801d0867bbf76257f230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 20 Mar 2023 21:32:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=89=E8=A3=85MySQL?= =?UTF-8?q?=E6=97=B6=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90=E6=89=80=E9=9C=80?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81=E5=BA=93=E8=BD=AF=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mysql/mysqlinstallers/mysql_installer.go | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/internal/web/actions/default/setup/mysql/mysqlinstallers/mysql_installer.go b/internal/web/actions/default/setup/mysql/mysqlinstallers/mysql_installer.go index 43e71c32..beb5637f 100644 --- a/internal/web/actions/default/setup/mysql/mysqlinstallers/mysql_installer.go +++ b/internal/web/actions/default/setup/mysql/mysqlinstallers/mysql_installer.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/setup/mysql/mysqlinstallers/utils" + stringutil "github.com/iwind/TeaGo/utils/string" timeutil "github.com/iwind/TeaGo/utils/time" "io" "net" @@ -106,6 +107,29 @@ func (this *MySQLInstaller) InstallFromFile(xzFilePath string, targetDir string) time.Sleep(1 * time.Second) } } + + // create symbolic links + { + var libFile = "/usr/lib64/libncurses.so.5" + _, err = os.Stat(libFile) + if err != nil && os.IsNotExist(err) { + var latestLibFile = this.findLatestVersionFile("/usr/lib64", "libncurses.so.") + if len(latestLibFile) > 0 { + _ = os.Symlink(latestLibFile, libFile) + } + } + } + + { + var libFile = "/usr/lib64/libtinfo.so.5" + _, err = os.Stat(libFile) + if err != nil && os.IsNotExist(err) { + var latestLibFile = this.findLatestVersionFile("/usr/lib64", "libtinfo.so.") + if len(latestLibFile) > 0 { + _ = os.Symlink(latestLibFile, libFile) + } + } + } } // create 'mysql' user group @@ -610,3 +634,26 @@ func (this *MySQLInstaller) lookupUserAdd() (string, error) { } return "", errors.New("not found") } + +func (this *MySQLInstaller) findLatestVersionFile(dir string, prefix string) string { + files, err := filepath.Glob(filepath.Clean(dir + "/" + prefix + "*")) + if err != nil { + return "" + } + var resultFile = "" + var lastVersion = "" + var reg = regexp.MustCompile(`\.([\d.]+)`) + for _, file := range files { + var filename = filepath.Base(file) + var matches = reg.FindStringSubmatch(filename) + if len(matches) > 1 { + var version = matches[1] + if len(lastVersion) == 0 || stringutil.VersionCompare(lastVersion, version) < 0 { + lastVersion = version + resultFile = file + } + } + } + + return resultFile +}