remove FUSE mount responsibility from olliesrv
This commit is contained in:
parent
921d46d2e5
commit
23dd7fc490
32
main.go
32
main.go
|
|
@ -29,7 +29,6 @@ import (
|
|||
|
||||
const serviceName = "ollie"
|
||||
|
||||
var mountPath = flag.String("mount", "", "FUSE mount path (default: $HOME/mnt/ollie)")
|
||||
var tcpAddr = flag.String("tcp", "", "also listen on TCP address (e.g. :564)")
|
||||
var strict = flag.Bool("strict", false, "only allow tool steps; reject inline code")
|
||||
var yolo = flag.Bool("yolo", false, "skip landrun sandbox for execute_code")
|
||||
|
|
@ -176,9 +175,6 @@ func isRunning(sockPath string) bool {
|
|||
func daemonize(pidPath string) {
|
||||
exe, _ := os.Executable()
|
||||
args := []string{"fgstart"}
|
||||
if *mountPath != "" {
|
||||
args = append(args, "-mount", *mountPath)
|
||||
}
|
||||
if *tcpAddr != "" {
|
||||
args = append(args, "-tcp", *tcpAddr)
|
||||
}
|
||||
|
|
@ -317,30 +313,6 @@ func runServer(sockPath, pidPath string) {
|
|||
fmt.Printf("olliesrv listening on tcp %s\n", *tcpAddr)
|
||||
}
|
||||
|
||||
// Optional FUSE mount
|
||||
mnt := *mountPath
|
||||
if mnt == "" {
|
||||
mnt = os.Getenv("OLLIE")
|
||||
}
|
||||
if mnt == "" {
|
||||
home, _ := os.UserHomeDir()
|
||||
mnt = filepath.Join(home, "mnt", "ollie")
|
||||
}
|
||||
var fuseCmd *exec.Cmd
|
||||
if err := os.MkdirAll(mnt, fs.PermMkdir); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "warning: cannot create mount dir: %v\n", err)
|
||||
} else {
|
||||
exe, _ := os.Executable()
|
||||
fuseCmd = exec.Command(filepath.Join(filepath.Dir(exe), "ollie-9p-mount"),
|
||||
"-u", os.Getenv("USER"), "-net", "unix", "-addr", sockPath, mnt)
|
||||
if err := fuseCmd.Start(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "warning: ollie-9p-mount: %v\n", err)
|
||||
fuseCmd = nil
|
||||
} else {
|
||||
fmt.Printf("mounted at %s\n", mnt)
|
||||
}
|
||||
}
|
||||
|
||||
sigChan := make(chan os.Signal, 1)
|
||||
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-sigChan
|
||||
|
|
@ -348,10 +320,6 @@ func runServer(sockPath, pidPath string) {
|
|||
srv.InterruptAll()
|
||||
fmt.Println("shutting down")
|
||||
srv.Shutdown()
|
||||
if fuseCmd != nil {
|
||||
exec.Command("fusermount", "-u", mnt).Run() //nolint:errcheck
|
||||
fuseCmd.Wait() //nolint:errcheck
|
||||
}
|
||||
listener.Close() //nolint:errcheck
|
||||
if tcpListener != nil {
|
||||
tcpListener.Close() //nolint:errcheck
|
||||
|
|
|
|||
Reference in New Issue