From 68fee17793fba5c72b799aa0a31eea8497eb1f63 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 9 Aug 2022 09:56:45 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E5=8A=A0=E5=85=A5=E5=8F=AA=E8=AF=BB?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/wide.go | 10 +++++++--- main.go | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index a45635f..978662c 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -84,8 +84,8 @@ var Docker bool const DockerImageGo = "golang" // Load loads the Wide configurations from wide.json and users' configurations from users/{userId}.json. -func Load(confPath, confData, confServer, confLogLevel string, confSiteStatCode template.HTML) { - initWide(confPath, confData, confServer, confLogLevel, confSiteStatCode) +func Load(confPath, confData, confServer, confLogLevel, confReadOnly string, confSiteStatCode template.HTML) { + initWide(confPath, confData, confServer, confLogLevel, confReadOnly, confSiteStatCode) initUsers() cmd := exec.Command("docker", "version") @@ -155,7 +155,7 @@ func initUsers() { initCustomizedConfs() } -func initWide(confPath, confData, confServer, confLogLevel string, confSiteStatCode template.HTML) { +func initWide(confPath, confData, confServer, confLogLevel, confReadOnly string, confSiteStatCode template.HTML) { bytes, err := ioutil.ReadFile(confPath) if nil != err { logger.Error(err) @@ -219,6 +219,10 @@ func initWide(confPath, confData, confServer, confLogLevel string, confSiteStatC Wide.Server = confServer } + if "" != confReadOnly { + Wide.ReadOnly, _ = strconv.ParseBool(confReadOnly) + } + // SiteStatCode if "" != confSiteStatCode { Wide.SiteStatCode = confSiteStatCode diff --git a/main.go b/main.go index 8e6f86e..394aa6d 100644 --- a/main.go +++ b/main.go @@ -50,6 +50,7 @@ func init() { confData := flag.String("data", "", "path of data dir") confServer := flag.String("server", "", "this will overwrite Wide.Server if specified") confLogLevel := flag.String("log_level", "", "this will overwrite Wide.LogLevel if specified") + confReadOnly := flag.String("readonly", "", "this will overrite Wide.ReadOnly if specified") confSiteStatCode := flag.String("site_stat_code", "", "this will overrite Wide.SiteStatCode if specified") flag.Parse() @@ -66,7 +67,7 @@ func init() { i18n.Load() event.Load() - conf.Load(*confPath, *confData, *confServer, *confLogLevel, template.HTML(*confSiteStatCode)) + conf.Load(*confPath, *confData, *confServer, *confLogLevel, *confReadOnly, template.HTML(*confSiteStatCode)) conf.FixedTimeCheckEnv() session.FixedTimeSave()