From ba9d568539feb0270e8631c2d6e1fb23f52dfb14 Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Sat, 13 Aug 2022 20:56:19 +0800 Subject: [PATCH] fix: add `-password` flag back --- alist.go | 11 +++++++++++ bootstrap/log.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/alist.go b/alist.go index a34d3b8cde5..f42ef41c59b 100644 --- a/alist.go +++ b/alist.go @@ -2,9 +2,11 @@ package main import ( "fmt" + "github.com/Xhofe/alist/bootstrap" "github.com/Xhofe/alist/conf" _ "github.com/Xhofe/alist/drivers" + "github.com/Xhofe/alist/model" "github.com/Xhofe/alist/server" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" @@ -14,6 +16,15 @@ func Init() bool { bootstrap.InitConf() bootstrap.InitCron() bootstrap.InitModel() + if conf.Password { + pass, err := model.GetSettingByKey("password") + if err != nil { + log.Errorf(err.Error()) + return false + } + fmt.Printf("your password: %s\n", pass.Value) + return false + } server.InitIndex() bootstrap.InitSettings() bootstrap.InitAuth() diff --git a/bootstrap/log.go b/bootstrap/log.go index 7e188994110..d7350dd6838 100644 --- a/bootstrap/log.go +++ b/bootstrap/log.go @@ -2,6 +2,7 @@ package bootstrap import ( "flag" + "github.com/Xhofe/alist/conf" log "github.com/sirupsen/logrus" ) @@ -29,6 +30,7 @@ func init() { flag.StringVar(&conf.ConfigFile, "conf", "data/config.json", "config file") flag.BoolVar(&conf.Debug, "debug", false, "start with debug mode") flag.BoolVar(&conf.Version, "version", false, "print version info") + flag.BoolVar(&conf.Password, "password", false, "print current password") flag.BoolVar(&conf.Docker, "docker", false, "is using docker") flag.Parse() InitLog()