cli

package
v1.7.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2024 License: AGPL-3.0 Imports: 16 Imported by: 0

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 {
		Initialize(ctx)
		go web.NewServer(os.Getenv("OG_DEV") == "1").Start()
		go ssh.Start()
		select {}
	},
}
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 App

func App() error

func Initialize

func Initialize(ctx *cli.Context)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL