diff --git a/go.mod b/go.mod index 8d314777..57fd8957 100755 --- a/go.mod +++ b/go.mod @@ -36,6 +36,7 @@ replace ( ) require ( + github.com/Masterminds/semver/v3 v3.2.1 github.com/cavaliergopher/grab/v3 v3.0.1 github.com/containerd/containerd v1.7.18 github.com/containers/image/v5 v5.32.2 @@ -76,7 +77,6 @@ require ( github.com/BurntSushi/toml v1.3.2 // indirect github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect @@ -221,10 +221,10 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/kr/fs v0.1.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/pflag v1.0.5 go.uber.org/multierr v1.11.0 // indirect - golang.org/x/sys v0.27.0 // indirect + golang.org/x/sys v0.27.0 gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/klog/v2 v2.120.1 sigs.k8s.io/controller-runtime v0.18.4 ) diff --git a/pkg/common/common.go b/pkg/common/common.go index 5506ee98..bc1189bb 100755 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -249,6 +249,8 @@ const ( CacheAppValues = "app_built_in_values" CacheCountPodsUsingHostIP = "count_pods_using_host_ip" + + CacheWindowsDistroStoreLocation = "windows_distro_store_location" ) const ( @@ -289,6 +291,7 @@ const ( ENV_DISABLE_HOST_IP_PROMPT = "DISABLE_HOST_IP_PROMPT" ENV_AUTO_ADD_FIREWALL_RULES = "AUTO_ADD_FIREWALL_RULES" ENV_TERMINUS_OS_DOMAINNAME = "TERMINUS_OS_DOMAINNAME" + ENV_DEFAULT_WSL_DISTRO_LOCATION = "DEFAULT_WSL_DISTRO_LOCATION" // If set to 1, the default WSL distro storage will be used. ) // TerminusGlobalEnvs holds a group of general environment variables diff --git a/pkg/core/common/common.go b/pkg/core/common/common.go index 1fc05fab..576b404e 100755 --- a/pkg/core/common/common.go +++ b/pkg/core/common/common.go @@ -92,7 +92,8 @@ const ( ) const ( - DownloadUrl = "https://dc3p1870nn3cj.cloudfront.net" + DownloadUrl = "https://dc3p1870nn3cj.cloudfront.net" + DefaultBashUrl = "olares.sh" ) const ( diff --git a/pkg/phase/cluster/windows.go b/pkg/phase/cluster/windows.go index 7f2f03b0..d1f496e0 100644 --- a/pkg/phase/cluster/windows.go +++ b/pkg/phase/cluster/windows.go @@ -14,6 +14,8 @@ func (w *windowsInstallPhaseBuilder) build() []module.Module { return []module.Module{ &windows.InstallWSLModule{}, &windows.InstallWSLUbuntuDistroModule{}, + &windows.GetDiskPartitionModule{}, + &windows.MoveDistroModule{}, &windows.ConfigWslModule{}, &windows.InstallTerminusModule{}, } diff --git a/pkg/utils/cmd.go b/pkg/utils/cmd.go index b5d503a9..2ead50f6 100644 --- a/pkg/utils/cmd.go +++ b/pkg/utils/cmd.go @@ -10,14 +10,15 @@ import ( "bytetrade.io/web3os/installer/pkg/core/logger" "github.com/pkg/errors" - "golang.org/x/text/encoding/simplifiedchinese" + utilexec "k8s.io/utils/exec" ) type Charset string const ( - UTF8 = Charset("UTF-8") - GB18030 = Charset("GB18030") + DEFAULT Charset = "DEFAULT" + GBK Charset = "GBK" + UTF16 Charset = "UTF16" ) type CommandExecute interface { @@ -70,6 +71,17 @@ func (d *DefaultCommandExecutor) Run() (string, error) { return cmd.run() } +func (d *DefaultCommandExecutor) RunCmd(name string, charset Charset) (string, error) { + var cmd = &CommandExecutor{ + name: name, + cmd: d.Commands, + printOutput: d.PrintOutput, + printLine: d.PrintLine, + } + + return cmd.runcmd(charset) +} + func (d *DefaultCommandExecutor) Exec() (string, error) { var cmd = &CommandExecutor{ name: "cmd", @@ -96,6 +108,29 @@ func (command *CommandExecutor) getCmd() string { return strings.Join(command.cmd, " ") } +func (command *CommandExecutor) runcmd(charset Charset) (string, error) { + var res string + var exec = utilexec.New() + + output, err := exec.Command(command.name, command.cmd...).Output() + switch charset { + case UTF16: + res = Utf16ToUtf8(output) + case GBK: + tmp, _ := GbkToUtf8(output) + res = string(tmp) + default: + res = string(output) + } + + if err != nil { + return res, err + } + + logger.Debugf("[exec] CMD: %s, OUTPUT: %s", fmt.Sprintf("%s %v", command.name, command.cmd), res) + return res, nil +} + func (command *CommandExecutor) run() (string, error) { args := append([]string{command.prefix}, command.cmd...) c := exec.Command(command.name, args...) @@ -233,17 +268,3 @@ func (command *CommandExecutor) exec() (string, error) { logger.Debugf("[exec] CMD: %s, OUTPUT: %s", c.String(), res) return res, errors.Wrapf(err, "Failed to exec command: %s \n%s", command.getCmd(), res) } - -func ConvertByte2String(byte []byte, charset Charset) string { - var str string - switch charset { - case GB18030: - decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte) - str = string(decodeBytes) - case UTF8: - fallthrough - default: - str = string(byte) - } - return str -} diff --git a/pkg/utils/disk_darwin.go b/pkg/utils/disk_darwin.go new file mode 100644 index 00000000..0e949a9f --- /dev/null +++ b/pkg/utils/disk_darwin.go @@ -0,0 +1,9 @@ +package utils + +func GetDrives() []string { + return []string{} +} + +func GetDiskSpace(path string) (total uint64, free uint64, err error) { + return total, free, err +} diff --git a/pkg/utils/disk_linux.go b/pkg/utils/disk_linux.go new file mode 100644 index 00000000..0e949a9f --- /dev/null +++ b/pkg/utils/disk_linux.go @@ -0,0 +1,9 @@ +package utils + +func GetDrives() []string { + return []string{} +} + +func GetDiskSpace(path string) (total uint64, free uint64, err error) { + return total, free, err +} diff --git a/pkg/utils/disk_windows.go b/pkg/utils/disk_windows.go new file mode 100644 index 00000000..f81e0551 --- /dev/null +++ b/pkg/utils/disk_windows.go @@ -0,0 +1,40 @@ +package utils + +import ( + "fmt" + "os" + + "golang.org/x/sys/windows" +) + +func GetDrives() []string { + var drives []string + for i := 'A'; i <= 'Z'; i++ { + drive := fmt.Sprintf("%c:\\", i) + if _, err := os.Stat(drive); err == nil { + drives = append(drives, drive) + } + } + return drives +} + +func GetDiskSpace(path string) (total uint64, free uint64, err error) { + lpDirectoryName, err := windows.UTF16PtrFromString(path) + if err != nil { + return 0, 0, err + } + + var freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes uint64 + + err = windows.GetDiskFreeSpaceEx( + lpDirectoryName, + &freeBytesAvailable, + &totalNumberOfBytes, + &totalNumberOfFreeBytes, + ) + if err != nil { + return 0, 0, err + } + + return totalNumberOfBytes, totalNumberOfFreeBytes, nil +} diff --git a/pkg/utils/encoding.go b/pkg/utils/encoding.go new file mode 100644 index 00000000..ce13e26f --- /dev/null +++ b/pkg/utils/encoding.go @@ -0,0 +1,31 @@ +package utils + +import ( + "bytes" + "io/ioutil" + "unicode/utf16" + "unicode/utf8" + + "golang.org/x/text/encoding/simplifiedchinese" + "golang.org/x/text/transform" +) + +func GbkToUtf8(data []byte) ([]byte, error) { + reader := transform.NewReader(bytes.NewReader(data), simplifiedchinese.GBK.NewDecoder()) + return ioutil.ReadAll(reader) +} + +func Utf16ToUtf8(data []byte) string { + u16s := make([]uint16, len(data)/2) + for i := 0; i < len(u16s); i++ { + u16s[i] = uint16(data[2*i]) | uint16(data[2*i+1])<<8 + } + + runes := utf16.Decode(u16s) + buf := make([]byte, 0, len(runes)*3) + for _, r := range runes { + buf = append(buf, make([]byte, utf8.RuneLen(r))...) + utf8.EncodeRune(buf[len(buf)-utf8.RuneLen(r):], r) + } + return string(buf) +} diff --git a/pkg/windows/modules.go b/pkg/windows/modules.go index 97dd3af5..346ff072 100644 --- a/pkg/windows/modules.go +++ b/pkg/windows/modules.go @@ -46,6 +46,23 @@ func (i *InstallWSLUbuntuDistroModule) Init() { } } +// Move the distro to another drive to avoid excessive system disk space usage. +// If using the import method, you can directly specify the location, and it will later be switched to the import method +type MoveDistroModule struct { + common.KubeModule +} + +func (m *MoveDistroModule) Init() { + m.Name = "MoveDistro" + + m.Tasks = []task.Interface{ + &task.LocalTask{ + Name: "MoveDistro", + Action: &MoveDistro{}, + }, + } +} + type ConfigWslModule struct { common.KubeModule } @@ -116,3 +133,18 @@ func (u *UninstallOlaresModule) Init() { }, } } + +type GetDiskPartitionModule struct { + common.KubeModule +} + +func (g *GetDiskPartitionModule) Init() { + g.Name = "GetDiskPartition" + + g.Tasks = []task.Interface{ + &task.LocalTask{ + Name: "GetDiskPartition", + Action: &GetDiskPartition{}, + }, + } +} diff --git a/pkg/windows/tasks.go b/pkg/windows/tasks.go index cc363b7d..b0c1c9c8 100644 --- a/pkg/windows/tasks.go +++ b/pkg/windows/tasks.go @@ -110,9 +110,9 @@ func (u *UpdateWSL) Execute(runtime connector.Runtime) error { } var cmd = &utils.DefaultCommandExecutor{ - Commands: []string{"wsl", "--update"}, + Commands: []string{"--update"}, } - if _, err := cmd.Run(); err != nil { + if _, err := cmd.RunCmd("wsl", utils.DEFAULT); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("Update WSL failed")) } @@ -148,13 +148,19 @@ type InstallWSLDistro struct { } func (i *InstallWSLDistro) Execute(runtime connector.Runtime) error { - var cmd = &utils.PowerShellCommandExecutor{ - Commands: []string{ubuntuTool, "install", "--root"}, + var cmd = &utils.DefaultCommandExecutor{ + Commands: []string{"install", "--root"}, PrintLine: true, } - if _, err := cmd.Run(); err != nil { - fmt.Printf("Install WSL Ubuntu Distro failed, please check if it is already installed.\nyou can uninstall it by \"wsl --unregister Ubuntu\".\n\n") - return fmt.Errorf("install WSL Ubuntu Distro error %v", err) + if _, err := cmd.RunCmd(ubuntuTool, utils.GBK); err != nil { + fmt.Printf("\nStop Installation !!!!!!!\n\n") + fmt.Printf("Installing Windows Olares will use the Ubuntu Distro. It has been detected that there is already an existing Ubuntu Distro in the system. \n\n") + fmt.Printf("You can use the 'wsl -l --all' command to view the list of WSL Distros.\n\n") + fmt.Printf("To proceed with the installation of Olares, you need to unregister the existing Ubuntu Distro. If your Ubuntu Distro contains important information, please back it up first, then unregister the Ubuntu Distro. \n\n") + fmt.Printf("Uninstallation command: 'wsl --unregister Ubuntu'\n\n") + fmt.Printf("After the unregister Ubuntu Distro is complete, please reinstall Olares.\n\n") + + return fmt.Errorf("need to unregister Ubuntu Distro") } logger.Infof("Install WSL Ubuntu Distro %s successd\n", distro) @@ -162,22 +168,71 @@ func (i *InstallWSLDistro) Execute(runtime connector.Runtime) error { return nil } +type MoveDistro struct { + common.KubeAction +} + +func (m *MoveDistro) Execute(runtime connector.Runtime) error { + distroStoreDriver, _ := m.PipelineCache.GetMustString(common.CacheWindowsDistroStoreLocation) + if distroStoreDriver == "" { + return errors.New("get distro location failed") + } + var distroStorePath = fmt.Sprintf("%s:\\.olares\\distro", distroStoreDriver) + if !utils.IsExist(distroStorePath) { + utils.CreateDir(distroStorePath) + } + + var si = runtime.GetSystemInfo() + var aclCmd = &utils.DefaultCommandExecutor{ + Commands: []string{fmt.Sprintf("%s:\\.olares", distroStoreDriver), "/grant", fmt.Sprintf("Users:(OI)(CI)F")}, + } + + logger.Infof("distro store path: %s, user: %s", distroStorePath, si.GetUsername()) + + if aclRes, err := aclCmd.RunCmd("icacls", utils.GBK); err != nil { + logger.Debugf("icacls exec failed, err: %v, message: %s", err, aclRes) + return err + } + + var cmd = &utils.DefaultCommandExecutor{ + Commands: []string{"--shutdown"}, + } + + _, _ = cmd.RunCmd("wsl", utils.DEFAULT) + + var removeCmd = &utils.DefaultCommandExecutor{ + Commands: []string{"--manage", distro, "--move", distroStorePath}, + } + + if _, err := removeCmd.RunCmd("wsl", utils.DEFAULT); err != nil { + return err + } + + cmd = &utils.DefaultCommandExecutor{ + Commands: []string{"--shutdown"}, + } + + _, _ = cmd.RunCmd("wsl", utils.DEFAULT) + + return nil +} + type ConfigWslConf struct { common.KubeAction } func (c *ConfigWslConf) Execute(runtime connector.Runtime) error { var cmd = &utils.DefaultCommandExecutor{ - Commands: []string{"wsl", "-d", distro, "-u", "root", "bash", "-c", "echo -e '[boot]\\nsystemd=true\\ncommand=\"mount --make-rshared /\"\\n[network]\\ngenerateHosts=false\\ngenerateResolvConf=false\\nhostname=terminus' > /etc/wsl.conf"}, + Commands: []string{"-d", distro, "-u", "root", "bash", "-c", "echo -e '[boot]\\nsystemd=true\\ncommand=\"mount --make-rshared /\"\\n[network]\\ngenerateHosts=false\\ngenerateResolvConf=false\\nhostname=terminus' > /etc/wsl.conf"}, } - if _, err := cmd.Run(); err != nil { + if _, err := cmd.RunCmd("wsl", utils.DEFAULT); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("config wsl %s hosts and dns failed", distro)) } cmd = &utils.DefaultCommandExecutor{ - Commands: []string{"wsl", "--shutdown", distro}, + Commands: []string{"--shutdown", distro}, } - if _, err := cmd.Run(); err != nil { + if _, err := cmd.RunCmd("wsl", utils.DEFAULT); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("shutdown wsl %s failed", distro)) } @@ -190,6 +245,7 @@ type ConfigWSLForwardRules struct { func (c *ConfigWSLForwardRules) ipFormat(wslIp string) string { var pip net.IP + wslIp = strings.ReplaceAll(wslIp, "\n", "\r") var ipStrs = strings.Split(wslIp, "\r") if len(ipStrs) == 0 { return "" @@ -225,7 +281,6 @@ func (c *ConfigWSLForwardRules) Execute(runtime connector.Runtime) error { } ip = c.ipFormat(ip) - if ip == "" { return fmt.Errorf("wsl ip address not found") } @@ -235,26 +290,24 @@ func (c *ConfigWSLForwardRules) Execute(runtime connector.Runtime) error { cmd = &utils.DefaultCommandExecutor{ Commands: []string{fmt.Sprintf("netsh interface portproxy add v4tov4 listenport=80 listenaddress=0.0.0.0 connectport=80 connectaddress=%s", ip)}, } - - if _, err = cmd.Run(); err != nil { - logger.Debugf("set portproxy listenport 80 failed, maybe it's already exist %v", err) + if output, err := cmd.Run(); err != nil { + logger.Debugf("set portproxy listenport 80 failed %v, message: %s", err, output) return errors.Wrap(errors.WithStack(err), fmt.Sprintf("config wsl %s forward rules failed", distro)) } cmd = &utils.DefaultCommandExecutor{ Commands: []string{fmt.Sprintf("netsh interface portproxy add v4tov4 listenport=443 listenaddress=0.0.0.0 connectport=443 connectaddress=%s", ip)}, } - if _, err = cmd.Run(); err != nil { - logger.Debugf("set portproxy listenport 443 failed, maybe it's already exist %v", err) + if output, err := cmd.Run(); err != nil { + logger.Debugf("set portproxy listenport 443 failed %v, message: %s", err, output) return errors.Wrap(errors.WithStack(err), fmt.Sprintf("config wsl %s forward rules failed", distro)) } cmd = &utils.DefaultCommandExecutor{ Commands: []string{fmt.Sprintf("netsh interface portproxy add v4tov4 listenport=30180 listenaddress=0.0.0.0 connectport=30180 connectaddress=%s", ip)}, } - - if _, err = cmd.Run(); err != nil { - logger.Debugf("set portproxy listenport 30180 failed, maybe it's already exist %v", err) + if output, err := cmd.Run(); err != nil { + logger.Debugf("set portproxy listenport 30180 failed %v, message: %s", err, output) return errors.Wrap(errors.WithStack(err), fmt.Sprintf("config wsl %s forward rules failed", distro)) } @@ -267,15 +320,15 @@ type ConfigWSLHostsAndDns struct { func (c *ConfigWSLHostsAndDns) Execute(runtime connector.Runtime) error { var cmd = &utils.DefaultCommandExecutor{ - Commands: []string{"wsl", "-d", distro, "-u", "root", "bash", "-c", "chattr -i /etc/hosts /etc/resolv.conf && "}, + Commands: []string{"-d", distro, "-u", "root", "bash", "-c", "chattr -i /etc/hosts /etc/resolv.conf && "}, } - _, _ = cmd.Run() + _, _ = cmd.RunCmd("wsl", utils.DEFAULT) cmd = &utils.DefaultCommandExecutor{ - Commands: []string{"wsl", "-d", distro, "-u", "root", "bash", "-c", "echo -e '127.0.0.1 localhost\\n$(ip -4 addr show eth0 | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}') $(hostname)' > /etc/hosts && echo -e 'nameserver 1.1.1.1\\nnameserver 1.0.0.1' > /etc/resolv.conf"}, + Commands: []string{"-d", distro, "-u", "root", "bash", "-c", "echo -e '127.0.0.1 localhost\\n$(ip -4 addr show eth0 | grep -oP '(?<=inet\\s)\\d+(\\.\\d+){3}') $(hostname)' > /etc/hosts && echo -e 'nameserver 1.1.1.1\\nnameserver 1.0.0.1' > /etc/resolv.conf"}, } - if _, err := cmd.Run(); err != nil { + if _, err := cmd.RunCmd("wsl", utils.DEFAULT); err != nil { return errors.Wrap(errors.WithStack(err), fmt.Sprintf("config wsl %s hosts and dns failed", distro)) } @@ -368,23 +421,29 @@ func (i *InstallTerminus) Execute(runtime connector.Runtime) error { fmt.Sprintf("export %s=%s", common.ENV_NVIDIA_CONTAINER_REPO_MIRROR, os.Getenv(common.ENV_NVIDIA_CONTAINER_REPO_MIRROR)), } + var bashUrl = fmt.Sprintf("https://%s", cc.DefaultBashUrl) var defaultDomainName = os.Getenv(common.ENV_TERMINUS_OS_DOMAINNAME) if !utils.IsValidDomain(defaultDomainName) { defaultDomainName = "" } if defaultDomainName != "" { envs = append(envs, fmt.Sprintf("export %s=%s", common.ENV_TERMINUS_OS_DOMAINNAME, defaultDomainName)) + bashUrl = fmt.Sprintf("https://%s", defaultDomainName) } for key, val := range common.TerminusGlobalEnvs { envs = append(envs, fmt.Sprintf("export %s=%s", key, val)) } - var installScript = fmt.Sprintf("curl -fsSL https://olares.sh | bash -") + var downloadUrl = i.KubeConf.Arg.DownloadCdnUrl + if downloadUrl == "" { + downloadUrl = cc.DownloadUrl + } + var installScript = fmt.Sprintf("curl -fsSL %s | bash -", bashUrl) if i.KubeConf.Arg.TerminusVersion != "" { var installFile = fmt.Sprintf("install-wizard-v%s.tar.gz", i.KubeConf.Arg.TerminusVersion) installScript = fmt.Sprintf("curl -fsSLO %s/%s && tar -xf %s -C ./ ./install.sh && rm -rf %s && bash ./install.sh", - cc.DownloadUrl, installFile, installFile, installFile) + downloadUrl, installFile, installFile, installFile) } var params = strings.Join(envs, " && ") @@ -419,9 +478,9 @@ type UninstallOlares struct { func (u *UninstallOlares) Execute(runtime connector.Runtime) error { var cmd = &utils.DefaultCommandExecutor{ - Commands: []string{"wsl", "--unregister", "Ubuntu"}, + Commands: []string{"--unregister", "Ubuntu"}, } - _, _ = cmd.Run() + _, _ = cmd.RunCmd("wsl", utils.UTF16) return nil } @@ -446,8 +505,81 @@ func (r *RemovePortProxy) Execute(runtime connector.Runtime) error { var ports = []string{"80", "443", "30180"} for _, port := range ports { (&utils.DefaultCommandExecutor{ - Commands: []string{fmt.Sprintf("netsh interface portproxy delete v4tov4 listenport=%s listenaddress=0.0.0.0", port)}}).Run() + Commands: []string{"interface", "portproxy", "delete", "v4tov4", fmt.Sprintf("listenport=%s", port), "listenaddress=0.0.0.0"}}).RunCmd("netsh", utils.DEFAULT) } return nil } + +type GetDiskPartition struct { + common.KubeAction +} + +func (g *GetDiskPartition) Execute(runtime connector.Runtime) error { + var partitions []string + paths := utils.GetDrives() + if paths == nil || len(paths) == 0 { + return fmt.Errorf("Unable to retrieve disk information") + } + + for _, path := range paths { + _, free, err := utils.GetDiskSpace(path) + if err != nil { + continue + } + partitions = append(partitions, fmt.Sprintf("%s_%s", path, utils.FormatBytes(int64(free)))) + } + + if len(partitions) == 0 { + return fmt.Errorf("Unable to retrieve disk space information") + } + fmt.Printf("\nInstalling Olares will create a WSL Ubuntu Distro and occupy at least 80 GB of disk space. \nCurrent disk available space, please select the disk to store the WSL Ubuntu Distro: \n\n") + for _, v := range partitions { + var tmp = strings.Split(v, "_") + fmt.Printf("%s Free Disk: %s\n", tmp[0], tmp[1]) + } + + var enterPath string + var useDefaultDisk = os.Getenv(common.ENV_DEFAULT_WSL_DISTRO_LOCATION) + useDefaultDisk = strings.TrimSpace(useDefaultDisk) + + switch { + case useDefaultDisk != "": + enterPath = "C" + break + default: + scanner := bufio.NewScanner(os.Stdin) + + for { + fmt.Printf("\nPlease enter the drive, such as C, D, ... : ") + + scanner.Scan() + enterPath = scanner.Text() + enterPath = strings.TrimSpace(enterPath) + checkPathValid := g.checkEnter(enterPath, partitions) + if !checkPathValid { + continue + } + break + } + } + + g.PipelineCache.Set(common.CacheWindowsDistroStoreLocation, enterPath) + fmt.Printf("\n") + + return nil +} + +func (g *GetDiskPartition) checkEnter(enterPath string, partitions []string) bool { + var res bool = false + for _, v := range partitions { + var tmp = fmt.Sprintf("%s:\\", enterPath) + var p = strings.Split(v, "_") + if tmp == p[0] { + res = true + break + } + } + + return res +}