-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stéphane Graber <[email protected]>
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//go:build linux | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
cli "github.com/lxc/incus/internal/cmd" | ||
"github.com/lxc/incus/internal/i18n" | ||
"github.com/lxc/incus/shared/util" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
type cmdAdminCluster struct { | ||
global *cmdGlobal | ||
} | ||
|
||
func (c *cmdAdminCluster) Command() *cobra.Command { | ||
cmd := &cobra.Command{} | ||
cmd.Use = usage("cluster") | ||
cmd.Short = i18n.G("Low-level cluster administration commands") | ||
cmd.Long = cli.FormatSection(i18n.G("Description"), i18n.G( | ||
`Low level administration tools for inspecting and recovering clusters.`)) | ||
|
||
cmd.Run = c.Run | ||
return cmd | ||
} | ||
|
||
func (c *cmdAdminCluster) Run(cmd *cobra.Command, args []string) { | ||
path, _ := exec.LookPath("incusd") | ||
if path == "" { | ||
if util.PathExists("/usr/lib/incus/incusd") { | ||
path = "/usr/lib/incus/incusd" | ||
} else if util.PathExists("/opt/incus/bin/incusd") { | ||
path = "/opt/incus/bin/incusd" | ||
} | ||
} | ||
|
||
if path == "" { | ||
fmt.Println(i18n.G(`The "cluster" subcommand requires access to internal server data. | ||
To do so, it's actually part of the "incusd" binary rather than "incus". | ||
You can invoke it through "incusd cluster".`)) | ||
os.Exit(1) | ||
} | ||
|
||
doExec(path, []string{"incusd", "cluster"}, getEnviron()) | ||
} |