mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
cmd/tailscale: allow use of flags in gokrazy
Enable use of command line arguments with tailscale cli on gokrazy. Before this change using arguments like "up" would cause tailscale cli to be repeatedly restarted by gokrazy process supervisor. We never want to have gokrazy restart tailscale cli, even if user would manually start the process. Expected usage is that user creates files: flags/tailscale.com/cmd/tailscale/flags.txt: up flags/tailscale.com/cmd/tailscaled/flags.txt: --statedir=/perm/tailscaled/ --tun=userspace-networking Then tailscale prints URL for user to log in with browser. Alternatively it should be possible to use up with auth key to allow unattended gokrazy installs. Signed-off-by: Joonas Kuorilehto <joneskoo@derbian.fi>
This commit is contained in:
parent
2c89b3a601
commit
c1b3500a05
@ -125,16 +125,21 @@ func CleanUpArgs(args []string) []string {
|
||||
}
|
||||
|
||||
// Run runs the CLI. The args do not include the binary name.
|
||||
func Run(args []string) error {
|
||||
func Run(args []string) (err error) {
|
||||
if len(args) == 1 && (args[0] == "-V" || args[0] == "--version") {
|
||||
args = []string{"version"}
|
||||
}
|
||||
if runtime.GOOS == "linux" && distro.Get() == distro.Gokrazy && len(args) == 0 &&
|
||||
if runtime.GOOS == "linux" && distro.Get() == distro.Gokrazy &&
|
||||
os.Getenv("GOKRAZY_FIRST_START") == "1" {
|
||||
// Exit with 125 otherwise the CLI binary is restarted
|
||||
// forever in a loop by the Gokrazy process supervisor.
|
||||
// See https://gokrazy.org/userguide/process-interface/
|
||||
os.Exit(125)
|
||||
defer func() {
|
||||
// Exit with 125 otherwise the CLI binary is restarted
|
||||
// forever in a loop by the Gokrazy process supervisor.
|
||||
// See https://gokrazy.org/userguide/process-interface/
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
os.Exit(125)
|
||||
}()
|
||||
}
|
||||
|
||||
var warnOnce sync.Once
|
||||
@ -201,7 +206,7 @@ func Run(args []string) error {
|
||||
}
|
||||
})
|
||||
|
||||
err := rootCmd.Run(context.Background())
|
||||
err = rootCmd.Run(context.Background())
|
||||
if tailscale.IsAccessDeniedError(err) && os.Getuid() != 0 && runtime.GOOS != "windows" {
|
||||
return fmt.Errorf("%v\n\nUse 'sudo tailscale %s' or 'tailscale up --operator=$USER' to not require root.", err, strings.Join(args, " "))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user