Documentation
¶
Overview ¶
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Package cmd Copyright © 2022 Noah Hsu<i@nn.ci>
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AdminCmd = &cobra.Command{ Use: "admin", Aliases: []string{"password"}, Short: "Show admin user's info and some operations about admin user's password", Run: func(cmd *cobra.Command, args []string) { bootstrap.Init() defer bootstrap.Release() admin, err := op.GetAdmin() if err != nil { utils.Log.Errorf("failed get admin user: %+v", err) } else { utils.Log.Infof("get admin user from CLI") fmt.Println("Admin user's username:", admin.Username) fmt.Println("The password can only be output at the first startup, and then stored as a hash value, which cannot be reversed") fmt.Println("You can reset the password with a random string by running [openlist admin random]") fmt.Println("You can also set a new password by running [openlist admin set NEW_PASSWORD]") } }, }
AdminCmd represents the password command
var Cancel2FACmd = &cobra.Command{ Use: "cancel2fa", Short: "Delete 2FA of admin user", Run: func(cmd *cobra.Command, args []string) { bootstrap.Init() defer bootstrap.Release() admin, err := op.GetAdmin() if err != nil { utils.Log.Errorf("failed to get admin user: %+v", err) } else { err := op.Cancel2FAByUser(admin) if err != nil { utils.Log.Errorf("failed to cancel 2FA: %+v", err) } else { utils.Log.Infof("2FA is canceled from CLI") fmt.Println("2FA canceled") DelAdminCacheOnline() } } }, }
Cancel2FACmd represents the delete2fa command
var CryptCmd = &cobra.Command{ Use: "crypt", Short: "Encrypt or decrypt local file or dir", Example: `openlist crypt -s ./src/encrypt/ --op=de --pwd=123456 --salt=345678`, Run: func(cmd *cobra.Command, args []string) { opt.validate() opt.cryptFileDir() }, }
CryptCmd represents the crypt command
var KillCmd = &cobra.Command{ Use: "kill", Short: "Force kill openlist server process by daemon/pid file", Run: func(cmd *cobra.Command, args []string) { kill() }, }
KillCmd represents the kill command
var LangCmd = &cobra.Command{ Use: "lang", Short: "Generate language json file", Run: func(cmd *cobra.Command, args []string) { frontendPath, _ = cmd.Flags().GetString("frontend-path") bootstrap.InitConfig() err := os.MkdirAll("lang", 0777) if err != nil { utils.Log.Fatalf("failed create folder: %s", err.Error()) } generateDriversJson() generateSettingsJson() }, }
LangCmd represents the lang command
var RandomPasswordCmd = &cobra.Command{ Use: "random", Short: "Reset admin user's password to a random string", Run: func(cmd *cobra.Command, args []string) { utils.Log.Infof("reset admin user's password to a random string from CLI") newPwd := random.String(8) setAdminPassword(newPwd) }, }
var RestartCmd = &cobra.Command{ Use: "restart", Short: "Restart openlist server by daemon/pid file", Run: func(cmd *cobra.Command, args []string) { stop() start() }, }
RestartCmd represents the restart command
var RootCmd = &cobra.Command{
Use: "openlist",
Short: "A file list program that supports multiple storage.",
Long: `A file list program that supports multiple storage,
built with love by OpenListTeam.
Complete documentation is available at https://doc.oplist.org/`,
}
var ServerCmd = &cobra.Command{ Use: "server", Short: "Start the server at the specified address", Long: `Start the server at the specified address the address is defined in config file`, Run: func(cmd *cobra.Command, args []string) { bootstrap.Init() defer bootstrap.Release() bootstrap.Start() quit := make(chan os.Signal, 1) signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) <-quit bootstrap.Shutdown(1 * time.Second) }, }
ServerCmd represents the server command
var SetPasswordCmd = &cobra.Command{ Use: "set", Short: "Set admin user's password", RunE: func(cmd *cobra.Command, args []string) error { if len(args) == 0 { return fmt.Errorf("Please enter the new password") } setAdminPassword(args[0]) return nil }, }
var ShowTokenCmd = &cobra.Command{ Use: "token", Short: "Show admin token", Run: func(cmd *cobra.Command, args []string) { bootstrap.Init() defer bootstrap.Release() token := setting.GetStr(conf.Token) utils.Log.Infof("show admin token from CLI") fmt.Println("Admin token:", token) }, }
var StartCmd = &cobra.Command{ Use: "start", Short: "Silent start openlist server with `--force-bin-dir`", Run: func(cmd *cobra.Command, args []string) { start() }, }
StartCmd represents the start command
var StopCmd = &cobra.Command{ Use: "stop", Short: "Stop openlist server by daemon/pid file", Run: func(cmd *cobra.Command, args []string) { stop() }, }
StopCmd represents the stop command
var VersionCmd = &cobra.Command{ Use: "version", Short: "Show current version of OpenList", Run: func(cmd *cobra.Command, args []string) { goVersion := fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH) fmt.Printf(`Built At: %s Go Version: %s Author: %s Commit ID: %s Version: %s WebVersion: %s `, conf.BuiltAt, goVersion, conf.GitAuthor, conf.GitCommit, conf.Version, conf.WebVersion) os.Exit(0) }, }
VersionCmd represents the version command
Functions ¶
func DelAdminCacheOnline ¶
func DelAdminCacheOnline()
func DelUserCacheOnline ¶
func DelUserCacheOnline(username string)