auto daemon-reload where applicable
This commit is contained in:
@@ -34,6 +34,7 @@ The program:
|
|||||||
- If saving the Samba config or its backup needs admin rights, explains the issue and offers to retry with `sudo`.
|
- If saving the Samba config or its backup needs admin rights, explains the issue and offers to retry with `sudo`.
|
||||||
- Writes a timestamped backup before saving changes.
|
- Writes a timestamped backup before saving changes.
|
||||||
- Can append a CIFS mount entry to `/etc/fstab`, including an inline username and password if that is the setup you want.
|
- Can append a CIFS mount entry to `/etc/fstab`, including an inline username and password if that is the setup you want.
|
||||||
|
- If it updates `/etc/fstab` on a systemd system, it reloads systemd before attempting the mount.
|
||||||
|
|
||||||
If you create a local account for a Samba-authenticated share, you may still need to add the Samba password separately:
|
If you create a local account for a Samba-authenticated share, you may still need to add the Samba password separately:
|
||||||
|
|
||||||
|
|||||||
23
app.go
23
app.go
@@ -253,6 +253,9 @@ func (a *App) setupClientMount() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if mountNow {
|
if mountNow {
|
||||||
|
if err := a.reloadSystemdIfNeeded(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if err := a.mountCIFS(cfg.MountPoint); err != nil {
|
if err := a.mountCIFS(cfg.MountPoint); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -779,6 +782,26 @@ func (a *App) mountCIFS(path string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) reloadSystemdIfNeeded() error {
|
||||||
|
if _, err := os.Stat("/run/systemd/system"); err != nil {
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return fmt.Errorf("check for systemd: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.lookPath != nil {
|
||||||
|
if _, err := a.lookPath("systemctl"); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := a.runPrivilegedOrLocal("systemctl", []string{"daemon-reload"}, "Refreshing system mount settings needs administrator permission."); err != nil {
|
||||||
|
return fmt.Errorf("reload systemd after updating /etc/fstab: %w", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) ensureShareDirectories(doc *Document) error {
|
func (a *App) ensureShareDirectories(doc *Document) error {
|
||||||
for _, section := range doc.ShareSections() {
|
for _, section := range doc.ShareSections() {
|
||||||
cfg := ShareFromSection(section)
|
cfg := ShareFromSection(section)
|
||||||
|
|||||||
BIN
samba-configer
BIN
samba-configer
Binary file not shown.
Reference in New Issue
Block a user