mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 04:54:32 +08:00
自动安装MySQL时自动生成所需的动态库软链接
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user