Example #1
0
File: main.go Project: lht/termite
func main() {
	cachedir := flag.String("cachedir", "/tmp/fsserver-cache", "content cache")
	port := flag.Int("port", 1234, "file server")
	secretFile := flag.String("secret", "/tmp/secret.txt", "file containing password.")

	flag.Parse()
	if flag.NArg() < 1 {
		log.Fatalf("usage: %s EXPORTED-ROOT\n", os.Args[0])
	}
	secret, err := ioutil.ReadFile(*secretFile)
	if err != nil {
		log.Fatal("ReadFile", err)
	}
	cache := termite.NewContentCache(*cachedir)
	fileServer := termite.NewFsServer(flag.Arg(0), cache, []string{"/proc"})

	out := make(chan net.Conn)
	go termite.SetupServer(*port, secret, out)

	conn := <-out
	rpcServer := rpc.NewServer()
	err = rpcServer.Register(fileServer)
	if err != nil {
		log.Fatal("could not register file server", err)
	}
	log.Println("Server started...")
	rpcServer.ServeConn(conn)
}
Example #2
0
File: main.go Project: lht/termite
func main() {
	home := os.Getenv("HOME")
	cachedir := flag.String("cachedir",
		filepath.Join(home, ".cache", "termite-master"), "content cache")
	workers := flag.String("workers", "", "comma separated list of worker addresses")
	coordinator := flag.String("coordinator", "localhost:1233",
		"address of coordinator. Overrides -workers")
	socket := flag.String("socket", ".termite-socket", "socket to listen for commands")
	exclude := flag.String("exclude", "/sys,/proc,/dev,/selinux,/cgroup", "prefixes to not export.")
	secretFile := flag.String("secret", "secret.txt", "file containing password.")
	srcRoot := flag.String("sourcedir", "", "root of corresponding source directory")
	jobs := flag.Int("jobs", 1, "number of jobs to run")
	port := flag.Int("port", 1237, "http status port")

	flag.Parse()
	secret, err := ioutil.ReadFile(*secretFile)
	if err != nil {
		log.Fatal("ReadFile", err)
	}

	workerList := strings.Split(*workers, ",")
	excludeList := strings.Split(*exclude, ",")
	c := termite.NewContentCache(*cachedir)
	master := termite.NewMaster(
		c, *coordinator, workerList, secret, excludeList, *jobs)
	master.SetSrcRoot(*srcRoot)
	go master.ServeHTTP(*port)
	master.Start(*socket)
}
Example #3
0
File: main.go Project: lht/termite
func main() {
	cachedir := flag.String("cachedir", "/tmp/termite-cache", "content cache")
	server := flag.String("server", "localhost:1234", "file server")
	secretFile := flag.String("secret", "/tmp/secret.txt", "file containing password.")

	flag.Parse()
	if flag.NArg() < 1 {
		fmt.Fprintf(os.Stderr, "usage: %s MOUNTPOINT\n", os.Args[0])
		os.Exit(2)
	}
	secret, err := ioutil.ReadFile(*secretFile)
	if err != nil {
		log.Fatal("ReadFile", err)
	}

	rpcConn, err := termite.DialTypedConnection(*server, termite.RPC_CHANNEL, secret)
	if err != nil {
		log.Fatal("dialing:", err)
	}

	cache := termite.NewContentCache(*cachedir)
	fs := termite.NewRpcFs(rpc.NewClient(rpcConn), cache)
	conn := fuse.NewFileSystemConnector(fuse.NewPathNodeFs(fs), nil)
	state := fuse.NewMountState(conn)
	opts := fuse.MountOptions{}
	if os.Geteuid() == 0 {
		opts.AllowOther = true
	}

	state.Mount(flag.Arg(0), &opts)
	if err != nil {
		fmt.Printf("Mount fail: %v\n", err)
		os.Exit(1)
	}

	state.Debug = true
	state.Loop(false)
}