mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-14 15:07:55 +00:00
client/systray: add startup script generator for systemd (#16801)
Updates #1708 Signed-off-by: Claus Lensbøl <claus@tailscale.com>
This commit is contained in:
@@ -7,17 +7,41 @@ package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/peterbourgon/ff/v3/ffcli"
|
||||
"tailscale.com/client/systray"
|
||||
)
|
||||
|
||||
var systrayArgs struct {
|
||||
initSystem string
|
||||
installStartup bool
|
||||
}
|
||||
|
||||
var systrayCmd = &ffcli.Command{
|
||||
Name: "systray",
|
||||
ShortUsage: "tailscale systray",
|
||||
ShortHelp: "Run a systray application to manage Tailscale",
|
||||
Exec: func(_ context.Context, _ []string) error {
|
||||
new(systray.Menu).Run(&localClient)
|
||||
return nil
|
||||
},
|
||||
LongHelp: `Run a systray application to manage Tailscale.
|
||||
To have the application run on startup, use the --enable-startup flag.`,
|
||||
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 {
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user