Add SqlServerPassword() and HttpServerPassword() to Config, see #16
This commit is contained in:
parent
e37a674e94
commit
e9425329f1
5 changed files with 71 additions and 25 deletions
|
@ -7,8 +7,10 @@ import-path: /srv/photoprism/photos/import
|
|||
export-path: /srv/photoprism/photos/export
|
||||
sql-host: localhost
|
||||
sql-port: 4000
|
||||
sql-password:
|
||||
http-host:
|
||||
http-mode: release
|
||||
http-port: 80
|
||||
http-password:
|
||||
database-driver: internal
|
||||
database-dsn: root:@tcp(localhost:4000)/photoprism?parseTime=true
|
|
@ -81,22 +81,34 @@ var GlobalFlags = []cli.Flag{
|
|||
Value: "",
|
||||
EnvVar: "PHOTOPRISM_HTTP_MODE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "http-password",
|
||||
Usage: "HTTP server password (optional)",
|
||||
Value: "",
|
||||
EnvVar: "PHOTOPRISM_HTTP_PASSWORD",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "sql-port, s",
|
||||
Usage: "Built-in SQL server port",
|
||||
Usage: "built-in SQL server port",
|
||||
Value: 4000,
|
||||
EnvVar: "PHOTOPRISM_SQL_PORT",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "sql-host",
|
||||
Usage: "Built-in SQL server host",
|
||||
Usage: "built-in SQL server host",
|
||||
Value: "",
|
||||
EnvVar: "PHOTOPRISM_SQL_HOST",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "sql-path",
|
||||
Usage: "Built-in SQL server storage path",
|
||||
Usage: "built-in SQL server storage path",
|
||||
Value: "",
|
||||
EnvVar: "PHOTOPRISM_SQL_PATH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "sql-password",
|
||||
Usage: "built-in SQL server password",
|
||||
Value: "",
|
||||
EnvVar: "PHOTOPRISM_SQL_PASSWORD",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -30,26 +30,28 @@ const (
|
|||
//
|
||||
// See https://github.com/photoprism/photoprism/issues/50#issuecomment-433856358
|
||||
type Config struct {
|
||||
appName string
|
||||
appVersion string
|
||||
appCopyright string
|
||||
debug bool
|
||||
configFile string
|
||||
assetsPath string
|
||||
cachePath string
|
||||
originalsPath string
|
||||
importPath string
|
||||
exportPath string
|
||||
sqlServerHost string
|
||||
sqlServerPort uint
|
||||
sqlServerPath string
|
||||
httpServerHost string
|
||||
httpServerPort int
|
||||
httpServerMode string
|
||||
darktableCli string
|
||||
databaseDriver string
|
||||
databaseDsn string
|
||||
db *gorm.DB
|
||||
appName string
|
||||
appVersion string
|
||||
appCopyright string
|
||||
debug bool
|
||||
configFile string
|
||||
assetsPath string
|
||||
cachePath string
|
||||
originalsPath string
|
||||
importPath string
|
||||
exportPath string
|
||||
sqlServerHost string
|
||||
sqlServerPort uint
|
||||
sqlServerPath string
|
||||
sqlServerPassword string
|
||||
httpServerHost string
|
||||
httpServerPort int
|
||||
httpServerMode string
|
||||
httpServerPassword string
|
||||
darktableCli string
|
||||
databaseDriver string
|
||||
databaseDsn string
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
// NewConfig() creates a new configuration entity by using two methods:
|
||||
|
@ -90,6 +92,10 @@ func (c *Config) SetValuesFromFile(fileName string) error {
|
|||
c.sqlServerPort = uint(sqlServerPort)
|
||||
}
|
||||
|
||||
if sqlServerPassword, err := yamlConfig.Get("sql-password"); err == nil {
|
||||
c.sqlServerPassword = sqlServerPassword
|
||||
}
|
||||
|
||||
if sqlServerPath, err := yamlConfig.Get("sql-path"); err == nil {
|
||||
c.sqlServerPath = sqlServerPath
|
||||
}
|
||||
|
@ -102,8 +108,12 @@ func (c *Config) SetValuesFromFile(fileName string) error {
|
|||
c.httpServerPort = int(httpServerPort)
|
||||
}
|
||||
|
||||
if serverMode, err := yamlConfig.Get("http-mode"); err == nil {
|
||||
c.httpServerMode = serverMode
|
||||
if httpServerMode, err := yamlConfig.Get("http-mode"); err == nil {
|
||||
c.httpServerMode = httpServerMode
|
||||
}
|
||||
|
||||
if httpServerPassword, err := yamlConfig.Get("http-password"); err == nil {
|
||||
c.httpServerPassword = httpServerPassword
|
||||
}
|
||||
|
||||
if assetsPath, err := yamlConfig.Get("assets-path"); err == nil {
|
||||
|
@ -340,6 +350,11 @@ func (c *Config) SqlServerPath() string {
|
|||
return c.ServerPath() + "/database"
|
||||
}
|
||||
|
||||
// SqlServerPassword returns the password for the built-in database server.
|
||||
func (c *Config) SqlServerPassword() string {
|
||||
return c.sqlServerPassword
|
||||
}
|
||||
|
||||
// HttpServerHost returns the built-in HTTP server host name or IP address (empty for all interfaces).
|
||||
func (c *Config) HttpServerHost() string {
|
||||
return c.httpServerHost
|
||||
|
@ -355,6 +370,11 @@ func (c *Config) HttpServerMode() string {
|
|||
return c.httpServerMode
|
||||
}
|
||||
|
||||
// HttpServerPassword returns the password for the user interface (optional).
|
||||
func (c *Config) HttpServerPassword() string {
|
||||
return c.httpServerPassword
|
||||
}
|
||||
|
||||
// OriginalsPath returns the originals.
|
||||
func (c *Config) OriginalsPath() string {
|
||||
return c.originalsPath
|
||||
|
|
|
@ -25,10 +25,12 @@ type Config interface {
|
|||
SqlServerHost() string
|
||||
SqlServerPort() uint
|
||||
SqlServerPath() string
|
||||
SqlServerPassword() string
|
||||
|
||||
HttpServerHost() string
|
||||
HttpServerPort() int
|
||||
HttpServerMode() string
|
||||
HttpServerPassword() string
|
||||
HttpTemplatesPath() string
|
||||
HttpFaviconsPath() string
|
||||
HttpPublicPath() string
|
||||
|
|
|
@ -198,11 +198,21 @@ func (c *Config) SqlServerPort() uint {
|
|||
return 4001
|
||||
}
|
||||
|
||||
// SqlServerPassword returns the password for the built-in database server.
|
||||
func (c *Config) SqlServerPassword() string {
|
||||
return "photoprism"
|
||||
}
|
||||
|
||||
// HttpServerMode returns the server mode.
|
||||
func (c *Config) HttpServerMode() string {
|
||||
return "test"
|
||||
}
|
||||
|
||||
// HttpServerPassword returns the password for the Web UI.
|
||||
func (c *Config) HttpServerPassword() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// OriginalsPath returns the originals.
|
||||
func (c *Config) OriginalsPath() string {
|
||||
return OriginalsPath
|
||||
|
|
Loading…
Reference in a new issue