package mount import ( "errors" "log" "os" "bazil.org/fuse" "github.com/mdlayher/sdnotify" ) func Mount(mountpoint string) error { n, err := sdnotify.New() if err != nil && !errors.Is(err, os.ErrNotExist) { log.Fatalf("failed to open systemd notifier: %v", err) } err = n.Notify( sdnotify.Statusf("service started successfully"), sdnotify.Ready, ) if err != nil { log.Fatalf("failed to send ready notification: %v", err) } return Unmount(mountpoint, n) } func Unmount(mountpoint string, n *sdnotify.Notifier) error { log.Println("Unmounting...") err := n.Notify( sdnotify.Statusf("service stopped successfully"), sdnotify.Ready, ) if err != nil { log.Fatalf("failed to send stop notification: %v", err) } fuse.Unmount(mountpoint) return nil }