diff --git a/cmd/tailscale/cli/cli.go b/cmd/tailscale/cli/cli.go index e461ca56b..c0b43e052 100644 --- a/cmd/tailscale/cli/cli.go +++ b/cmd/tailscale/cli/cli.go @@ -150,6 +150,8 @@ func Run(args []string) (err error) { rootCmd.Subcommands = append(rootCmd.Subcommands, serveCmd) case slices.Contains(args, "update"): rootCmd.Subcommands = append(rootCmd.Subcommands, updateCmd) + case slices.Contains(args, "configure"): + rootCmd.Subcommands = append(rootCmd.Subcommands, configureCmd) } if runtime.GOOS == "linux" && distro.Get() == distro.Synology { rootCmd.Subcommands = append(rootCmd.Subcommands, configureHostCmd) diff --git a/cmd/tailscale/cli/configure-host.go b/cmd/tailscale/cli/configure-synology.go similarity index 81% rename from cmd/tailscale/cli/configure-host.go rename to cmd/tailscale/cli/configure-synology.go index 7aeaa477a..3c3ed8e14 100644 --- a/cmd/tailscale/cli/configure-host.go +++ b/cmd/tailscale/cli/configure-synology.go @@ -18,9 +18,23 @@ "tailscale.com/version/distro" ) +// configureHostCmd is the "tailscale configure-host" command which +// was once used to configure Synology devices, but is now a redirect +// to "tailscale configure synology". var configureHostCmd = &ffcli.Command{ Name: "configure-host", - Exec: runConfigureHost, + Exec: runConfigureSynology, + ShortHelp: synologyConfigureCmd.ShortHelp, + LongHelp: synologyConfigureCmd.LongHelp, + FlagSet: (func() *flag.FlagSet { + fs := newFlagSet("configure-host") + return fs + })(), +} + +var synologyConfigureCmd = &ffcli.Command{ + Name: "synology", + Exec: runConfigureSynology, ShortHelp: "Configure Synology to enable more Tailscale features", LongHelp: strings.TrimSpace(` The 'configure-host' command is intended to run at boot as root @@ -30,14 +44,12 @@ See: https://tailscale.com/kb/1152/synology-outbound/ `), FlagSet: (func() *flag.FlagSet { - fs := newFlagSet("configure-host") + fs := newFlagSet("synology") return fs })(), } -var configureHostArgs struct{} - -func runConfigureHost(ctx context.Context, args []string) error { +func runConfigureSynology(ctx context.Context, args []string) error { if len(args) > 0 { return errors.New("unknown arguments") } diff --git a/cmd/tailscale/cli/configure.go b/cmd/tailscale/cli/configure.go new file mode 100644 index 000000000..f8aaad449 --- /dev/null +++ b/cmd/tailscale/cli/configure.go @@ -0,0 +1,32 @@ +// Copyright (c) Tailscale Inc & AUTHORS +// SPDX-License-Identifier: BSD-3-Clause + +package cli + +import ( + "context" + "flag" + "runtime" + + "github.com/peterbourgon/ff/v3/ffcli" + "tailscale.com/version/distro" +) + +var configureCmd = &ffcli.Command{ + Name: "configure", + FlagSet: (func() *flag.FlagSet { + fs := newFlagSet("configure") + return fs + })(), + Subcommands: configureSubcommands(), + Exec: func(ctx context.Context, args []string) error { + return flag.ErrHelp + }, +} + +func configureSubcommands() (out []*ffcli.Command) { + if runtime.GOOS == "linux" && distro.Get() == distro.Synology { + out = append(out, synologyConfigureCmd) + } + return out +}