mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-18 07:36:24 -07:00
Properly log config issues if value isn't set and msg != ""
This commit is contained in:
parent
7e4ea59dbe
commit
19466dd8eb
3 changed files with 33 additions and 13 deletions
4
go.mod
4
go.mod
|
@ -7,12 +7,12 @@ require (
|
|||
github.com/disintegration/imaging v1.6.2
|
||||
github.com/frustra/bbcode v0.0.0-20180807171629-48be21ce690c
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/lib/pq v1.4.0
|
||||
github.com/lib/pq v1.5.2
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||
github.com/mojocn/base64Captcha v1.3.1
|
||||
github.com/nranchev/go-libGeoIP v0.0.0-20170629073846-d6d4a9a4c7e8 // indirect
|
||||
github.com/tdewolff/minify v2.3.6+incompatible
|
||||
github.com/tdewolff/parse v2.3.4+incompatible // indirect
|
||||
golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f
|
||||
)
|
||||
|
|
4
go.sum
4
go.sum
|
@ -10,6 +10,8 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF0
|
|||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/lib/pq v1.4.0 h1:TmtCFbH+Aw0AixwyttznSMQDgbR5Yed/Gg6S8Funrhc=
|
||||
github.com/lib/pq v1.4.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.5.2 h1:yTSXVswvWUOQ3k1sd7vJfDrbSl8lKuscqFJRqjC0ifw=
|
||||
github.com/lib/pq v1.5.2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mojocn/base64Captcha v1.2.2 h1:NTFnThPVrb3tR66JO/N8/ZHsyFrNc7ho+xRpxBUEIlo=
|
||||
|
@ -35,6 +37,8 @@ golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+o
|
|||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U=
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f h1:QBjCr1Fz5kw158VqdE9JfI9cJnl/ymnJWAdMuinqL7Y=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
|
|
@ -111,6 +111,9 @@ func (cfg *GochanConfig) checkString(val, defaultVal string, critical bool, msg
|
|||
if critical {
|
||||
flags |= gclog.LFatal
|
||||
}
|
||||
if msg != "" {
|
||||
gclog.Print(flags, msg)
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
@ -122,10 +125,14 @@ func (cfg *GochanConfig) checkInt(val, defaultVal int, critical bool, msg string
|
|||
if critical {
|
||||
flags |= gclog.LFatal
|
||||
}
|
||||
if msg != "" {
|
||||
gclog.Print(flags, msg)
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// InitConfig loads and parses gochan.json and verifies its contents
|
||||
func InitConfig(versionStr string) {
|
||||
cfgPath := findResource("gochan.json", "/etc/gochan/gochan.json")
|
||||
if cfgPath == "" {
|
||||
|
@ -154,7 +161,8 @@ func InitConfig(versionStr string) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
Config.checkString(Config.ListenIP, "", true, "ListenIP not set in gochan.json, halting.")
|
||||
Config.checkString(Config.ListenIP, "", true,
|
||||
"ListenIP not set in gochan.json, halting.")
|
||||
|
||||
if Config.Port == 0 {
|
||||
Config.Port = 80
|
||||
|
@ -164,8 +172,10 @@ func InitConfig(versionStr string) {
|
|||
Config.FirstPage = []string{"index.html", "board.html", "firstrun.html"}
|
||||
}
|
||||
|
||||
Config.Username = Config.checkString(Config.Username, "gochan", false, "Username not set in gochan.json, using 'gochan' as default")
|
||||
Config.DocumentRoot = Config.checkString(Config.DocumentRoot, "gochan", true, "DocumentRoot not set in gochan.json, halting.")
|
||||
Config.Username = Config.checkString(Config.Username, "gochan", false,
|
||||
"Username not set in gochan.json, using 'gochan' as default")
|
||||
Config.DocumentRoot = Config.checkString(Config.DocumentRoot, "gochan", true,
|
||||
"DocumentRoot not set in gochan.json, halting.")
|
||||
|
||||
wd, wderr := os.Getwd()
|
||||
if wderr == nil {
|
||||
|
@ -176,21 +186,27 @@ func InitConfig(versionStr string) {
|
|||
}
|
||||
|
||||
Config.TemplateDir = Config.checkString(
|
||||
findResource(Config.TemplateDir, "templates", "/usr/local/share/gochan/templates/", "/usr/share/gochan/templates/"),
|
||||
"", true, "Unable to locate template directory, halting.")
|
||||
findResource(Config.TemplateDir, "templates", "/usr/local/share/gochan/templates/", "/usr/share/gochan/templates/"), "", true,
|
||||
"TemplateDir not set in gochan.json or unable to locate template directory, halting.")
|
||||
|
||||
Config.checkString(Config.DBtype, "", true, "DBtype not set in gochan.json, halting (currently supported values: mysql,postgresql,sqlite3)")
|
||||
Config.checkString(Config.DBhost, "", true, "DBhost not set in gochan.json, halting.")
|
||||
Config.checkString(Config.DBtype, "", true,
|
||||
"DBtype not set in gochan.json, halting (currently supported values: mysql,postgresql,sqlite3)")
|
||||
Config.checkString(Config.DBhost, "", true,
|
||||
"DBhost not set in gochan.json, halting.")
|
||||
Config.DBname = Config.checkString(Config.DBname, "gochan", false,
|
||||
"DBname not set in gochan.json, setting to 'gochan'")
|
||||
|
||||
Config.checkString(Config.DBusername, "", true, "DBusername not set in gochan, halting.")
|
||||
Config.checkString(Config.DBpassword, "", true, "DBpassword not set in gochan, halting.")
|
||||
Config.checkString(Config.DBusername, "", true,
|
||||
"DBusername not set in gochan, halting.")
|
||||
Config.checkString(Config.DBpassword, "", true,
|
||||
"DBpassword not set in gochan, halting.")
|
||||
Config.LockdownMessage = Config.checkString(Config.LockdownMessage,
|
||||
"The administrator has temporarily disabled posting. We apologize for the inconvenience", false, "")
|
||||
|
||||
Config.checkString(Config.SiteName, "", true, "SiteName not set in gochan.json, halting.")
|
||||
Config.checkString(Config.SiteDomain, "", true, "SiteName not set in gochan.json, halting.")
|
||||
Config.checkString(Config.SiteName, "", true,
|
||||
"SiteName not set in gochan.json, halting.")
|
||||
Config.checkString(Config.SiteDomain, "", true,
|
||||
"SiteName not set in gochan.json, halting.")
|
||||
|
||||
if Config.SiteWebfolder == "" {
|
||||
gclog.Print(gclog.LErrorLog|gclog.LStdLog, "SiteWebFolder not set in gochan.json, using / as default.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue