mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-13 22:47:30 +00:00
cmd/tailscale/cli: move systray configuration to tailscale configure (#16817)
Updates #1708 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
@@ -32,6 +32,7 @@ services on the host to use Tailscale in more ways.
|
|||||||
ccall(maybeSysExtCmd),
|
ccall(maybeSysExtCmd),
|
||||||
ccall(maybeVPNConfigCmd),
|
ccall(maybeVPNConfigCmd),
|
||||||
ccall(maybeJetKVMConfigureCmd),
|
ccall(maybeJetKVMConfigureCmd),
|
||||||
|
ccall(maybeSystrayCmd),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
cmd/tailscale/cli/configure_linux-all.go
Normal file
8
cmd/tailscale/cli/configure_linux-all.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
package cli
|
||||||
|
|
||||||
|
import "github.com/peterbourgon/ff/v3/ffcli"
|
||||||
|
|
||||||
|
var maybeSystrayCmd func() *ffcli.Command // non-nil only on Linux, see configure_linux.go
|
51
cmd/tailscale/cli/configure_linux.go
Normal file
51
cmd/tailscale/cli/configure_linux.go
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
//go:build linux && !ts_omit_systray
|
||||||
|
|
||||||
|
package cli
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/peterbourgon/ff/v3/ffcli"
|
||||||
|
"tailscale.com/client/systray"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
maybeSystrayCmd = systrayConfigCmd
|
||||||
|
}
|
||||||
|
|
||||||
|
var systrayArgs struct {
|
||||||
|
initSystem string
|
||||||
|
installStartup bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func systrayConfigCmd() *ffcli.Command {
|
||||||
|
return &ffcli.Command{
|
||||||
|
Name: "systray",
|
||||||
|
ShortUsage: "tailscale configure systray [options]",
|
||||||
|
ShortHelp: "[ALPHA] Manage the systray client for Linux",
|
||||||
|
LongHelp: "[ALPHA] The systray set of commands provides a way to configure the systray application on Linux.",
|
||||||
|
Exec: configureSystray,
|
||||||
|
FlagSet: (func() *flag.FlagSet {
|
||||||
|
fs := newFlagSet("systray")
|
||||||
|
fs.StringVar(&systrayArgs.initSystem, "enable-startup", "",
|
||||||
|
"Install startup script for init system. Currently supported systems are [systemd].")
|
||||||
|
return fs
|
||||||
|
})(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func configureSystray(_ context.Context, _ []string) error {
|
||||||
|
if systrayArgs.initSystem != "" {
|
||||||
|
if err := systray.InstallStartupScript(systrayArgs.initSystem); err != nil {
|
||||||
|
fmt.Printf("%s\n\n", err.Error())
|
||||||
|
return flag.ErrHelp
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return flag.ErrHelp
|
||||||
|
}
|
@@ -7,41 +7,20 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/peterbourgon/ff/v3/ffcli"
|
"github.com/peterbourgon/ff/v3/ffcli"
|
||||||
"tailscale.com/client/systray"
|
"tailscale.com/client/systray"
|
||||||
)
|
)
|
||||||
|
|
||||||
var systrayArgs struct {
|
|
||||||
initSystem string
|
|
||||||
installStartup bool
|
|
||||||
}
|
|
||||||
|
|
||||||
var systrayCmd = &ffcli.Command{
|
var systrayCmd = &ffcli.Command{
|
||||||
Name: "systray",
|
Name: "systray",
|
||||||
ShortUsage: "tailscale systray",
|
ShortUsage: "tailscale systray",
|
||||||
ShortHelp: "Run a systray application to manage Tailscale",
|
ShortHelp: "Run a systray application to manage Tailscale",
|
||||||
LongHelp: `Run a systray application to manage Tailscale.
|
LongHelp: "Run a systray application to manage Tailscale.",
|
||||||
To have the application run on startup, use the --enable-startup flag.`,
|
Exec: runSystray,
|
||||||
Exec: runSystray,
|
|
||||||
FlagSet: (func() *flag.FlagSet {
|
|
||||||
fs := newFlagSet("systray")
|
|
||||||
fs.StringVar(&systrayArgs.initSystem, "enable-startup", "",
|
|
||||||
"Install startup script for init system. Currently supported systems are [systemd].")
|
|
||||||
return fs
|
|
||||||
})(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runSystray(ctx context.Context, _ []string) error {
|
func runSystray(ctx context.Context, _ []string) error {
|
||||||
if systrayArgs.initSystem != "" {
|
|
||||||
if err := systray.InstallStartupScript(systrayArgs.initSystem); err != nil {
|
|
||||||
fmt.Printf("%s\n\n", err.Error())
|
|
||||||
return flag.ErrHelp
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
new(systray.Menu).Run(&localClient)
|
new(systray.Menu).Run(&localClient)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user