Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CmdAdmin = cli.Command{ Name: "admin", Usage: "Admin commands", Subcommands: []*cli.Command{ &CmdAdminResetPassword, }, }
View Source
var CmdAdminResetPassword = cli.Command{ Name: "reset-password", Usage: "Reset the password for a given user", ArgsUsage: "[username] [password]", Action: func(ctx *cli.Context) error { initialize(ctx) if ctx.NArg() < 2 { return fmt.Errorf("username and password are required") } username := ctx.Args().Get(0) plainPassword := ctx.Args().Get(1) user, err := db.GetUserByUsername(username) if err != nil { fmt.Printf("Cannot get user %s: %s\n", username, err) return err } password, err := utils.Argon2id.Hash(plainPassword) if err != nil { fmt.Printf("Cannot hash password for user %s: %s\n", username, err) return err } user.Password = password if err = user.Update(); err != nil { fmt.Printf("Cannot update password for user %s: %s\n", username, err) return err } fmt.Printf("Password for user %s has been reset.\n", username) return nil }, }
View Source
var CmdHook = cli.Command{ Name: "hook", Usage: "Run Git server hooks, used and should only be called by Opengist itself", Subcommands: []*cli.Command{ &CmdHookPreReceive, &CmdHookPostReceive, }, }
View Source
var CmdHookPostReceive = cli.Command{ Name: "post-receive", Usage: "Run Git server post-receive hook for a repository", Action: func(ctx *cli.Context) error { initialize(ctx) if err := hooks.PostReceive(os.Stdin, os.Stdout, os.Stderr); err != nil { os.Exit(1) } return nil }, }
View Source
var CmdHookPreReceive = cli.Command{ Name: "pre-receive", Usage: "Run Git server pre-receive hook for a repository", Action: func(ctx *cli.Context) error { initialize(ctx) if err := hooks.PreReceive(os.Stdin, os.Stdout, os.Stderr); err != nil { os.Exit(1) } return nil }, }
View Source
var CmdStart = cli.Command{ Name: "start", Usage: "Start Opengist server", Action: func(ctx *cli.Context) error { stopCtx, stop := signal.NotifyContext(ctx.Context, syscall.SIGINT, syscall.SIGTERM) defer stop() Initialize(ctx) go web.NewServer(os.Getenv("OG_DEV") == "1", path.Join(config.GetHomeDir(), "sessions")).Start() go ssh.Start() <-stopCtx.Done() shutdown() return nil }, }
View Source
var CmdVersion = cli.Command{ Name: "version", Usage: "Print the version of Opengist", Action: func(c *cli.Context) error { fmt.Println("Opengist " + config.OpengistVersion) return nil }, }
View Source
var ConfigFlag = cli.StringFlag{ Name: "config", Aliases: []string{"c"}, Usage: "Path to a config file in YAML format", }
Functions ¶
func Initialize ¶
func Initialize(ctx *cli.Context)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.