()
| 70 | } |
| 71 | |
| 72 | func InitNetworkMount() { |
| 73 | time.Sleep(time.Second * 10) |
| 74 | connections := service.MyService.Connections().GetConnectionsList() |
| 75 | for _, v := range connections { |
| 76 | connection := service.MyService.Connections().GetConnectionByID(fmt.Sprint(v.ID)) |
| 77 | directories, err := samba.GetSambaSharesList(connection.Host, connection.Port, connection.Username, connection.Password) |
| 78 | if err != nil { |
| 79 | service.MyService.Connections().DeleteConnection(fmt.Sprint(connection.ID)) |
| 80 | logger.Error("mount samba err", zap.Any("err", err), zap.Any("info", connection)) |
| 81 | continue |
| 82 | } |
| 83 | baseHostPath := "/mnt/" + connection.Host |
| 84 | |
| 85 | mountPointList, err := service.MyService.System().GetDirPath(baseHostPath) |
| 86 | if err != nil { |
| 87 | logger.Error("get mount point err", zap.Any("err", err)) |
| 88 | continue |
| 89 | } |
| 90 | for _, v := range mountPointList { |
| 91 | service.MyService.Connections().UnmountSmaba(v.Path) |
| 92 | } |
| 93 | |
| 94 | os.RemoveAll(baseHostPath) |
| 95 | |
| 96 | file.IsNotExistMkDir(baseHostPath) |
| 97 | for _, v := range directories { |
| 98 | mountPoint := baseHostPath + "/" + v |
| 99 | file.IsNotExistMkDir(mountPoint) |
| 100 | service.MyService.Connections().MountSmaba(connection.Username, connection.Host, v, connection.Port, mountPoint, connection.Password) |
| 101 | } |
| 102 | connection.Directories = strings.Join(directories, ",") |
| 103 | service.MyService.Connections().UpdateConnection(&connection) |
| 104 | } |
| 105 | err := service.MyService.Storage().CheckAndMountAll() |
| 106 | if err != nil { |
| 107 | logger.Error("mount storage err", zap.Any("err", err)) |
| 108 | } |
| 109 | } |
| 110 | func InitZerotier() { |
| 111 | v1.CheckNetwork() |
| 112 | } |
no test coverage detected