func main() { // When we run under the device manager, no environment is set up. // We want to have some kind of path. if os.Getenv("PATH") == "" { os.Setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin") os.Setenv("HOME", "/home/testuser1") } cmdline.Main(root) } var root = &cmdline.Command{ Name: os.Args[0], ArgsName: "<name>", ArgsLong: "<name> Is the name to mount the server under.", Runner: v23cmd.RunnerFunc(serve), Short: "Serve a display to remote clients.", } func serve(ctx *context.T, env *cmdline.Env, args []string) error { name := "" if len(args) > 0 { name = args[0] fmt.Printf("mounting under: %s\n", name) } _, server, err := v23.WithNewServer(ctx, name, defaultMediaServer(), security.AllowEveryone()) if err != nil { return err } fmt.Printf("Listening at: %s", server.Status().Endpoints[0].Name())
) const ( // TODO(ataly): Define these conventions in the README recvKeySuffix = "recvkey" lockUserNhPrefix = "user-" lockUserNhGlobPrefix = "nh/user-" vanadiumBlessingPrefix = "dev.v.io:u" ) var ( flagSendKeyExpiry time.Duration lockNhGlobPrefix = path.Join("nh", locklib.LockNhPrefix) cmdScan = &cmdline.Command{ Runner: v23cmd.RunnerFunc(runScan), Name: "scan", Short: "Scan the neighborhood for lock devices", Long: ` Searches for lock devices (both claimed and unclaimed) nearby. `, } cmdUsers = &cmdline.Command{ Runner: v23cmd.RunnerFunc(runUsers), Name: "users", Short: "Scan the neighborhood for physical-lock users", Long: ` Searches for physical-lock users nearby. `, } cmdClaim = &cmdline.Command{
"v.io/x/lib/cmdline" "v.io/x/ref/lib/signals" "v.io/x/ref/lib/v23cmd" _ "v.io/x/ref/runtime/factories/roaming" ) var configDir string func main() { cmdRoot.Flags.StringVar(&configDir, "config-dir", "", "Directory where the lock configuration files are stored. It will be created if it does not exist.") cmdline.HideGlobalFlagsExcept() cmdline.Main(cmdRoot) } var cmdRoot = &cmdline.Command{ Runner: v23cmd.RunnerFunc(runLockD), Name: "lockd", Short: "Runs the lockd server", Long: ` Command lockd runs the lockd server, which implements the UnclaimedLock or the Lock interface depending on the files in the configuration directory. `, } func runLockD(ctx *context.T, env *cmdline.Env, args []string) error { if len(configDir) == 0 { return errors.New("--config-dir must be specified") } if finfo, err := os.Stat(configDir); os.IsNotExist(err) { if err := os.MkdirAll(configDir, os.FileMode(0700)); err != nil { return fmt.Errorf("could not create configuration directory %v: %v", configDir, err)
var stream *bool func main() { stream = root.Flags.Bool("stream", true, "If true stream the data instead of sending the URL.") cmdline.Main(root) } var root = &cmdline.Command{ Name: os.Args[0], ArgsName: "<server> <url>", ArgsLong: ("<server> is the Vanadium name of a media server. " + "<url> is an url to some content."), Runner: v23cmd.RunnerFunc(display), Short: "Share media with a remote display.", } type streamWriter struct { buf []byte stream interface { Send(item []byte) error Close() error } } func (w *streamWriter) Write(p []byte) (n int, err error) { return len(p), w.stream.Send(p) }