Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: mount dir when install in openEuler native #27

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 47 additions & 40 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,57 @@ func init() {
Config.Version = v
if !v {
modifyConfigWhenRunInDocker()
mountPath := hardware_util.GetMountDir()
if mountPath != "" {
JoinMountPathInConfigPath(mountPath)
}
createLogFileDir()
writeDefaultConfigFile(*flagConfFile)
}
}

func JoinMountPathInConfigPath(mountPath string) {
p := []*string{
&Config.Log.AoLogDirBase,
&Config.Log.Path,
&Config.Box.CpuIdStoreFile,
&Config.Box.SnNumberStoreFile,
&Config.Box.HostIpFile,
&Config.Box.ApplyEmailStoreFile,
&Config.Box.BoxInfoFile,
&Config.Box.InternetServiceConfigFile,

&Config.Box.SwithStatusFile,
&Config.Box.WifiNamePasswdFile,
&Config.Box.BoxMetaAdminPair,
&Config.Box.RandDockercomposePassword,
&Config.Box.RandDockercomposeRedisPort,

&Config.Box.PublicSharedInfoFile,
&Config.Box.BoxKey.RsaKeyFile,
&Config.Box.BoxKey.RsaPubKeyFile,
&Config.Box.Disk.DiskInitialInfoFile,
&Config.Box.Disk.DeviceUuidRecordFile,
&Config.Box.Disk.DiskSharedInfoFile,
&Config.Box.ClientKey.RsaPubKeyFile,
&Config.Box.ClientKey.RsaPriKeyFile,
&Config.Box.ClientKey.SharedSecret,
&Config.Box.UpgradeConfig.SettingsFile,
&Config.Box.Cert.CertDir,
&Config.Docker.ComposeFile,
&Config.Docker.CustomComposeFile,
&Config.RunTime.BasePath,
&Config.Notification.UpgradeRecordFile,
&Config.Box.Disk.StorageVolumePath,
&Config.Box.Disk.NoDisksFileStoragePath,
&Config.Box.Disk.NoDisksFileStoragePathDockerDeploy,
&Config.GTClient.ConfigPath,
&Config.Box.DID.RootPath}
for _, v := range p {
*v = mountPath + *v
}
}

func modifyConfigWhenRunInDocker() {
// fmt.Printf("+++++++++++++++++++++++ modifyConfigWhenRunInDocker \n")
////////////////////////////////////////////////////////////
Expand All @@ -453,46 +499,7 @@ func modifyConfigWhenRunInDocker() {
// 修改保存路径。
// 新增路径的配置项时,如果docker 中运行时, 需要在这里修改默认路径 !!!
if runInDocker {
p := []*string{
&Config.Log.AoLogDirBase,
&Config.Log.Path,
&Config.Box.CpuIdStoreFile,
&Config.Box.SnNumberStoreFile,
&Config.Box.HostIpFile,
&Config.Box.ApplyEmailStoreFile,
&Config.Box.BoxInfoFile,
&Config.Box.InternetServiceConfigFile,

&Config.Box.SwithStatusFile,
&Config.Box.WifiNamePasswdFile,
&Config.Box.BoxMetaAdminPair,
&Config.Box.RandDockercomposePassword,
&Config.Box.RandDockercomposeRedisPort,

&Config.Box.PublicSharedInfoFile,
&Config.Box.BoxKey.RsaKeyFile,
&Config.Box.BoxKey.RsaPubKeyFile,
&Config.Box.Disk.DiskInitialInfoFile,
&Config.Box.Disk.DeviceUuidRecordFile,
&Config.Box.Disk.DiskSharedInfoFile,
&Config.Box.ClientKey.RsaPubKeyFile,
&Config.Box.ClientKey.RsaPriKeyFile,
&Config.Box.ClientKey.SharedSecret,
&Config.Box.UpgradeConfig.SettingsFile,
&Config.Box.Cert.CertDir,
&Config.Docker.ComposeFile,
&Config.Docker.CustomComposeFile,
&Config.RunTime.BasePath,
&Config.Notification.UpgradeRecordFile,
&Config.Box.Disk.StorageVolumePath,
&Config.Box.Disk.NoDisksFileStoragePath,
&Config.Box.Disk.NoDisksFileStoragePathDockerDeploy,
&Config.GTClient.ConfigPath,
&Config.Box.DID.RootPath}

for _, v := range p {
*v = SpaceMountPath + *v
}

// fmt.Printf("Config.Box.SnNumberStoreFile: %v \n", Config.Box.SnNumberStoreFile)

// 调用地址修改
Expand Down
14 changes: 7 additions & 7 deletions utils/hardware/hardware.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ func GetHardwareChip() (string, error) {
// RunningInDocker is program running in container ?
func RunningInDocker() bool {
// 由于其他方法在某些 OS 上有失效的可能性,暂时用用户传入的环境变量来判断。
envkey := "AOSPACE_DATADIR"
dataDir := os.Getenv(envkey)
if len(dataDir) > 0 {
// fmt.Printf("RunningInDocker, dataDir:%v\n", dataDir)
return true
} else {
// fmt.Printf("RunningInDocker==false, dataDir:%v\n", dataDir)
_, err := os.Stat("/root/.dockerenv")
if err != nil {
return false
}
return true
}

func GetMountDir() string {
return os.Getenv("AOSPACE_DATADIR")
}
Loading