auto daemon-reload where applicable
This commit is contained in:
23
app.go
23
app.go
@@ -253,6 +253,9 @@ func (a *App) setupClientMount() error {
|
||||
return err
|
||||
}
|
||||
if mountNow {
|
||||
if err := a.reloadSystemdIfNeeded(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := a.mountCIFS(cfg.MountPoint); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -779,6 +782,26 @@ func (a *App) mountCIFS(path string) error {
|
||||
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 {
|
||||
for _, section := range doc.ShareSections() {
|
||||
cfg := ShareFromSection(section)
|
||||
|
||||
Reference in New Issue
Block a user