|
|
|
@ -28,35 +28,34 @@ func Configure() error { |
|
|
|
|
title(" Server setup ") |
|
|
|
|
fmt.Println() |
|
|
|
|
|
|
|
|
|
prompt := promptui.Prompt{ |
|
|
|
|
Label: "Local port", |
|
|
|
|
Validate: validatePort, |
|
|
|
|
Default: fmt.Sprintf("%d", c.Server.Port), |
|
|
|
|
tmpls := &promptui.PromptTemplates{ |
|
|
|
|
Success: "{{ . | bold | faint }}: ", |
|
|
|
|
} |
|
|
|
|
port, err := prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
selTmpls := &promptui.SelectTemplates{ |
|
|
|
|
Selected: fmt.Sprintf(`{{.Label}} {{ . | faint }}`, promptui.IconGood), |
|
|
|
|
} |
|
|
|
|
c.Server.Port, _ = strconv.Atoi(port) // Ignore error, as we've already validated number
|
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: "Public-facing host", |
|
|
|
|
Validate: validateDomain, |
|
|
|
|
Default: c.App.Host, |
|
|
|
|
prompt := promptui.Prompt{ |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Local port", |
|
|
|
|
Validate: validatePort, |
|
|
|
|
Default: fmt.Sprintf("%d", c.Server.Port), |
|
|
|
|
} |
|
|
|
|
c.App.Host, err = prompt.Run() |
|
|
|
|
port, err := prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
c.Server.Port, _ = strconv.Atoi(port) // Ignore error, as we've already validated number
|
|
|
|
|
|
|
|
|
|
fmt.Println() |
|
|
|
|
title(" Database setup ") |
|
|
|
|
fmt.Println() |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: "Username", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.User, |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Username", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.User, |
|
|
|
|
} |
|
|
|
|
c.Database.User, err = prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -64,10 +63,11 @@ func Configure() error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: "Password", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.Password, |
|
|
|
|
Mask: '*', |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Password", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.Password, |
|
|
|
|
Mask: '*', |
|
|
|
|
} |
|
|
|
|
c.Database.Password, err = prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -75,9 +75,10 @@ func Configure() error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: "Database name", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.Database, |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Database name", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.Database, |
|
|
|
|
} |
|
|
|
|
c.Database.Database, err = prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -85,9 +86,10 @@ func Configure() error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: "Host", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.Host, |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Host", |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.Database.Host, |
|
|
|
|
} |
|
|
|
|
c.Database.Host, err = prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -95,9 +97,10 @@ func Configure() error { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: "Port", |
|
|
|
|
Validate: validatePort, |
|
|
|
|
Default: fmt.Sprintf("%d", c.Database.Port), |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Port", |
|
|
|
|
Validate: validatePort, |
|
|
|
|
Default: fmt.Sprintf("%d", c.Database.Port), |
|
|
|
|
} |
|
|
|
|
dbPort, err := prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -110,44 +113,74 @@ func Configure() error { |
|
|
|
|
fmt.Println() |
|
|
|
|
|
|
|
|
|
selPrompt := promptui.Select{ |
|
|
|
|
Label: "Site type", |
|
|
|
|
Items: []string{"Single user", "Multiple users"}, |
|
|
|
|
Templates: selTmpls, |
|
|
|
|
Label: "Site type", |
|
|
|
|
Items: []string{"Single user blog", "Multi-user instance"}, |
|
|
|
|
} |
|
|
|
|
_, usersType, err := selPrompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
c.App.SingleUser = usersType == "Single user" |
|
|
|
|
// TODO: if c.App.SingleUser {
|
|
|
|
|
// prompt for username
|
|
|
|
|
// prompt for password
|
|
|
|
|
// create blog
|
|
|
|
|
|
|
|
|
|
siteNameLabel := "Instance name" |
|
|
|
|
if c.App.SingleUser { |
|
|
|
|
siteNameLabel = "Blog name" |
|
|
|
|
} |
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Label: siteNameLabel, |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.App.SiteName, |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: siteNameLabel, |
|
|
|
|
Validate: validateNonEmpty, |
|
|
|
|
Default: c.App.SiteName, |
|
|
|
|
} |
|
|
|
|
c.App.SiteName, err = prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Public URL", |
|
|
|
|
Validate: validateDomain, |
|
|
|
|
Default: c.App.Host, |
|
|
|
|
} |
|
|
|
|
c.App.Host, err = prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if !c.App.SingleUser { |
|
|
|
|
selPrompt = promptui.Select{ |
|
|
|
|
Label: "Registration", |
|
|
|
|
Items: []string{"Open", "Closed"}, |
|
|
|
|
Templates: selTmpls, |
|
|
|
|
Label: "Registration", |
|
|
|
|
Items: []string{"Open", "Closed"}, |
|
|
|
|
} |
|
|
|
|
_, regType, err := selPrompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
c.App.OpenRegistration = regType == "Open" |
|
|
|
|
|
|
|
|
|
prompt = promptui.Prompt{ |
|
|
|
|
Templates: tmpls, |
|
|
|
|
Label: "Max blogs per user", |
|
|
|
|
Default: fmt.Sprintf("%d", c.App.MaxBlogs), |
|
|
|
|
} |
|
|
|
|
maxBlogs, err := prompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
c.App.MaxBlogs, _ = strconv.Atoi(maxBlogs) // Ignore error, as we've already validated number
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
selPrompt = promptui.Select{ |
|
|
|
|
Label: "Federation", |
|
|
|
|
Items: []string{"Enabled", "Disabled"}, |
|
|
|
|
Templates: selTmpls, |
|
|
|
|
Label: "Federation", |
|
|
|
|
Items: []string{"Enabled", "Disabled"}, |
|
|
|
|
} |
|
|
|
|
_, fedType, err := selPrompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -157,8 +190,9 @@ func Configure() error { |
|
|
|
|
|
|
|
|
|
if c.App.Federation { |
|
|
|
|
selPrompt = promptui.Select{ |
|
|
|
|
Label: "Federation usage stats", |
|
|
|
|
Items: []string{"Public", "Private"}, |
|
|
|
|
Templates: selTmpls, |
|
|
|
|
Label: "Federation usage stats", |
|
|
|
|
Items: []string{"Public", "Private"}, |
|
|
|
|
} |
|
|
|
|
_, fedStatsType, err := selPrompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
@ -167,8 +201,9 @@ func Configure() error { |
|
|
|
|
c.App.PublicStats = fedStatsType == "Public" |
|
|
|
|
|
|
|
|
|
selPrompt = promptui.Select{ |
|
|
|
|
Label: "Instance metadata privacy", |
|
|
|
|
Items: []string{"Public", "Private"}, |
|
|
|
|
Templates: selTmpls, |
|
|
|
|
Label: "Instance metadata privacy", |
|
|
|
|
Items: []string{"Public", "Private"}, |
|
|
|
|
} |
|
|
|
|
_, fedStatsType, err = selPrompt.Run() |
|
|
|
|
if err != nil { |
|
|
|
|