added configuration for webserver and AllowRoot
This commit is contained in:
parent
0fd673cd19
commit
8021684f77
5 changed files with 39 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*.yaml
|
||||
|
||||
# ---> Go
|
||||
# Binaries for programs and plugins
|
||||
|
|
10
README.md
10
README.md
|
@ -1,3 +1,13 @@
|
|||
# Feedizer
|
||||
|
||||
A rewrite of the [Feedizer](https://git.zom.bi/fanir/feedizer) project originally written in PHP5.
|
||||
|
||||
## Configuration
|
||||
|
||||
To write the default configuration to a file, run `feedizer [-C path/to/configfile.yaml] newconfig`
|
||||
|
||||
## Running as root
|
||||
|
||||
Feedizer will abort startup if run as root. If you want to disable this behavior,
|
||||
i.e. because feedizer is running inside a docker container, you can set
|
||||
`FEEDIZER_ALLOWROOT=1` in the environment or `AllowRoot: true` in the config file.
|
||||
|
|
|
@ -17,8 +17,18 @@ type DatabaseConfig struct {
|
|||
Options string
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Address string
|
||||
TemplateDir string
|
||||
StaticDir string
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Database DatabaseConfig
|
||||
|
||||
Server ServerConfig
|
||||
|
||||
AllowRoot bool
|
||||
}
|
||||
|
||||
var config = Config{
|
||||
|
@ -28,6 +38,11 @@ var config = Config{
|
|||
Database: "feedizer",
|
||||
Options: "sslmode=require",
|
||||
},
|
||||
Server: ServerConfig{
|
||||
Address: ":3000",
|
||||
TemplateDir: "../../templates",
|
||||
StaticDir: "../../static",
|
||||
},
|
||||
}
|
||||
|
||||
const appName = "feedizer"
|
||||
|
|
|
@ -57,6 +57,15 @@ func structFromEnv(v reflect.Value, t reflect.Type, prefix string) (namesAvailab
|
|||
panic(err)
|
||||
}
|
||||
fv.SetInt(x)
|
||||
case reflect.Bool:
|
||||
switch strings.ToLower(val) {
|
||||
case "1", "true", "t", "on":
|
||||
fv.SetBool(true)
|
||||
case "0", "false", "f", "off":
|
||||
fv.SetBool(false)
|
||||
default:
|
||||
panic(fmt.Sprintf("cannot set field for environment variable %s: cannot parse %s as boolean. Please use one of: 1, true, t, on / 0, false, f, off", envName, fk))
|
||||
}
|
||||
default:
|
||||
panic(fmt.Sprintf("cannot set field for environment variable %s: type %s is not supported", envName, fk))
|
||||
}
|
||||
|
|
|
@ -14,10 +14,6 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
if os.Geteuid() == 0 {
|
||||
log.Fatalln("do not run feedizer as root")
|
||||
}
|
||||
|
||||
configFile := flag.String("C", "", "custom config file path")
|
||||
autoMigrate := flag.Bool("m", true, "Automatically migrate the database to the highest version.")
|
||||
flag.Parse()
|
||||
|
@ -49,6 +45,10 @@ func startApp(automigrate bool) {
|
|||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if !cfg.AllowRoot && os.Geteuid() == 0 {
|
||||
log.Fatalln("do not run feedizer as root")
|
||||
}
|
||||
|
||||
db, err := database.Open(cfg.Database)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
|
|
Loading…
Reference in a new issue