You've already forked CasaOS
mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-07-15 23:54:17 +02:00
Update samba (#1021)
This commit is contained in:
@ -11,11 +11,12 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
command2 "github.com/IceWhaleTech/CasaOS/pkg/utils/command"
|
||||
"fmt"
|
||||
|
||||
"github.com/IceWhaleTech/CasaOS/service/model"
|
||||
model2 "github.com/IceWhaleTech/CasaOS/service/model"
|
||||
"github.com/moby/sys/mount"
|
||||
"golang.org/x/sys/unix"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -26,7 +27,7 @@ type ConnectionsService interface {
|
||||
CreateConnection(connection *model2.ConnectionsDBModel)
|
||||
DeleteConnection(id string)
|
||||
UpdateConnection(connection *model2.ConnectionsDBModel)
|
||||
MountSmaba(username, host, directory, port, mountPoint, password string) string
|
||||
MountSmaba(username, host, directory, port, mountPoint, password string) error
|
||||
UnmountSmaba(mountPoint string) error
|
||||
}
|
||||
|
||||
@ -56,9 +57,17 @@ func (s *connectionsStruct) DeleteConnection(id string) {
|
||||
s.db.Where("id= ?", id).Delete(&model.ConnectionsDBModel{})
|
||||
}
|
||||
|
||||
func (s *connectionsStruct) MountSmaba(username, host, directory, port, mountPoint, password string) string {
|
||||
str := command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;MountCIFS " + username + " " + host + " " + directory + " " + port + " " + mountPoint + " " + password)
|
||||
return str
|
||||
func (s *connectionsStruct) MountSmaba(username, host, directory, port, mountPoint, password string) error {
|
||||
err := unix.Mount(
|
||||
fmt.Sprintf("//%s/%s", host, directory),
|
||||
mountPoint,
|
||||
"cifs",
|
||||
unix.MS_NOATIME|unix.MS_NODEV|unix.MS_NOSUID,
|
||||
fmt.Sprintf("username=%s,password=%s", username, password),
|
||||
)
|
||||
return err
|
||||
//str := command2.ExecResultStr("source " + config.AppInfo.ShellPath + "/helper.sh ;MountCIFS " + username + " " + host + " " + directory + " " + port + " " + mountPoint + " " + password)
|
||||
//return str
|
||||
}
|
||||
func (s *connectionsStruct) UnmountSmaba(mountPoint string) error {
|
||||
return mount.Unmount(mountPoint)
|
||||
|
Reference in New Issue
Block a user