MCPcopy
hub / github.com/IceWhaleTech/CasaOS / InitNetworkMount

Function InitNetworkMount

route/init.go:72–109  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72func 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}
110func InitZerotier() {
111 v1.CheckNetwork()
112}

Callers 1

InitFunctionFunction · 0.85

Calls 14

GetSambaSharesListFunction · 0.92
IsNotExistMkDirFunction · 0.92
GetConnectionsListMethod · 0.65
ConnectionsMethod · 0.65
GetConnectionByIDMethod · 0.65
DeleteConnectionMethod · 0.65
GetDirPathMethod · 0.65
SystemMethod · 0.65
UnmountSmabaMethod · 0.65
MountSmabaMethod · 0.65
UpdateConnectionMethod · 0.65
CheckAndMountAllMethod · 0.65

Tested by

no test coverage detected